-
Notifications
You must be signed in to change notification settings - Fork 241
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
unexpected token export #244
Comments
Here is my setup:
there is no error if I use babel in webpack:
|
In my setup I don't use webpack but gulp for generating production version. For developing I use systemjs and there is no prolbem with newest version of angular2-modal. But when I try to create a bundle with gulp browserity, I got that Import Export error:
I tried also inspirate with fix babel i webpack similar solution in gulp: But that does not help. |
My setup is with WebPack 1 and configured exactly like this - https://angular.io/docs/ts/latest/guide/webpack.html All my modals are custom modal dialogs using the bootstrap plugin as per the example found here - http://embed.plnkr.co/ZAZqZu/ <-- this example uses systemJS, I'm using Webpack 1 with Babel The error I get is |
The problem is that the entire project is compiled as ES6, which wont work in a lot of browsers. Can anybody re-release in ES5? A lot of browsers don't support all the keywords consistently. |
If you use jspm w/ system.js, you can add the following to your config.js in the |
I moved to webpack and everythings works now great. So for me is this issue resolved. |
Problem returns again when I use webpack and Angular universal. It's because server it's compiled as node with angular2 ts files, so when I include: import { Modal, BSModalContext } from 'angular2-modal/plugins/bootstrap'; I got error during starting server (compilation is okay): `.../node_modules/angular2-modal/plugins/bootstrap/index.js:7 SyntaxError: Unexpected reserved word It's because export it's not allowed word (reserved) word for node. But I think in this case is nessesary to make some conditions with isNode or isBrowser with angular2 universal to prevent node process this actions which generates those errors.. |
@jvanharn The project is not compiled in ES6, it is compiled in ESM which is ES5 + module syntax. ESM is how angular is distributed, the core If you want a 100% ES5 syntax use the UMD bundles, they should load automatically if your'e not use a module bundler. If you do then ESM shouldn't be an issue. Now, from some digging, experimenting and the reports above the problem is caused by the combination of 2 factors:
Of course using a plugin is a must :) Webpack 1 does not know how to handle ESM, it uses the UMD bundles supplied in the package.
Notice we are not importing the core (angular2-modal) but an inner path. Hooray, a solution:To solve this issue I need to place a dummy I will post a solution in several hours with dummy package files. |
2.02 is out, should fix it |
2.0.2 solves the problem I was having - thanks! |
This issue consolidates #220 #236 #241
First some background:
The library is published with 2 versions ESM & UMD.
The UMD version (1 file, ES5) is kicked of by default.
The ESM version is used by bundlers (e.g webpack), they auto detect it and use ESM.
ESM is actually ES5 + module syntax, that is import / export statements.
It is clear that the issue is caused when ESM is used.
It's also worth noting the angular is packages the same way (expect plugins, see below)
Test repo
I have prepared a sample project in this repository
It is based on this starter https://github.com/qdouble/angular-webpack2-starter
The setup uses webpack 2 and angular 2.1.0
It allows to test JIT and AOT.
I did not get the unexpected token export with this setup.
The setup does not use babel loader.
To identify the issue I will need your help.
I have 2 suspects for now:
Plugins for the library (bootstrap, vex etc...) are published within the package, they don't come in a separate package. It might be the issue in some setups.
Please help me with details about your setup so I can find the problem.
The text was updated successfully, but these errors were encountered: