liady / webpack-node-externals

Easily exclude node modules in Webpack
MIT License
1.3k stars 62 forks source link

Option 'includeAbsolutePaths' can't work well with inline loader #119

Open licg9999 opened 1 year ago

licg9999 commented 1 year ago

Hi, there. I found an interesting case that can be consistently reproduced. If I specify option 'includeAbsolutePaths' and use an inline loader which contains a sub path '/node_modules/', webpack-node-externals would mistakenly externalize the target file that should be imported. For example:

// webpack.config.js
...
  externals: [nodeExternals({ includeAbsolutePaths: true })],
...
// entry file
import { greeting } from '!../node_modules/babel-loader/lib/index.js!./constants';

In this case, the file constants should be imported but in fact it's externalized. I created a repo licg9999/b6881284 so that you can reproduce the abnormally. Would you help fix it? Or do you mind my fixing it? Thanks.