[Feature Request] Use virtual file as entry point
See original GitHub issueDo you want to request a feature or report a bug?
feature
What is the current behavior?
You must specify the entry point file path and output dir.
If the current behavior is a bug, please provide the steps to reproduce.
not a bugs.
What is the expected behavior?
We can specify the code string as an entry point.
If this is a feature request, what is motivation or use case for changing the behavior?
I some case. I build a builder cli base on webpack. I need to pack my code.
In current behavior, I gonna create a temp file and use it as entry file, so webpack can work it well.
webpack({
entry: "/path/to/temp/file.js" // before pack the code, I need to create this temp file first
});
What if I can use code string as an entry point?
such as this:
webpack({
entry: {
code: "const xx = require('xxx'); // do something else",
filepath: "/home/xxx/xxx.js"
}
});
Or maybe we can make it better
const virtualEntryFile = new webpack.VirtualFile(
"filepath.js",
"// here is the js code string"
);
const virtualImages = new webpack.VirtualFile(
"example.png",
new Buffer()
);
webpack({
entry: virtualEntryFile
});
In here, you can see that, I don’t need to create an intermediary file anymore
Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:43
- Comments:23 (7 by maintainers)
I just tested
virtual-module-webpack-plugin
which seems to work with entry points and also (interesting for my case) as template source for the HtmlWebpackPlugin.Example: const VirtualModulePlugin = require(‘virtual-module-webpack-plugin’);
If you want to be able to access
node_modules
, I’d suggest using a memory file system + node fs and merging them withunionfs
and then in the compiler using: