Skip to content
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

Support name-spaced UMD module names #378

Closed
ericf opened this issue Dec 28, 2015 · 5 comments
Closed

Support name-spaced UMD module names #378

ericf opened this issue Dec 28, 2015 · 5 comments
Assignees

Comments

@ericf
Copy link
Contributor

ericf commented Dec 28, 2015

I'd like to set the --name option to be something like: Foo.bar. Rollup will accept this as input and output Global.Foo.bar = ... in the UMD module, but this will break if Foo isn't already defined.

Browserify supports name-spaced module names by recognizing this pattern and generating code to make sure the object is defined before the member expression assignment. Something like:

(global.Foo || (global.Foo = {})).bar = ...

It would be great if Rollup also supported this for name-spaced UMD module names.

@ericf
Copy link
Contributor Author

ericf commented Dec 30, 2015

Thanks! 😄

@Rich-Harris
Copy link
Contributor

Thanks for raising it! Just published a new version with this fix – 0.22.1

@ericf
Copy link
Contributor Author

ericf commented Dec 30, 2015

@Rich-Harris I've tried this out in 0.22.2 and it appears to be generating bad code. You can see in this example.

The comma expression needs parens around it, otherwise it throws in a CommonJS or AMD environment.

ericf added a commit to ericf/rollup that referenced this issue Dec 30, 2015
This wraps the comma expression generated when using a namespaced
global module name; e.g.: `Foo.bar`. Previously the generated code
would fail in a CommonJS or AMD module environment.

See: rollup#378
@ericf
Copy link
Contributor Author

ericf commented Dec 30, 2015

PR to address the above problem: #392

@sevencai
Copy link

sevencai commented Mar 5, 2023

Is there any way to disable name-spaced UMD module names?

Sometimes I just need a dot in exported name, like 1.0 version in it.

image

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants