我试图用电子的WebPack建立与电子应用atlaskit 。
我设置尽可能小的回购重现该问题: fstephany /错误报告-电子的WebPack 。
这里是我的package.json :
{
"name": "electron-webpack-quick-start",
"version": "0.0.0",
"license": "MIT",
"esm": "auto",
"scripts": {
"dev": "electron-webpack dev",
"compile": "electron-webpack",
"dist": "yarn compile && electron-builder",
},
"dependencies": {
"source-map-support": "^0.5.12",
"esm": "^3.2.25",
"@atlaskit/navigation-next": "6.3.0"
},
"devDependencies": {
"electron": "5.0.4",
"electron-builder": "^20.44.4",
"electron-webpack": "^2.7.1",
"webpack": "~4.35.0"
}
}
而我src/renderer/index.js
简单地加载外部依赖:
import { LayoutManager } from "@atlaskit/navigation-next";
let app = document.getElementById("app");
let layoutManager = LayoutManager;
console.log(app);
console.log(layoutManager);
当我运行应用程序$ yarn dev
。 我得到了来自电子窗口Web控制台的错误:
Uncaught /home/fstephany/Code/Play/new-electron-webpack-project/node_modules/@atlaskit/navigation-next/index.js:2
export { default as ContainerHeader } from './components/presentational/ContainerHeader';
^^^^^^
SyntaxError: Unexpected token export
at new Script (vm.js:85:7)
at createScript (vm.js:266:10)
at Object.runInThisContext (vm.js:314:10)
at Module._compile (internal/modules/cjs/loader.js:742:26)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:820:10)
at Module.load (internal/modules/cjs/loader.js:677:32)
at tryModuleLoad (internal/modules/cjs/loader.js:609:12)
at Function.Module._load (internal/modules/cjs/loader.js:601:3)
at Module.require (internal/modules/cjs/loader.js:715:19)
at require (internal/modules/cjs/helpers.js:14:16)
SyntaxError: Unexpected token export
让我觉得有些事情是从巴贝尔transpiling失踪。 特别是当发行说明中的@ atlaskit /导航下一个版本5.0.0明确提到:
从所有的流模块拖放ES5
在所有@atlaskit包丢弃CJS支持
作为一个重大更改,所有@atlaskit包将被丢弃CJS分布,只会散发ESM。 这意味着所有分布式代码将被transpiled,但仍将包含进出口报关。
关于如何解决此问题的任何想法? 我已经尝试了不同的巴贝尔的配置,但我觉得在圆周转弯......