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

mjs couse trouble in create-react-app #2

Open
linonetwo opened this issue Dec 6, 2017 · 9 comments
Open

mjs couse trouble in create-react-app #2

linonetwo opened this issue Dec 6, 2017 · 9 comments

Comments

@linonetwo
Copy link

It throws Unhandled Rejection (TypeError): __WEBPACK_IMPORTED_MODULE_1_collisions___default.a is not a constructor

If I import Collisions, { Circle, Polygon } from 'collisions';

And console.log(Collisions) gives /static/media/Collisions.c776ea0e.mjs

@linonetwo
Copy link
Author

Ok it's caused by facebook/create-react-app#3520

@linonetwo
Copy link
Author

create-react-app Failed to compile.

@linonetwo linonetwo reopened this Dec 15, 2017
@GrosSacASac
Copy link
Contributor

from the readme:
import {Collisions, Circle, Polygon, Point} from 'collisions';

@linonetwo
Copy link
Author

@GrosSacASac Sure I did that, and able to run it on yarn start, but failed on yarn build saying Collisions is not a constructor

@ShimShamSam
Copy link
Contributor

ShimShamSam commented Dec 15, 2017

Is there way I can view your project? This honestly looks specific to create-react-app, but I'm willing to dig deeper if I can reproduce it on my machine.

Also, it looks like the ticket you linked for create-react-app has been merged. Have you updated it to see if it fixes your issue?

@linonetwo
Copy link
Author

linonetwo commented Dec 16, 2017

Collisions is not a constructor occurred when I don't apply what https://github.com/facebookincubator/create-react-app/pull/3537/files said.

But when I did what https://github.com/facebookincubator/create-react-app/pull/3537/files said, building it will result in:

yarn build
yarn run v1.3.2
$ node scripts/build.js
Creating an optimized production build...
Failed to compile.

Failed to minify the code from this file:

        ./node_modules/collisions/src/Collisions.mjs:12

Read more here: http://bit.ly/2tRViJ9

error Command failed with exit code 1.

I think just like what http://bit.ly/2tRViJ9 said, at this early point, package publish to npm probably should still be ES5 ...

Though I don't quite understand why .mjs file can't be minified.

@GrosSacASac
Copy link
Contributor

GrosSacASac commented Dec 16, 2017

to minify ES6+ file use uglifyjs harmony branch https://github.com/mishoo/UglifyJS2/tree/harmony

@GrosSacASac

This comment has been minimized.

@GrosSacASac

This comment has been minimized.

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

3 participants