Skip to content

Commit

Permalink
Fix StatoscopeWebpackPlugin import to support default export (#357)
Browse files Browse the repository at this point in the history
The import of StatoscopeWebpackPlugin was adjusted to use the default export, which is necessary when the module exports a single class or function as the default. This change ensures that the plugin is correctly instantiated whether the `why` flag is used or not, and it resolves issues that may arise if the module is not exporting an object with named exports. The `new StatoscopeWebpackPlugin` calls have been replaced with `new StatoscopeWebpackPlugin.default` to reflect this change.

Co-authored-by: hoo00nn <[email protected]>
  • Loading branch information
hoo00nn and hoo00nn authored Mar 12, 2024
1 parent 450ae46 commit cb1844f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/webpack-why/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function addStatoscope(limitConfig, check, webpackConfig) {
let shouldOpen = process.env.NODE_ENV !== 'test' && !limitConfig.saveBundle

webpackConfig.plugins.push(
new StatoscopeWebpackPlugin({
new StatoscopeWebpackPlugin.default({

Check failure on line 9 in packages/webpack-why/index.js

View workflow job for this annotation

GitHub Actions / Node.js Latest Full

packages/webpack-why/test/index.test.js > supports --why

TypeError: default.default is not a constructor ❯ addStatoscope packages/webpack-why/index.js:9:7 ❯ Object.modifyWebpackConfig packages/webpack-why/index.js:43:9 ❯ Object.step20 packages/webpack/index.js:97:39 ❯ packages/webpack-why/test/index.test.js:48:5

Check failure on line 9 in packages/webpack-why/index.js

View workflow job for this annotation

GitHub Actions / Node.js Latest Full

packages/webpack-why/test/index.test.js > applies both `modifyWebpackConfig`

TypeError: default.default is not a constructor ❯ addStatoscope packages/webpack-why/index.js:9:7 ❯ Object.modifyWebpackConfig packages/webpack-why/index.js:43:9 ❯ Object.step20 packages/webpack/index.js:97:39 ❯ packages/webpack-why/test/index.test.js:81:5

Check failure on line 9 in packages/webpack-why/index.js

View workflow job for this annotation

GitHub Actions / Node.js 20 Quick

packages/webpack-why/test/index.test.js > supports --why

TypeError: default.default is not a constructor ❯ addStatoscope packages/webpack-why/index.js:9:7 ❯ Object.modifyWebpackConfig packages/webpack-why/index.js:43:9 ❯ Object.step20 packages/webpack/index.js:97:39 ❯ packages/webpack-why/test/index.test.js:48:5

Check failure on line 9 in packages/webpack-why/index.js

View workflow job for this annotation

GitHub Actions / Node.js 20 Quick

packages/webpack-why/test/index.test.js > applies both `modifyWebpackConfig`

TypeError: default.default is not a constructor ❯ addStatoscope packages/webpack-why/index.js:9:7 ❯ Object.modifyWebpackConfig packages/webpack-why/index.js:43:9 ❯ Object.step20 packages/webpack/index.js:97:39 ❯ packages/webpack-why/test/index.test.js:81:5

Check failure on line 9 in packages/webpack-why/index.js

View workflow job for this annotation

GitHub Actions / Node.js 18 Quick

packages/webpack-why/test/index.test.js > supports --why

TypeError: default.default is not a constructor ❯ addStatoscope packages/webpack-why/index.js:9:7 ❯ Object.modifyWebpackConfig packages/webpack-why/index.js:43:9 ❯ Object.step20 packages/webpack/index.js:97:39 ❯ packages/webpack-why/test/index.test.js:48:5

Check failure on line 9 in packages/webpack-why/index.js

View workflow job for this annotation

GitHub Actions / Node.js 18 Quick

packages/webpack-why/test/index.test.js > applies both `modifyWebpackConfig`

TypeError: default.default is not a constructor ❯ addStatoscope packages/webpack-why/index.js:9:7 ❯ Object.modifyWebpackConfig packages/webpack-why/index.js:43:9 ❯ Object.step20 packages/webpack/index.js:97:39 ❯ packages/webpack-why/test/index.test.js:81:5
additionalStats: [limitConfig.compareWith, check.compareWith].filter(
Boolean
),
Expand All @@ -24,7 +24,7 @@ function addStatoscope(limitConfig, check, webpackConfig) {
)
} else if (limitConfig.saveBundle) {
webpackConfig.plugins.push(
new StatoscopeWebpackPlugin({
new StatoscopeWebpackPlugin.default({

Check failure on line 27 in packages/webpack-why/index.js

View workflow job for this annotation

GitHub Actions / Node.js Latest Full

packages/webpack-why/test/index.test.js > supports --save-bundle

TypeError: default.default is not a constructor ❯ addStatoscope packages/webpack-why/index.js:27:7 ❯ Object.modifyWebpackConfig packages/webpack-why/index.js:43:9 ❯ Object.step20 packages/webpack/index.js:97:39 ❯ run packages/webpack-why/test/index.test.js:24:5 ❯ packages/webpack-why/test/index.test.js:96:3

Check failure on line 27 in packages/webpack-why/index.js

View workflow job for this annotation

GitHub Actions / Node.js 20 Quick

packages/webpack-why/test/index.test.js > supports --save-bundle

TypeError: default.default is not a constructor ❯ addStatoscope packages/webpack-why/index.js:27:7 ❯ Object.modifyWebpackConfig packages/webpack-why/index.js:43:9 ❯ Object.step20 packages/webpack/index.js:97:39 ❯ run packages/webpack-why/test/index.test.js:24:5 ❯ packages/webpack-why/test/index.test.js:96:3

Check failure on line 27 in packages/webpack-why/index.js

View workflow job for this annotation

GitHub Actions / Node.js 18 Quick

packages/webpack-why/test/index.test.js > supports --save-bundle

TypeError: default.default is not a constructor ❯ addStatoscope packages/webpack-why/index.js:27:7 ❯ Object.modifyWebpackConfig packages/webpack-why/index.js:43:9 ❯ Object.step20 packages/webpack/index.js:97:39 ❯ run packages/webpack-why/test/index.test.js:24:5 ❯ packages/webpack-why/test/index.test.js:96:3
open: false,
saveReportTo: join(limitConfig.saveBundle, 'report.html'),
saveStatsTo: join(limitConfig.saveBundle, 'stats.json'),
Expand Down

0 comments on commit cb1844f

Please sign in to comment.