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

issue with import cesium and webpack #21

Open
ababakanian opened this issue May 11, 2020 · 3 comments
Open

issue with import cesium and webpack #21

ababakanian opened this issue May 11, 2020 · 3 comments

Comments

@ababakanian
Copy link

ababakanian commented May 11, 2020

I am encountering two issues with the create-react-app v 3.4.1 and craco-cesium v 1.2.0.
I created a simple application using create-react-app and install @craco, craco-cesium and cesium. See project package.json file

{
  "name": "desktopapp",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@craco/craco": "^5.6.4",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "cesium": "^1.69.0",
    "craco-cesium": "^1.2.0",
    "lodash": "^4.17.15",
    "prop-types": "^15.7.2",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-router-dom": "^5.2.0",
    "react-scripts": "3.4.1"
  },
  "scripts": {
    "start": "craco start",
    "build": "craco build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

in the view, I have the following Cesium import line which returns undefined:

import Cesium from 'cesium';
console.log(Cesium);

after deleting the node_modules and package-lock.json files and running npm install the depencencies are installed again, though starting the app npm run start showing the following error:

$ npm run start

> desktopapp@0.1.0 start /home/ababakanian/SNT/scenario_analyzer/desktopapp
> craco start


There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.

The react-scripts package provided by Create React App requires a dependency:

  "webpack": "4.42.0"

Don't try to install it manually: your package manager does it automatically.
However, a different version of webpack was detected higher up in the tree:

  /home/ababakanian/SNT/scenario_analyzer/desktopapp/node_modules/webpack (version: 4.43.0) 

listing the webpack versions. this is what I see:

$ npm ls webpack
desktopapp@0.1.0 /home/ababakanian/SNT/scenario_analyzer/desktopapp
├─┬ craco-cesium@1.2.0
│ └── UNMET PEER DEPENDENCY webpack@4.43.0 
└─┬ react-scripts@3.4.1
  └── webpack@4.42.0 

npm ERR! peer dep missing: webpack@^2.0.0, required by strip-pragma-loader@1.0.0

the associated react-scripts uses webpack v 4.43.0 see https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/package.json#L81
though craco-cesium uses 4.42.1, see https://github.com/darwin-education/craco-cesium/blob/master/package.json#L15
is this the cause of the issue?

@ovielma
Copy link

ovielma commented Jul 7, 2020

Any update on this? I'm having the same issue and getting the same errors.

@ababakanian
Copy link
Author

I think the issue is not Craco related, the newer version of Cesium doesn't export default cesium, so you have to use individual imports

@TJKoury
Copy link

TJKoury commented Oct 6, 2020

We created a single-file distro, c137.js, that might help with this issue. Example config files for different bundler or import configs are here.

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