Building a Cesium Bundle using DllPlugin
Hi Mark,
Thank you for your demo!
In part one, I'm getting tripped up on the section around "Commit b55dbd5: Add scripts to build a Cesium bundle with DllPlugin."
I've been following along with every step of this demo, including grabbing the scripts from Github that you skip looking at in the demo, in re Commit b55dbd5.
When I run node ./scripts/buildCesiumDLL.js, I don't get any asset list, and the whole process goes by in a matter of milliseconds. Which gives me the impression that something meaningful is happening when you run this build that isn't translating to when I run it.
Accordingly, there is no $PROJECT/distdll folder created, and so running node scripts/build.js throws an error because there isn't any distdll/cesiumDLL-manifest.json file. I'm assuming the creation of this file is something that buildCesiumDLL is supposed to automate?
That said, even with deleting the cesium folder from the public directory, npm start still runs the app. While there isn't a $PROJECT/distdll folder, there's a $PROJECT/build one that includes the cesium folder that had previously been living in public.
Any idea what's going on here? And how I can actually compress the cesium bundle (as far as I know it's still 40-some-odd kilobytes)?
Thanks, Ben
Hmm. This sounds odd at a couple levels.
If you look at the commit logs, b55dbd5 adds the scripts to create the Cesium DLL bundle, but doesn't actually modify the app build process to make use of that bundle. Commit 6db616f then actually modifies the app build config to reference the DLL bundle.
In theory, checking out b55dbd5 and running npm run build:dll:cesium should result in a distdll folder being created, with (I think) two files: cesiumDll.js (which should be about 2MB, minified), and cesiumDll-manifest.json. On my box, that step takes about 35 seconds to execute. I do have Webpack's logging configured to turn off much of the noise, but it should display the names and sizes of those two files when it's done.
If you've only got b55dbd5 checked out, then I would expect that running npm run build would succeed, because it shouldn't yet be trying to make use of the DLL bundle.
Out of curiosity, if you check out 67e831e , do the Cesium bundle and overall build steps work there?
It's certainly possible I missed something when assembling these commits. I don't have time at the moment to look into this myself, but please let me know what happens.
Thanks so much!
In checking out 67e831e, I noticed two small discrepancies:
- My
config/paths.jsfor some reason did not include the "ownNodeModules" line - Silly mistake - I never exported webpackConfig at the end of
config/webpack.cesium.dll.config.js! (This last line had been cut off in the image of this file that is featured in your blog post for the demo.)
After adding those two lines, both npm run build:dll:cesium and node scripts/build.js worked as expected.
Does this mean I can get rid of that $PROJECT/build folder now?
Thanks again!!
The build folder should be created every time you run CRA's npm run build command, and will include all the normal JS app bundle output. The changes in 902ba044 should update things so that the build output also includes the Cesium DLL bundle and the rest of the needed Cesium folder contents.
Looking at the blog post... yeah, my bundle config snippet does leave out the export line. (It's an actual syntax-highlighted snippet, not an image.) Thanks for pointing that out, I'll fix it when I get a chance.
Glad to hear it's working for you! Just out of curiosity, what's your use case and background for learning this? Are you actually planning to use Cesium for something, or just curious about the build process aspect?