Can't create UMD build which can be required by Node
See original GitHub issueDo you want to request a feature or report a bug?
bug
What is the current behavior?
If you require a module in the target output UMD you get this error:
ReferenceError: window is not defined
at Object.<anonymous> (/mnt/c/Users/foo/webpack-umd-node/dist/main.js:1:272)
If the current behavior is a bug, please provide the steps to reproduce.
- https://github.com/donaldpipowitch/webpack-umd-node
$ git clone git@github.com:donaldpipowitch/webpack-umd-node.git && cd webpack-umd-node && yarn && yarn build && yarn test
What is the expected behavior?
You shouldn’t see a ReferenceError
.
If this is a feature request, what is motivation or use case for changing the behavior?
Please mention other relevant information such as the browser version, Node.js version, webpack version, and Operating System.
Node v8.9.4, webpack v4.0.0-beta.2
According to https://webpack.js.org/configuration/output/#module-definition-systems the UMD build should not include window
.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:64
- Comments:28 (5 by maintainers)
Top Results From Across the Web
Webpack UMD: Critical dependency... cannot be statically ...
when I try to require('./index.js') the generated index.js I get: Error: Cannot find module "." For completeness here are all my files ...
Read more >Bundling with Rollup: Build CommonJS to UMD
How to build a Rollup bundle to UMD, CJS, and IIFE formats for CommonJS modules. ... in node_modules , you need to install...
Read more >NPM Support - Babylon.js Documentation
We first run npm init to generate package.json . You can generate package.json in any other way you wish. After package,json was generated,...
Read more >How to write and build JS libraries in 2018 - Medium
We can't leave var EventBus = require('eventbus') like it was in source. UMD looks nice, but simple nano-libraries is not a case for...
Read more >You may not need a bundler for your NPM library
I'd recommend just compiling your code with tsc , no bundler involved. This way, you can develop with typescript, it will output js...
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
Setting
globalObject: 'typeof self !== \'undefined\' ? self : this'
produces exactly the same UMD header as in WebPack 3With
target: 'node'
it throwsUncaught ReferenceError: global is not defined
if the UMD build is loaded in the browser 😄globalObject: 'this'
works for Node and the browser. Is this a new setting? I haven’t seen it before. Is this the right way to do it or is it a bug that I need to do that? I’ll update my linked example.