Comments (7)
How to do this with webpack 1.x or later? emitFile
and noWrite
seem gone. Already changed absoluteFile
arg to entry: absoluteFile
in config options.
Only possible with memory file system, e.g. https://webpack.github.io/docs/node.js-api.html#compile-to-memory? Or custom read from filesystem after compile?
from webpack.
yes. There is an option noWrite
and you need to pass the option emitFile
to get the source of a file.
Here is a working example: https://github.com/webpack/worker-loader/blob/master/index.js
It's a webpack loader which compiles to WebWorker.
It's called from the parent webpack and executes a embedded webpack. The embeddend webpack do not write out files, but the worker-loader grabs the emitted files and pass them to the parent webpack.
Good luck.
from webpack.
The API which returns the source in the callback was deprecated in webpack 0.5 and I removed it in 0.6. The reason for removing was that many loader would not work with the old API because they emit files. I. e. file-loader
.
The webpack-dev-middleware also do webpack in memory: https://github.com/webpack/webpack-dev-middleware/blob/master/middleware.js#L15
from webpack.
Thank you for your fast response. I'm not sure if I got it, but are the following steps correct?
- first: set
noWrite
totrue
- second: define with
emitFile
a function that collects the source of each file, likefunction collectSources(filename, content) { /* do some collecting stuff */ }
- third: execute
webpack(absolutePath, options, function(err, stats) { /* nothing really to do here */})
- fourth: on
"bundle"
-event webpack has finished and I can return in any way the collected sources
If I try it like described I get the following error:
Error: options.output is required
from webpack.
Set output to the name of the bundled file, i. e. bundle.js
.
You don't need the "bundle" event just use the callback in third.
webpack(absoluteFile, {
output: "bundle.js",
noWrite: true,
emitFile: function(name, stringOrBuffer) {
files[name] = stringOrBuffer;
}
}, function(err, stats) {
if(err) return handleError(err);
processFiles(files);
})
from webpack.
Thank you again for your fast response and help. It works now. If you like to you can take a look my implementation here: WebpackBundler
from webpack.
peerigon/nof5#10
peerigon/nof5#11
from webpack.
Related Issues (20)
- Module Federation - Some chunks are not loaded when navigating from the Remote module to the Host module
- failed to import ffmpeg-core.js HOT 1
- Webpack 5 doesnt generate the chunks of imports HOT 1
- Error: Cannot find module 'webpack-cli/package.json' HOT 2
- Unable to bust cache of module federation remotes....
- Re-exported Ant Design components don't have same style with the original components
- failed to import ffmpeg-core.js HOT 3
- DllPlugin: When processing multiple chunks, does the `path` option must have a string template?
- Webpack BannerPlugin with `raw` option should put `use strict` on the very first line HOT 10
- After webpack 5 migration not able to use local packages in a mono repo
- 95% emitting emit phase takes much longer in Node >=16
- Plugin apply not working for multi compiler HOT 2
- packages/tailwindcss/src/compile.ts HOT 1
- Current error handling mainly involves calling the `onInvalidCandidate` callback function to handle invalid candidates, and printing corresponding error messages to the console.
- [5.91.0] "Fixed fs types" breaks `outputFileSystem` compatibility with `memfs` HOT 6
- Using `[name]` within `output.library`, the correct value isn't utilized in the source map namespace HOT 1
- Not found node_modules/@angular/common/bundles/common-http.umd.js
- webpack5.90.0 Modifying files in the node_modules directory (local component library) cannot trigger hot updates HOT 1
- Delete this. HOT 1
- how to make webpack recompile on dev mode with cache on? 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.