Hack require in Webpack compilation
See original GitHub issueI’m wondering if you ever discovered a way/created a plugin for Webpack to redefine requires for server compilation through Webpack. You suggested here https://github.com/halt-hammerzeit/webpack-isomorphic-tools/issues/7#issuecomment-149092151 the maybe this could be done through NormalModuleReplacement
plugin.
webpack-isomorphic-tools
are working great for me if I pre-compile my files with Babel or use babel-register but I’m running into situations, such as on AWS Lambda, that I would prefer to make a server bundle with Webpack, then I don’t have to zip all my client node_modules and upload them to Lambda.
Wondering if there is an easy way to do this?
Issue Analytics
- State:
- Created 8 years ago
- Comments:27 (15 by maintainers)
Top Results From Across the Web
How do I require() from the console using webpack?
First, require the module at least once. import "webpack-runtime-require";. It will then add a Require() function to the window object ...
Read more >Fixing WebpackChunkName for Dynamic Imports - Time to Hack
The First line of the Readme of the repo: Babel plugin to transpile import() to require.ensure , for Webpack. And this is what...
Read more >webpack-on-demand - npm
This is an experimental webpack plugin that enables you to only compile modules once they are requested by the browser. This may be...
Read more >webpack | Its always better to hack around than... - Amit Gharat
A month ago, I wrote a blog post explaining a hacky way to enable tree-shaking in Rails/Webpacker project at Simpl. I would definitely...
Read more >To v2 or v3 from v1 - webpack
You may remove some hacks to work around this: module: { rules: [ { // ... - loader: require.resolve("my-loader") + loader: "my-loader" }...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@danecando There are a lot of christians here though. We don’t fight with each other yet. http://politicalhotwire.com/current-events/119136-obamas-lack-education-display-again-time-equating-christianity-isis-15.html
FYI I’m posting this in every issue and PR to notify whoever may be interested: today I’ve released an alternative helper library called
universal-webpack
. It takes a different approach thanwebpack-ismorphic-tools
and instead of hacking Node.jsrequire()
calls it just compiles all code withtarget: 'node'
webpack configuration option. As a result, all Webpack plugins and features are supported. If you think you might need that here’s an example project: https://github.com/halt-hammerzeit/webpack-react-redux-isomorphic-render-example