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

esModule option is ignored #775

Closed
nicolashenry opened this issue Feb 21, 2017 · 12 comments
Closed

esModule option is ignored #775

nicolashenry opened this issue Feb 21, 2017 · 12 comments

Comments

@nicolashenry
Copy link

The systemjs esModule option (https://github.com/systemjs/systemjs/blob/master/docs/config-api.md) seems to be ignored with systemjs-builder, is it supposed to only work with systemjs alone ?

@aluanhaddad
Copy link

aluanhaddad commented Feb 23, 2017

Yes it should work with the builder. What does your configuration look like?

@nicolashenry
Copy link
Author

I made a minimal example here : https://github.com/nicolashenry/esmodule-systemjs-builder

"index.html" display "ok" in console
"index-bundled.html" display "enableProdMode is not a function" (the same happen if I remove 'esModule: true' with index.html)

Maybe I'm doing something wrong here.

@aluanhaddad
Copy link

aluanhaddad commented Feb 27, 2017

Unless something has changed, module format meta config should look like this.

meta: {
  '@angular/core/*': {
    format: 'esm'
  }
}

@nicolashenry
Copy link
Author

I don't understand, I use the "esModule" option and not the "format" option.

@nicolashenry
Copy link
Author

My objective is to use a legacy module "bundles/core.umd.js" which use "named imports", "bundles/core.umd.js" is not an ecmascript module.

@wongwill86
Copy link

Is the esModule flag working? React doesn't export __esModule right now and I would like to do import * as React from 'react' but I can't seem to get the correct incantation for this property
Here's a very simple project that imports react and importing redux for comparison.
https://github.com/wongwill86/esmoduleissue

@guybedford
Copy link
Member

@nicolashenry the bundled version still needs the configuration file to set the esModule meta configuration.

@wongwill86
Copy link

wongwill86 commented Mar 10, 2017

Is there somewhere else other than https://github.com/nicolashenry/esmodule-systemjs-builder/blob/master/systemjs.config.js#L26 where the meta should be set?

@nicolashenry
Copy link
Author

@guybedford buildStatic is supposed to "To make a bundle that is independent of the SystemJS loader entirely" so I don't understand why and how I could add the esModule meta configuration if I don't have any systemjs runtime.

@guybedford
Copy link
Member

Ahh, SFX support for the esModule flag is not currently included.

This can be added by enabling an esModule flag input for our build transformers in https://github.com/systemjs/babel-plugin-transform-system-register, https://github.com/systemjs/babel-plugin-transform-cjs-system-wrapper, https://github.com/systemjs/babel-plugin-transform-global-system-wrapper, https://github.com/systemjs/babel-plugin-transform-amd-system-wrapper, which adds a:

System.register([..], function (require, exports, module) {
  // this line is added by the flag:
  Object.defineProperty(exports, '__esModule', {  value: true });
});

If anyone is interested in working on this please let me know, otherwise I will try get to it when I can.

@guybedford
Copy link
Member

I've included the updates here in for the coming release 802ab43.

@guybedford
Copy link
Member

Released in 0.16.5.

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

No branches or pull requests

4 participants