localForageをwebpackで読み込む
Created at
Updated at
概要
webpackで運用しているプロジェクトでlocalForageを使おうとしたらエラーが出たのでメモ。
エラー
./node_modules/localforage/dist/localforage.js
Module build failed: ReferenceError: Unknown plugin "add-module-exports" specified in "/app/node_modules/localforage/.babelrc" at 0, attempted to resolve relative to "/app/node_modules/localforage"
localforageに既に上がっているIssue(#599)とは別物。
対処
Babelが原因のエラーのようなので、
webpack.config.js
のbabel-loader
に読み込ませないようにする。
// webpack.config.js
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader?presets=es2015',
exclude: /localforage/,
},
],
},
参考
https://stackoverflow.com/questions/45244723/how-to-use-noparse-in-webpack