When I use parcel to bundle my project with react-model, It works on CodeSandBox, but crash on local (I test on my Linux node v8.x and macOS node v10.x)
package.json
{
"name": "parcel-react-model-template",
"version": "1.0.0",
"description": "",
"main": "index.html",
"scripts": {
"start": "parcel index.html --open",
"build": "parcel build index.html"
},
"dependencies": {
"react": "16.8.0-alpha.1",
"react-dom": "16.8.0-alpha.1",
"react-model": "2.0.11",
"typescript": "3.2.4"
},
"devDependencies": {
"@types/react": "16.7.20",
"@types/react-dom": "16.0.11",
"parcel-bundler": "^1.6.1"
},
"keywords": []
}
npm start with no import error
Uncaught TypeError: react_model_1.Model is not a function
at Object.parcelRequire.model/index.ts.react-model
ES6/esnext module support
Now I remove the module field in [email protected] package.json to solve the issue.
node_modules/react-model/package.json
// ...
"license": "MIT",
"main": "./dist/react-model.js",
"module": "./dist/react-model",
"name": "react-model",
// ...
When I Change it to
"license": "MIT",
"main": "./dist/react-model.js",
"module": "./dist/react-model.js",
"name": "react-model",
Parcel can work well, But the file ./dist/react-model is a valid ES module under webpack. And this solution will be broken under webpack. What's wrong, What should I do ?
| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | v1.6.1 / v1.11.0 |
| Node | v8.x / v10.x |
| npm/Yarn | -- |
| Operating System | Linux / macOS |
Maybe smth wrong with react-module?
I can't reproduce this (anymore). react-model doesn't (and didn't? https://unpkg.com/[email protected]/package.json) have a module property in it's package.json.
Adding the line seems to make no difference. Are you still having issues?
I can't reproduce this (anymore). react-model doesn't (and didn't? https://unpkg.com/[email protected]/package.json) have a module property in it's package.json.
Adding the line seems to make no difference. Are you still having issues?
I remove the module field in [email protected] so you can't reproduce it.
You can reproduce this in [email protected]
the same as package.json above.
project's package.json
{
"name": "parcel-react-model-template",
"version": "1.0.0",
"description": "",
"main": "index.html",
"scripts": {
"start": "parcel index.html --open",
"build": "parcel build index.html"
},
"dependencies": {
"react": "16.8.0-alpha.1",
"react-dom": "16.8.0-alpha.1",
"react-model": "2.0.11",
"typescript": "3.2.4"
},
"devDependencies": {
"@types/react": "16.7.20",
"@types/react-dom": "16.0.11",
"parcel-bundler": "^1.6.1"
},
"keywords": []
}
react-model's package.json
// ...
"license": "MIT",
"main": "./dist/react-model.js",
"module": "./dist/react-model",
"name": "react-model",
// ...
@ArrayZoneYour You can't have a javascript file without a file extension. Renaming dist/react-model to react-model.esm.js (and changing package.json) fixes it.