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: update unbuild to 2.0.0, fix type declarations for ESM #28

Merged
merged 2 commits into from
Feb 20, 2024
Merged

fix: update unbuild to 2.0.0, fix type declarations for ESM #28

merged 2 commits into from
Feb 20, 2024

Conversation

wojtekmaj
Copy link
Contributor

@wojtekmaj wojtekmaj commented Feb 13, 2024

Fixes #24

This PR:

Before:

image

After:

image

@bluwy
Copy link
Member

bluwy commented Feb 20, 2024

The build fails for me locally:

> @vitejs/[email protected] build /Users/bjorn/Work/oss/vite-plugin-basic-ssl
> unbuild && esno scripts/patchCJS.ts

ℹ Building plugin-basic-ssl                                                               2:58:42 PM
ℹ Cleaning dist directory: ./dist                                                         2:58:42 PM
Entry module "src/index.ts" is using named and default exports together. Consumers of your bundle will have to use `chunk.default` to access the default export, which may not be what you want. Use `output.exports: "named"` to disable this warning.
✔ Build succeeded for plugin-basic-ssl                                                    2:58:43 PM
[2:58:43 PM]   dist/index.cjs (total size: 1.86 kB, chunk size: 1.86 kB, exports: default, getCertificate)

[2:58:43 PM]   dist/index.mjs (total size: 1.54 kB, chunk size: 1.54 kB, exports: default, getCertificate)

Σ Total dist size (byte size): 1.18 MB
                                                                                           2:58:43 PM
dist/index.cjs CJS patch failed
 ELIFECYCLE  Command failed with exit code 1.

It looks like our CI didn't run the build at all since Vitest can run on raw files.

@wojtekmaj
Copy link
Contributor Author

This was because the code we generated was ES3 (!) compliant, and using new unbuild, it's not doing that by default. It all comes down to this setting:

https://rollupjs.org/configuration-options/#output-generatedcode-reservednamesasprops

Fixed that, patch now works.

Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

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

Thanks for looking into this! That makes sense to me.

@patak-dev I guess we should release this as a minor as it could affect things? Don't think it needs a major though since things should still work the same.

@patak-dev patak-dev merged commit 2266824 into vitejs:main Feb 20, 2024
1 check passed
@wojtekmaj wojtekmaj deleted the fix-esm branch February 20, 2024 17:48
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.

"This expression is not callable." when using TypeScript with moduleResolution set to node16 or nodenext
3 participants