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

Update package.json - added module - fix vite esm build #506

Merged
merged 4 commits into from
Dec 22, 2022

Conversation

salvoravida
Copy link
Contributor

@salvoravida salvoravida commented Oct 19, 2022

Update package.json - added module - fix vite esm build


This change is Reviewable

@LouisBarranqueiro
Copy link
Owner

👋 @salvoravida Could you please share more information about this fix? What's the context?

@salvoravida
Copy link
Contributor Author

salvoravida commented Oct 19, 2022

without "module": "dist/reapop.esm.js",
inside package.json
modern bundlers like VITE cannot use the esm build (not the commonJS one (main))
and so the bundle is not working.

that's all.
the module entry is automatically added by tsdx

https://github.com/jaredpalmer/tsdx/blob/v0.14.1/src/templates/utils/index.ts#L15

@salvoravida
Copy link
Contributor Author

salvoravida commented Oct 19, 2022

the node_env=production is an optimizaiton for the esm build -> https://tsdx.io/optimization

For ESM build, it's up to end-user to build environment specific build with NODE_ENV

@ReidBraswell
Copy link

@salvoravida also using vite with a react app and seeing the following runtime error:

Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.

I'd imagine your fix should help as the default import is not what is expected?

@salvoravida
Copy link
Contributor Author

@salvoravida also using vite with a react app and seeing the following runtime error:

Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.

I'd imagine your fix should help as the default import is not what is expected?

I dnk, anyway can test my current fork with the fix

@salvoravida/reapop 4.2.1

https://www.npmjs.com/package/@salvoravida/reapop

@salvoravida
Copy link
Contributor Author

@LouisBarranqueiro any updates on this?

@LouisBarranqueiro
Copy link
Owner

👋 @salvoravida, sorry for the VERY VERY late reply.

For ESM build, it's up to end-user to build environment specific build with NODE_ENV

I compared builds with and without it and it's the same. I will keep it just in case and check for newer versions if there is a difference.

Thanks for the contribution 🙏

Copy link
Owner

@LouisBarranqueiro LouisBarranqueiro left a comment

Choose a reason for hiding this comment

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

code :lgtm:

Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @salvoravida)

Copy link
Owner

@LouisBarranqueiro LouisBarranqueiro left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @salvoravida)

@LouisBarranqueiro LouisBarranqueiro merged commit cc701f5 into LouisBarranqueiro:main Dec 22, 2022
@LouisBarranqueiro
Copy link
Owner

I will update other dependencies and release a new version this WE 🙂

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.

None yet

3 participants