这是重新创建问题的地方:
https://github.com/reggi/webpack-lerna-babel-loader-issue
目标:我正在尝试./packages/usage/index.js
使用 webpack 构建。
- 我有 4 个包裹
alpha
,beta
,gamma
,usage
. alpha
,beta
,gamma
没有使用 babel,应该只使用 index.jsusage
正在使用 babel 并且应该使用babel-loader
然后遍历应该继续
当我尝试编译时babel
,奇怪的是请求其他部门。
$ lerna bootstrap
Lerna v2.0.0-beta.20
Linking all dependencies
Successfully bootstrapped 4 packages.
$ cd packages/usage
$ npm run webpack
> @reggi/usage@1.0.0 webpack /Users/thomasreggi/Desktop/webpack-issue/packages/usage
> webpack
Hash: 27e6d9d1d4147417b516
Version: webpack 1.13.1
Time: 429ms
Asset Size Chunks Chunk Names
bundle.js 2.11 kB 0 [emitted] main
+ 3 hidden modules
ERROR in ../alpha/index.js
Module not found: Error: Cannot resolve module 'babel' in /Users/thomasreggi/Desktop/webpack-issue/packages/alpha
@ ../alpha/index.js 1:11-33
{ exclude: /(node_modules|bower_components)/ }
启用后我得到了这个。
$ npm run webpack
> @reggi/usage@1.0.0 webpack /Users/thomasreggi/Desktop/webpack-issue/packages/usage
> webpack
Hash: 99d08ad8b664833bba1c
Version: webpack 1.13.1
Time: 401ms
Asset Size Chunks Chunk Names
bundle.js 2.25 kB 0 [emitted] main
+ 4 hidden modules
ERROR in ../alpha/~/@reggi/beta/index.js
Module not found: Error: Cannot resolve module 'babel' in /Users/thomasreggi/Desktop/webpack-issue/packages/alpha/node_modules/@reggi/beta
@ ../alpha/~/@reggi/beta/index.js 1:17-82
捆绑包的类型
不babel-loader
排除node_modules
找不到模块“@reggi/beta”
与babel-loader
排除node_modules
找不到模块 \"/Users/thomasreggi/Desktop/webpack-issue/packages/beta\"
没有babel-loader
& 将代码切换到require
完美地包括一切。