New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trying to find async import() files #323
Comments
You need to use Rough example: webpack/webpack-dev-middleware#366 (comment) When you use require-from-string it doesn’t do anything magic and won’t be able to resolve any other files from memory file system. Unionfs and fs-monkey will patch |
Alternatively, you can configure your webpack bundle to not do any code splitting when bundling for server in dev mode. If you have one giant bundle file then webpack will handle all of the dynamic imports instead of relying on node to be able to find external files. Node externals won’t work the way you’re expecting either, if you’re using |
This is super helpful, thank you! |
I built a middleware for express that compiles the server's code for dev environments, it uses memfs presently, but the issue is when I
require-from-string
thecompiler.outputFileSystem
server file and that primary entry file tries to find a dynamic import(), it can't find that path based on webpack'soutput.path
. It always checks for real paths (in my case/Users/dveremchuk/source/webpack4-react-new/lib/server/
). I use '@babel/plugin-syntax-dynamic-import' to parse the import. I realize I can just convert the import to a deferred require, but I need to test things.I tried rewriting node's
Module._findPath()
but that's a bit over my head now, and I didn't have time to dig into it.Is it somehow possible to implement this with memfs/unionfs/fs-monkey?
Gist of what middleware is doing:
node_modules/my-custom-middleware/lib/main-middleware.js
Test component I use:
Error:
Webpack server config
The text was updated successfully, but these errors were encountered: