Comments (8)
@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.
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.
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.
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.
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.
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.
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.
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)
- [Bug] Plugin causes console noise when used alongside debug.js HOT 2
- [Feature] Support removeModule API HOT 6
- [Bug] virtual module trigger extra compilation in webpack 5 HOT 5
- [Bug] Uppercase driver letter in windows
- Incorrectly used fileWatcher, that causing writeModule not trigger recompile with webpack-dev-server HOT 1
- [Feature] GetModule/ReadModule API HOT 2
- [Bug] Using React/JSX with `webpack-virtual-modules` gives error even when `@babel/preset-react` is used HOT 1
- [Bug] HOT 1
- [Question] - Is it possible generate new virtual modules based on file-system changes? HOT 1
- [Bug] ModuleNotFoundError happened ,when I compile two project in the same progress HOT 3
- [Bug] Local version of webpack-virtual-modules in next-with-linaria HOT 3
- [Question] Next.js compatibility
- [Bug] Multiple config and broken invalidation right from the start HOT 10
- [Feature] Custom URI scheme
- What are some real usecases of this plugin? HOT 1
- [Bug] Question: Trigger webpack rebuild HOT 7
- [Feature] Expose types HOT 1
- [Bug] Stale virtual module contents upon ".writeModule" HOT 6
- [Bug] Compatibility with AngularCompilerPlugin HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webpack-virtual-modules.