You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ES modules: "main" and "module" in "package.json" #199
I recently stumbled across this when importing an internal helper function from AngularFire2. What I found is documented here. (Hopefully, for the benefit of others.)
The latest Angular and AngularFire2 releases use the package.json file's main to refer to a UMD bundle and its module to refer to an ES module (with ES2015 content). It's mentioned in this comment.
So an import like this:
import { AngularFire } from "angularfire2";
will result in the UMD bundle will being added to the Browserify bundle, but an import like this:
import { unwrapMapFn } from "angularfire2/utils";
will result in an ES module being added, with the following error being effected:
ParseError: 'import' and 'export' may appear only with 'sourceType: module'
Typically, this won't be a problem - as it only occurs when using deep-path imports. However, if RxJS goes this route and uses main and module in its package.json, it will be more distruptive, as it's pretty common to have imports like this:
TS seems to handle both the same way, although the main/node build pretty much resembles the module build (with some added code and slight tweaks, although that may differ more depending on your TS configuration).
Activity
Berkmann18 commentedon Apr 24, 2020
TS seems to handle both the same way, although the
main/nodebuild pretty much resembles themodulebuild (with some added code and slight tweaks, although that may differ more depending on your TS configuration).