Skip to content
This repository was archived by the owner on Oct 9, 2020. It is now read-only.

__moduleName to be handled generically for System.register #416

Closed
guybedford opened this issue Nov 30, 2015 · 3 comments
Closed

__moduleName to be handled generically for System.register #416

guybedford opened this issue Nov 30, 2015 · 3 comments

Comments

@guybedford
Copy link
Member

The System.register format should come with a default handling of __moduleName that doesn't involve inlining the string twice in the bundle.

@douglasduteil
Copy link

👍 I actually have an issue with a missing __moduleName when bundling the jspm-loader-css.

@guybedford
Copy link
Member Author

Here's a strategy for __moduleName treatment going forward:

  • Add __moduleName as the second argument to the declaration function in System.register(name, deps, function declare(_export, __moduleName) { ... })
  • The reason this was avoided before was to allow context to become the second argument, but instead context can be implemented by being the this value of the declare callback function (which doesn't rely in any way on being the global value), or even potentially the third argument anyway. System.register will likely end up renamed to System.loader.register or SystemJS.register possibly allowing for some breaking behaviours too, so we do have flexibility here.
  • Transpilers targeting System.register should now implement __moduleName as the second argument into declare. This can then be removed when not needed by minficiation / dead code analysis.
  • While transpilers do not yet support this, we will continue to provide the __moduleName runtime wrapping in SystemJS, and in the builder project System.register modules will be automatically transformed to add this argument.
  • Eventually the wrappers and automatic conversion can be deprecated when transpiler implementations are used widely enough.

@guybedford
Copy link
Member Author

Released in 0.14.12.

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

No branches or pull requests

2 participants