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

Invalid JS identifier if global name of export has a dot in it #21

Open
joebandenburg opened this issue Jan 7, 2015 · 1 comment
Open

Comments

@joebandenburg
Copy link

I have a particular use case where a library I depend on puts a global inside a namespace. For example, they export a global org.company.lib. If I use a command like:

pure-cjs --input index.js --output dist/foo.js --external '{"lib": {"global": "org.company.lib"}}' --exports foo

This produces invalid output:

(function (factory) {
   ...
}(function (__external_org.company.lib) {
   ...

As you can see, the dots need to be transformed in some way (probably replaced with underscores) to ensure that the identifier is correct. Alternatively, the identifier could be made not to depend on the name of the actual global at all, e.g. __external_1.

I'm happy to work on a pull request.

@joebandenburg
Copy link
Author

Note that there is a workaround. Specify an id for the global:

--external '{"lib": {"global": "org.company.lib", "id": "__external_1"}}'

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

No branches or pull requests

1 participant