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

build: support multi-entry build #1

Conversation

micmro
Copy link

@micmro micmro commented Oct 25, 2020

Hi @brendanrygus
I got the multi-entry build working, can you check if this works for your needs?

Screen Shot 2020-10-24 at 9 55 14 PM

@@ -52,7 +62,8 @@
},
"scripts": {
"start": "tsdx watch",
"build": "tsdx build",
"build": "tsdx build --entry src/index.tsx --entry src/register.tsx && npm run post-build",
"post-build": "node scripts/post-tsdx.js",
Copy link
Author

Choose a reason for hiding this comment

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

needed a post tsdx step to fix the cjs enty files (dist/index.js points at the wrong files and dist/register.js does not exist)

Comment on lines +42 to +51
"exports": {
".": {
"import": "./dist/index.esm.js",
"require": "./dist/index.js"
},
"./register": {
"import": "./dist/register.esm.js",
"require": "./dist/register.js"
}
},
Copy link
Author

Choose a reason for hiding this comment

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

I have not tested this out yet, https://nodejs.org/api/packages.html#packages_writing_dual_packages_while_avoiding_or_minimizing_hazards might be useful but "type": "module" does not play well with TSDX

@@ -0,0 +1,16 @@
// TSDX does not currently support multiple entry files out of the box,
Copy link
Author

Choose a reason for hiding this comment

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

TSDX does not currently support multiple entry files out of the box, so I had to overwrite the Rollup config
Ref: jaredpalmer/tsdx#175 (comment)

@lifeiscontent
Copy link

@micmro I was thinking of just tossing out tsdx all together and just creating a tsc build with esm and cjs outputs. wdyt?

@micmro
Copy link
Author

micmro commented Nov 5, 2020

Makes sense, tsdx works great for simple projects but is's quite limiting. I'll just need find time for this.

@brendanrygus
Copy link
Owner

In the event that we end up keeping this approach...

I finally tested this out tonight (sorry for the delay!) but had some issues implementing it in the test app. I could only get Webpack to resolve the import from "storybook-addon-apollo-client/dist/register", and not from "storybook-addon-apollo-client/register".

I'm currently installing it from a local directory "storybook-addon-apollo-client": "file:../storybook-addon-apollo-client" if that makes an impact on the resolution? I'll hopefully get time to look into this some more soon, and keep troubleshooting

@lifeiscontent
Copy link

@brendanrygus I'm pretty sure storybook resolves modern ES6 code, so we could potentially just use tsc and have it build for ES6

@micmro micmro closed this Jul 11, 2021
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.

3 participants