我有一个简单的基于 Web Worker 的项目,用 编译babel
,我在我的worker.js
importScripts('webGLWorker.js');
importScripts('proxyWorker.js');
而在我的index.js
我有
<script src="webGLClient.js"></script>
<script src="proxyClient.js"></script>
我的babel
配置是(.babelrc
)
{
"presets": [
[
"env",
{
"esmodules": false,
"targets": {
"browsers": [
"> 3%"
]
}
}
]
],
"plugins": [
"transform-runtime"
]
}
importScripts
当我运行时,找不到导入的文件(404),因为babel
基本上忽略了它们,所以我不会在我的dist/
项目文件夹中的其他文件(index.html
.,其他js等)中找到它们。
具体来说,我正在使用parcel
,这是我的有趣部分的package.json
样子:
{
"scripts": {
"watch": "cross-env NODE_ENV=development parcel index.html --no-hmr --open",
"build": "cross-env NODE_ENV=production parcel build index.html --no-minify --public-url ./"
},
"devDependencies": {
"babel-plugin-transform-runtime": "~6.23.0",
"babel-polyfill": "~6.26.0",
"babel-preset-env": "~1.6.1",
"clang-format": "~1.2.2",
"cross-env": "^5.1.6",
"parcel-bundler": "~1.8.1"
}
}