Структура моих папок выглядит следующим образом:
/testproject
/local-package
package.json
/src
package.json
/ testproject / package.json
"dependencies": {
"local-package": "file:./local-package",
/ testproject / webpack.config.js
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules(?!\/local-package)/,
use: ["babel-loader"]
}
]
},
Когда я бегу webpack --mode production
Я получаю ошибку
ERROR in ./local-package/components/NotFound.jsx
Module build failed: SyntaxError: /Users/pavel/Projects/JS/testproject/local-package/components/NotFound.jsx: Unexpected token (4:2)
2 |
3 | const NotFound = () => (
> 4 | <div>
| ^
5 | <h3>404 page not found</h3>
6 | <p>We are sorry but the page you are looking for does not exist.</p>
7 | </div>
https://gist.github.com/perevezencev/2c985c5a4f2c2ab9a89b9afd2989d409 Действия для воспроизведения:
- клон репо
git clone https://github.com/perevezencev/webpack-error.git
- бег
yarn link
внутри /webpack-error/local-package
- бег
yarn link "local-package"
внутри /webpack-error
- бег
yarn
внутри /webpack-error
- пробег
yarn build
внутри /webpack-error