Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack 的 sideEffects 似乎会始终对 node_modules 里的代码生效,即使是在 dev 模式 #131

Open
lmk123 opened this issue Jan 10, 2024 · 0 comments

Comments

@lmk123
Copy link
Owner

lmk123 commented Jan 10, 2024

我的项目使用了 monorepos 模式,然后今天发现了一个现象。

项目结构大致如下:

root/
   apps/my-app
        index.js
   packages/my-package
        index.js
        package.json

my-package/index.js 代码如下:

console.log('my-package 入口')
export { someFn }

且 my-package/package.json 里加入了 sideEffects: false

my-app/index.js 代码如下:

import { someFn } from '@inner-pkg/my-package'

然后用 Webpack 的 dev 模式打包了 my-app/index.js,结果发现控制台没有 my-package/index.js 里的日志消息。

另外,编辑 package.json 里的 sideEffects 选项后,webpack --watch 并没有重新编译代码,需要完全重启 webpack 才能生效。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant