ceisum1.85.0 ERROR in ./node_modules/cesium/Source/ThirdParty/zip.js

目录

问题

Ceisum 升级到1.85.0后运行报错

ERROR in ./node_modules/cesium/Source/ThirdParty/zip.js 1565:71
Module parse failed: Unexpected token (1565:71)
File was processed with these loaders:
 * ./node_modules/strip-pragma-loader/index.js
You may need an additional loader to handle the result of these loaders.
|       if (!workerData.interface) {
|               try {
>                       workerData.worker = new Worker(new URL(workerData.scripts[0], import.meta.url));
|               } catch (error) {
|                       workerData.worker = new Worker(new URL(workerData.scripts[0], import.meta.url), { type: "module" });
 @ ./node_modules/cesium/Source/DataSources/KmlDataSource.js 44:0-39 394:32-35 406:32-35 3168:19-22 3168:37-40
 @ ./node_modules/cesium/Source/Widgets/Viewer/viewerDragDropMixin.js
 @ ./node_modules/cesium/Source/Cesium.js
 @ ./src/plugins/cesium.ts
 @ ./src/store/storeCesium.ts
 @ ./src/store/store.ts
 @ ./src/main.ts

解决方案

wenpack增加loader

{
        test: /.js$/,
        include: path.resolve(__dirname, 'node_modules/cesium/Source'),
        use: { loader: require.resolve('@open-wc/webpack-import-meta-loader') }
}

vue项目如果不加include配置,运行没问题,但是打包会报错.原因是有些包是不能用这种loader方式。

Syntax Error: Thread Loader (Worker 4)
Cannot read property 'length' of undefined
退出移动版