私はSafari拡張機能を構築しようとしています。ブラウザでrequire
またはimport
を使用できないため、WebpackとBabelを設定しようとしています。私は、私が見つけたいくつかの他の例に大きく答えましたが、喜びはありませんでした。どんな助けもありがたい。babelとwebapckで未定義のプロパティ 'ヘルパー'を読み取ることができません
webpack.conf.js
const path = require('path')
module.exports = {
target: 'web',
entry: './src/index.js',
output: {
path: path.resolve(__dirname, "ReduxDevTools.safariextension"),
filename: 'index.js'
},
module: {
rules: [
{
test: /src\/.+\.js$/,
exclude: /(node_modules|ReduxDevTools\.safariextension)/,
use: {
loader: 'babel-loader',
options: {
"presets": [
["@babel/preset-env", {
"targets": {
"safari": 10
}
}],
"@babel/preset-stage-0"
],
"plugins": [
["@babel/plugin-transform-runtime", {
"helpers": false,
"polyfill": false,
"regenerator": true,
"moduleName": "@babel/runtime"
}]
]
}
}
}
]
}
}
package.json
"scripts": {
"build": "./node_modules/.bin/webpack",
"dev": "nodemon --watch ./src --exec yarn run build"
},
ディレクトリ
├── CertificateSigningRequest.certSigningRequest
├── ReduxDevTools.safariextension
│ ├── AppIcon.appiconset
│ │ ├── Contents.json
│ │ ├── logo-2-1024.png
│ │ ├── logo-2-128.png
│ │ ├── logo-2-16.png
│ │ ├── logo-2-256.png
│ │ ├── logo-2-32.png
│ │ ├── logo-2-512.png
│ │ └── logo-2-64.png
│ ├── Info.plist
│ ├── Settings.plist
│ ├── index.html
│ └── index.js
├── dist
├── package.json
├── src
│ └── index.js
├── webpack.config.js
├── yarn-error.log
└── yarn.lock
エラー
[nodemon] starting `yarn run build`
warning ../package.json: No license field
$ ./node_modules/.bin/webpack
Hash: e42a920b430f30cdd9f4
Version: webpack 3.10.0
Time: 1637ms
Asset Size Chunks Chunk Names
index.js 4.08 kB 0 [emitted] main
[0] ./src/index.js 1.61 kB {0} [built] [failed] [1 error]
ERROR in ./src/index.js
Module build failed: TypeError: Cannot read property 'helpers' of undefined
at _default (/Users/noah/Projects/ReduxDevtoolsExtension/node_modules/@babel/plugin-transform-runtime/lib/index.js:17:25)
at Function.memoisePluginContainer (/Users/noah/Projects/node_modules/babel-core/lib/transformation/file/options/option-manager.js:113:13)
at Function.normalisePlugin (/Users/noah/Projects/node_modules/babel-core/lib/transformation/file/options/option-manager.js:146:32)
at /Users/noah/Projects/node_modules/babel-core/lib/transformation/file/options/option-manager.js:184:30
at Array.map (<anonymous>)
at Function.normalisePlugins (/Users/noah/Projects/node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)
at OptionManager.mergeOptions (/Users/noah/Projects/node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)
at OptionManager.init (/Users/noah/Projects/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
at File.initOptions (/Users/noah/Projects/node_modules/babel-core/lib/transformation/file/index.js:212:65)
at new File (/Users/noah/Projects/node_modules/babel-core/lib/transformation/file/index.js:135:24)
at Pipeline.transform (/Users/noah/Projects/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
at transpile (/Users/noah/Projects/ReduxDevtoolsExtension/node_modules/babel-loader/lib/index.js:50:20)
at Object.module.exports (/Users/noah/Projects/ReduxDevtoolsExtension/node_modules/babel-loader/lib/index.js:175:20)
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[nodemon] app crashed - waiting for file changes before starting...
同じ問題が発生しました:( – Fezzy
と同じですが、私の答えはありません。 – Sabrina