Skip to content

Add package.exports to @zenstack/server #652

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

Merged
merged 8 commits into from
Aug 28, 2023
Merged

Conversation

krist7599555
Copy link
Contributor

Many bundler with mixed esm/cjs will not work without exports field in package.json

image

@ymc9
Copy link
Member

ymc9 commented Aug 27, 2023

Thanks for making this PR @krist7599555 !

I'm thinking maybe we should really generate cjs/esm dual format during build (like already done in the runtime package with tsup). I'm not really an expert on bundlers. Do you feel that to be necessary?

@ymc9 ymc9 changed the base branch from main to dev August 27, 2023 10:32
@krist7599555
Copy link
Contributor Author

@zenstack/server will mostly be use with framework like next, sveltekit which have another step to build production. And output is likely to be esm with import syntax.

So, I suggest using tsup with minify=false is the way.

If @ymc9 agree I welcomely to create pull request about Migrate
@zenstack/server to tsup
for you. (breaking!! change because npm folder structure will nested 1 level)

from

package.json
api/base.js
api/rest/index.js
api/rpc/index.js
api/utils.js
express/index.js
express/middleware.js
fastify/index.js
fastify/plugin.js

to

package.json
dist/api/base.js
dist/api/rest/index.js
dist/api/rpc/index.js
dist/api/utils.js
dist/express/index.js
dist/express/middleware.js
dist/fastify/index.js
dist/fastify/plugin.js

@ymc9
Copy link
Member

ymc9 commented Aug 27, 2023

The "package.json" file has a publishConfig setting:

    "publishConfig": {
        "directory": "dist",
        "linkDirectory": true
    }

So when published, the content of "dist" will be deployed instead of the root folder. I think we don't need the "dist" level in the "exports" section.

I'm not even sure if cjs/ems dual output is necessary. If framework bundlers are fine with CJS we can probably keep it as is. Just curious, with what framework did you initially run into issues with the "exports" section missing?

@ymc9 ymc9 merged commit 76c12f5 into zenstackhq:dev Aug 28, 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