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

Fix StatoscopeWebpackPlugin import to support default export #357

Merged
merged 1 commit into from
Mar 12, 2024

Conversation

hoo00nn
Copy link
Contributor

@hoo00nn hoo00nn commented Mar 12, 2024

  • Fixes the TypeError: StatoscopeWebpackPlugin is not a constructor error.

An error TypeError: StatoscopeWebpackPlugin is not a constructor occurs if the module does not export as default.

@ai Hello, I wanted to bring to your attention an issue I've found while utilizing the @size-limit/webpack-why package. Since I got an error message (StatoscopeWebpackPlugin is not a constructor), I have consulted with the official documentation. They advised that the class should be imported using the default export.

I have submitted a PR addressing this matter and would greatly appreciate it if you could take a moment to review the proposed changes. Your feedback would be invaluable.

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.
@ai ai merged commit cb1844f into ai:main Mar 12, 2024
@ai
Copy link
Owner

ai commented Mar 12, 2024

Strange that we do not catch it with tests

@ai
Copy link
Owner

ai commented Mar 12, 2024

Now we have a broken CI since we tested it
https://github.com/ai/size-limit/actions/runs/8250644947/job/22565763246

Something strange happens. Can you investigate and send another PR (I will revert this one)?

ai added a commit that referenced this pull request Mar 12, 2024
@hoo00nn
Copy link
Contributor Author

hoo00nn commented Mar 12, 2024

Now we have a broken CI since we tested it
https://github.com/ai/size-limit/actions/runs/8250644947/job/22565763246
Something strange happens. Can you investigate and send another PR (I will revert this one)?

@ai Yes, I'll check.

@hoo00nn
Copy link
Contributor Author

hoo00nn commented Mar 12, 2024

@ai, Hello

After further investigation, I was unable to pinpoint the exact cause of the issue. However, I've observed that depending on the project, the module in question may operate in either ES or CommonJS mode. To prevent any issues between the two module systems, I've made the necessary code fix and submitted the PR. I would appreciate your feedback on this.

all tests are passing.

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

Successfully merging this pull request may close these issues.

2 participants