Bug report
I have a library that has 26k npm downloads, it exports a function, and users use it with npm install and then import commonjs2 file with:
import Painterro from 'painterro';
Painterro(params)
Once I updated webpack I noted that Painterro is not function but object. So basic destruction works fine:
import { Painterro } from 'painterro';
Though named import is not so bad, I can imagine that my users will receive a lot of pain if I break backward compatibility even despite on minor number change. I was searching for the changes in the documentation but found nothing.
I prepared a super-minimal example to show the issue.
What is the current behavior?
If the current behavior is a bug, please provide the steps to reproduce.
- Create file
main.js:
module.exports = () => 1234;
- Create file
package.json:
{
"name": "p2",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack --progress"
},
"author": "",
"license": "ISC",
"devDependencies": {
"webpack": "^5.21.2",
"webpack-cli": "^4.5.0"
}
}
- Create file
webpack.config.js:
'use strict';
const path = require('path');
module.exports = {
mode: 'development',
entry: './main.js',
output: {
path: path.resolve(__dirname, 'build'),
filename: 'p2.commonjs2.js',
library: 'P2',
libraryTarget: 'commonjs2',
},
}
- Also, create a simple
test.js:
const p2 = require('./build/p2.commonjs2.js');
console.log(p2)
now do:
npm run build
- And
node test.js. I see:
What is the expected behavior?
- Next I do:
npm i [email protected] -D
npm run build
node test.js. I see:
Other relevant information:
webpack version: 5.21.2
Node.js version: v12.20.1
Operating System: Windows WSL 2
Additional tools: npm 7.5.4,
Bug report
I have a library that has 26k npm downloads, it exports a function, and users use it with npm install and then import commonjs2 file with:
Once I updated webpack I noted that
Painterrois not function but object. So basic destruction works fine:Though named import is not so bad, I can imagine that my users will receive a lot of pain if I break backward compatibility even despite on minor number change. I was searching for the changes in the documentation but found nothing.
I prepared a super-minimal example to show the issue.
What is the current behavior?
If the current behavior is a bug, please provide the steps to reproduce.
main.js:package.json:webpack.config.js:test.js:now do:
npm run buildnode test.js. I see:What is the expected behavior?
npm i [email protected] -Dnpm run buildnode test.js. I see:Other relevant information:
webpack version: 5.21.2
Node.js version: v12.20.1
Operating System: Windows WSL 2
Additional tools: npm 7.5.4,