output: {
path: path.join(__dirname, './dist'),
filename: 'index.js',
libraryTarget: 'umd',
// globalObject: 'window',
publicPath: '/dist/',
umdNamedDefine: true,
If the current behavior is a bug, please provide the steps to reproduce.
Not sure how to answer this.
What is the expected behavior?
Explicitly defining globalObject: 'window'
should have identical behavior as failing to declare the globalObject
key at all.
Other relevant information:
webpack version: 5.31.1
Node.js version: 12.21.0
Operating System: Windows 7
So our situation is working now a-okay, but if I hadn't tried this seemingly silly idea, I don't know how many hours I would have spent wondering what could possibly be wrong. So I'm hoping that someone knows what the real default value is and hopefully we can get the docs fixed quickly and potentially save someone else a lot of head scratching.
Thanks for your reply @alexander-akait. I see that the default is 'self'
, but that it's not quite that simple, so it's not clear to me what the docs should say, but if you can clarify I'd be happy to submit a PR.
I found these additional details related to what you mentioned but they didn't clarify it enough for me to know what the docs should say for output.globalObject
.
The return value of your entry point will be assigned to the global object using the output.library.name value. Depending on the target value, the global object could change respectively, e.g., self, global or globalThis.