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: library does not load in webpack projects #364 #365

Merged
merged 1 commit into from
May 16, 2023

Conversation

danice
Copy link

@danice danice commented May 4, 2023

Proposed changes

Changed library export method to export default M; and the configuration of webpack output library to the options that has proved to work without breaking changes for existing doc pages and also for projects using the library in typescript classes and webpack for bundling.

Types of changes

  • [x ] Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to change).

Checklist:

  • this can be tested with the webpack version of document that was linked in the issue description.

  • It would be good to have some official demo of the library in a webpack project

  • [x ] I have read the CONTRIBUTING document.

  • [x ] My commit messages follows the conventional commit format

  • My change requires a change to the documentation, and updated it accordingly.

  • I have added tests to cover my changes.

  • All new and existing tests passed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked it up on the webpack docu, but I did not fully understand why you changed this. Can you elaborate what this does?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, is it because of the Type any at the import?

Copy link
Author

@danice danice May 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous
module.exports = M
is the export following CommonJS format. After different proofs I was not able to make it work in the example ts-webpack project.
So I decided to change the format to the ES Module syntax (that of course is what is used now in typescript projects). With this it worked perfectly in the webpack project and I had to do the other changes in the webpack output config to make it work in plain js projects.
The

optimization: {
    minimize: false,
  }

was only to debug the result code more easily but I think we can removed it now.

Comment on lines +35 to 37
optimization: {
minimize: false,
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is that? I guess because of the function name obfuscation due to minimization process.

src/global.ts Show resolved Hide resolved
@wuda-io
Copy link
Member

wuda-io commented May 16, 2023

Thanks for your contribution! Please next time please base your PR into the DEV branch,
every PR from now has to be merged into DEV and at the Release in MAIN.
I dont really know how to test this... I will try locally and the approve if it works.
Sorry for the delay, best greets!

@wuda-io wuda-io self-requested a review May 16, 2023 11:05
Copy link
Member

@wuda-io wuda-io left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok local test worked, details can be handled later. Good work 👍

@wuda-io wuda-io merged commit d2bdbdd into materializecss:main May 16, 2023
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