question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hack require in Webpack compilation

See original GitHub issue

I’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:closed
  • Created 8 years ago
  • Comments:27 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
catamphetaminecommented, Jan 6, 2016
0reactions
catamphetaminecommented, May 21, 2016

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 than webpack-ismorphic-tools and instead of hacking Node.js require() calls it just compiles all code with target: '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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found