Git Product home page Git Product logo

Comments (8)

larixer avatar larixer commented on June 1, 2024 1

@stevenpetryk This comparison should be done on caller side. wrtieModule is expected to match the behaviour of fs.writeFile, e.g. when you write the same contents the file timestamp should be updated and recompilation should be scheduled. It is a bug in the example

from webpack-virtual-modules.

stevenpetryk avatar stevenpetryk commented on June 1, 2024

I found a gross workaround. You can compare webpack's filesystem with the incoming changes you want to write to your module, and bail out if they're the same:

const modulePath = "<YOUR MODULE'S *ABSOLUTE* PATH>"
const moduleContents = "<YOUR MODULE'S CONTENTS>"

let finalInputFileSystem = compiler.inputFileSystem;
while (finalInputFileSystem && finalInputFileSystem._inputFileSystem) {
  finalInputFileSystem = finalInputFileSystem._inputFileSystem;
}

const existing = finalInputFileSystem._virtualFiles[modulePath];
if (existing.contents != moduleContents) {
  virtualModules.writeModule(modulePath, moduleContents);
}

from webpack-virtual-modules.

stevenpetryk avatar stevenpetryk commented on June 1, 2024

So maybe the fix here would just be that webpack-virtual-modules needs to ignore calls to writeModule when they wouldn't change the module.

from webpack-virtual-modules.

larixer avatar larixer commented on June 1, 2024

Closing as works as intended, we also have #89 which tells about the opposite intended behaviour. And only one behaviour from these two can exists, because they are in direct contradiction to each another.

from webpack-virtual-modules.

atesgoral avatar atesgoral commented on June 1, 2024

@larixer

It is a bug in the example

I assume the said bug is still there? Running the webpack 5 example, I see an infinite compilation loop.

from webpack-virtual-modules.

larixer avatar larixer commented on June 1, 2024

@atesgoral

It is a bug in the example

I assume the said bug is still there? Running the webpack 5 example, I see an infinite compilation loop.

Yes, it is still present in the example.

from webpack-virtual-modules.

chaddjohnson avatar chaddjohnson commented on June 1, 2024

This still appears to be an issue. Seems to happen with @shopify/web-worker/webpack which uses webpack-virtual-modules. Happens when using webpack-dev-server (webpack serve) or webpack --watch.

from webpack-virtual-modules.

borayuksel1903 avatar borayuksel1903 commented on June 1, 2024

We are using this API on our end, and are seeing this infinite loop issue still. Opening a PR for a potential fix, but open to other suggestions. I don't think this and #89 need to be conflicting, we could hopefully have both issues fixed.

from webpack-virtual-modules.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.