-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
How-to import Cesium on Webpack #8471
Comments
@serut I assume you're referring to https://cesium.com/docs/tutorials/cesium-and-webpack/? Yes, this definitely looks outdated (thanks for opening an issue). We recently migrated to ES6 modules and simplified a lot of things but apparently forgot to update the tutorial. The reference example, https://github.com/AnalyticalGraphicsInc/cesium-webpack-example, was updated so you can check that out the meantime. Honestly, using Cesium with webpack is trivial now, so I guess the question is: Is it still worth having a specific tutorial at all? @OmarShehata I'll leave that question up to you. |
Hmm, I don't think the Cesium configuration for webpack is trivial as you need to add a little bit of specific config to webpack to get it work.
Otherwise I get :
Why don't you get that issue on your example ? And you still need
The rest of the tutorial looks outdated, things work well without them on my project. |
Thanks @serut you're absolutely right, I shouldn't have called it trivial. The critical dependency warning actually happens in the sample project as well, we just don't disabling the warning. (It's actually a false positive and can be safely ignored either way) None of us are big webpack users, so this is certainly an area that can use some TLC, if anyone has any thoughts on how to improve the reference example, we are always happy to take suggestions. The tutorial probably needs a larger overhaul. |
What does TLC means ? https://www.urbandictionary.com/define.php?term=TLC I think you just need to remove everything outdated and that will be good. I will make a PR if I have some spare time |
Sorry, @serut TLC means "tender loving care": https://www.merriam-webster.com/dictionary/tender%20loving%20care |
Allright I get it 😎 |
try vite ,it is much easier and faster |
We currently have cesium working with webpack 4, and we were in the process of upgrading to webpack 5 but ran into issues with cesium. I know there are 2 PRs in the cesium-and-webpack repo waiting review. If those are merged, I assume that would fix the webpack 5 issues? Can we get an update on webpack 5 support? Thanks! |
@goldenram I'm getting issues too with Webpack 5. No, something must be changed on Cesium, then changes on cesium-and-webpack would be mergeable. |
@serut and @goldenram , can you elaborate what your issues are? Is it related to asset import? When you say there are PRs waiting, I assume you're talking about CesiumGS/cesium-webpack-example#25 and CesiumGS/cesium-webpack-example#23. Both of those work a little differently from my current config. One copies Cesium assets (e.g. CSS and worker scripts) into What I did was to set |
@thw0rted I have the following webpack configuration : I had some unstable test issues so I upgraded my stack with Webpack 5 and a new test runner : I end up with the following error when building :
|
OK, that's exactly why I said to set The slightly less short explanation is that Webpack 5 tries to use the "exports": {
"./package.json": "./package.json",
".": {
"require": "./index.cjs",
"import": "./Source/Cesium.js"
}
}, If you don't disable the default Before I forget, there's actually a second related problem. You may also have to add rules: [{
test: /\.js$/,
resolve: {
fullySpecified: false,
},
}, ... because sometimes |
...or you can just forget all that mess and use c137.js! |
I don't know the right value for the package.json, but definitly Cesium is not buildable with Webpack 5 as it does not follow new standards. I'm trying to keep the type of build I have (it looks like it removes dead code on prod, fast build on dev...). My build is working on Jenkins now I've added :
It changes the content from :
I also removed @thw0rted I did not changed |
@serut Well it’s available for free whenever you want it. Maybe Cesium will partner with us soon so we can open up the build process. |
That makes sense. Your fix is another good solution, though in my case it's a bit of a pain to modify the installed library like that. I'm hoping that Cesium is willing to re-open the issue and take a PR fixing package.json for everybody. |
Hi all, we've recently made some updates to CesiumJS's I think those all address each of the concerns in this issue, so I'll close it. Thanks! |
I'm trying to install Cesium on Webpack, and the current tutorial looks outdated.
If I do what is inside your tutorial, i get :
Which makes this error :
I can fix it by importing everything like that :
Or even better (may use Webpack dead code optimizer) :
The text was updated successfully, but these errors were encountered: