Closed kisenka closed 8 years ago
Yup, exactly :) If you take a look at:
https://github.com/christianalfoni/webpack-bin/blob/master/server/index.js#L31 https://github.com/christianalfoni/webpack-bin/blob/master/server/preLoadPackages.js
You see how I preload them into memory :-)
Closing this, hope it helped you out!
Hi @christianalfoni Great information both in this issue as well as in https://github.com/webpack/webpack/issues/1562
I'm also trying to use Webpack compiler in memory, and I'm also struggling with loaders/presets. Maybe you (or someone) can give me an hand on that..
My webpack setup is like this:
var compiler = webpack({
entry: "/src/index.js",
output: {
filename: '[name].js',
path: '../dist'
},
module: {
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015', 'react']
}
}]
}
});
compiler.inputFileSystem = inputFs;
compiler.resolvers.normal.fileSystem = compiler.inputFileSystem;
compiler.resolvers.context.fileSystem = compiler.inputFileSystem;
my memory filesystem (inputFs
) is like this (Note: I wrote a JSON to simplify how the fs is structured):
{
"/src/index.js/": "ReactDOM.render(<h1>Hello World!</h1>,document.getElementById('example'));"
}
I tried to run this code directly, giving me the exception:
Module build failed: Error: Couldn't find preset "es2015" relative to directory "/src"
And I also tried to run this code with your preLoadPackages
method with the difference that I used require('recursive-readdir-sync');
instead of require('recursive-readdir');
to ensure that when I called compiler.run
the memory fs had all the files (I also checked this).
Any ideas of what I might be getting wrong?
Thank you in advanced!
Hi! I'm trying to use Webpack compiler in memory (input & output filesystem) just like you do (https://github.com/christianalfoni/webpack-bin/blob/master/server/sessionBundler.js#L82). All was great until loaders is appears in configuration :) Because of filesystem located in memory seems like loaders files needs to be in memory too. Am I right? My setup is pretty simple:
It's strange but I'm getting error only from css-loader, not from sass-loader.