Skip to content
This repository has been archived by the owner on Jul 12, 2021. It is now read-only.

Add build support for both cjs and esm #8

Merged
merged 2 commits into from
Jun 4, 2021
Merged

Conversation

winkerVSbecks
Copy link
Collaborator

@winkerVSbecks winkerVSbecks commented Jun 4, 2021

What I did?

  • Modified the build setup to generate both esm and cjs output
  • Watch task only builds cjs
  • Moved types output to dist/types
  • Added a stub index.js file similar to SB monorepo

closes #6

📦 Published PR as canary version: 1.2.1--canary.8.cce715f.0

✨ Test out this PR locally via:

npm install @storybook/addon-measure@1.2.1--canary.8.cce715f.0
# or 
yarn add @storybook/addon-measure@1.2.1--canary.8.cce715f.0

Copy link
Member

@IanVS IanVS left a comment

Choose a reason for hiding this comment

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

Using the canary version does indeed work correctly with the vite builder, whereas 1.2.0 fails. So this seems to be working correctly, although I have one comment about the build script.

package.json Outdated
"buildTsc": "tsc --declaration --emitDeclarationOnly --outDir ./dist",
"build": "concurrently \"yarn run buildBabel\" \"yarn run buildTsc\"",
"build:watch": "concurrently \"yarn run buildBabel -- --watch\" \"yarn run buildTsc -- --watch\"",
"buildBabel": "concurrently \"yarn buildBabel:cjs\" \"yarn buildBabel:esm\" \"yarn buildTsc\"",
Copy link
Member

Choose a reason for hiding this comment

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

It doesn't seem like buildTsc belongs in buildBabel, does it? I think that's handled by build below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch!

@winkerVSbecks
Copy link
Collaborator Author

@IanVS the main and module paths were incorrect in the last build. Could you give another go with 1.2.1--canary.8.cce715f.0 thanks!

@winkerVSbecks winkerVSbecks merged commit 05528a0 into main Jun 4, 2021
@winkerVSbecks winkerVSbecks deleted the esm-support branch June 4, 2021 16:15
@IanVS
Copy link
Member

IanVS commented Jun 4, 2021

@winkerVSbecks I'm not seeing any errors from the addon, so it seems like it's doing the right thing now! (My vite builder still isn't actually building my stories correctly, but the error from this plugin is gone at least, and I now have other problems).

@winkerVSbecks
Copy link
Collaborator Author

Perfect, thank you for your help

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Distribute ESM bundle
3 participants