rrdelaney / reason-scripts

:beginner: Create a ReasonML and React development environment
MIT License
628 stars 58 forks source link

webpack uses ES6 and not umd/commonJS #69

Closed Gregoirevda closed 6 years ago

Gregoirevda commented 6 years ago

We use a npm package as a dependency which has 3 entry points: https://github.com/apollographql/graphql-tag/blob/master/package.json#L5 main, module and jsnext:main for some reason, it is using the ES6 module or jsnext:main entry point, which uses a undefined require import statement.

Related issue: https://github.com/apollographql/reason-apollo/issues/95

rrdelaney commented 6 years ago

Our webpack config is based off of react-script's, and we're not likely to deviate from that.

Is there a reason you need all 3 entry points?

Gregoirevda commented 6 years ago

The 3 entry points are defined in the package.json of a dependency. Can you confirm me it'll pick the jsnext:main as the entry point?

rrdelaney commented 6 years ago

I’m not really sure about the resolution between the three. I recommend playing around with CRA main if you’re unsure. We use the same dependency resultion and webpack config, except we add bs-loader.

br1anchen commented 6 years ago

@Gregoirevda @rrdelaney I believe it is similar issue related to this, I changed resolve extension order in webpack.config.dev.js from:

    extensions: ['.re', '.ml', '.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx'],

to

    extensions: ['.re', '.ml', '.web.js', '.js', '.mjs', '.json', '.web.jsx', '.jsx'],

then it compiled with reason-apollo. Currently reason-scripts is using "webpack": "3.8.1",, I think it does not probably support EcmaScript modules yet. @rrdelaney is it straight forward to upgrade webpack to v4 to sync with current react-scripts dependencies in this case?

Gregoirevda commented 6 years ago

Tried making a new project pointing on fixed react-scripts 1.1.2, but still have this issue. Is this project using the latest webpack release? https://github.com/graphql/graphql-js/issues/1248#issuecomment-382539073

rrdelaney commented 6 years ago

reason-scripts isn't going to be updated, or really support much anymore. I recommend using Parcel with BSB.

Closing this because this won't be updated.

Anahkiasen commented 5 years ago

@rrdelaney You should add a warning about this in the main README and mark this package as deprecated in the meantime if it not going to get more updates. I don't think it's clear to a lot of people at the moment that this package is abandoned.

In addition to that I've never managed to make Parcel work on a my ReasonReact codebase, there's always some dependency or compilation error, have you had more success on your end?

rrdelaney commented 5 years ago

@Anahkiasen shoot yea, forgot to do that when I moved it out of reasonml-old