thheller / shadow-cljs

ClojureScript compilation made easy
https://github.com/thheller/shadow-cljs
Eclipse Public License 1.0
2.25k stars 178 forks source link

Don't export at all without export or export-as meta (Fix Storybook) #1143

Closed garrett-hopper closed 1 year ago

garrett-hopper commented 1 year ago

Originally changed in https://github.com/thheller/shadow-cljs/commit/ec63c34ae493a7e75e9fe7d5f3ab7cadd1fecfe8 for #710

The latest version of Webpack appears to behave differently than it did at the time the change was made.

technically still exported to avoid breaking existing builds but tools like storybook should no longer find them because of enumerable: false.

Webpack's require shim no longer respects enumerable: false, which causes Storybook to see exports it shouldn't.

This change forces properties to not be exported unless they explicitly have ^:export (or ^{:exportAs ""}) metadata.

I'm not sure which existing builds mentioned in @thheller's comment might be broken by this change.

If that's a concern, perhaps this change should be behind some sort of flag on the ns with the default behavior being the existing "export everything, but use enumerable: false" behavior.

(It's really only necessary for module consumers that expect all exports to mean something specific, like Storybook.)

thheller commented 1 year ago

Makes sense I guess. Accessing not-exported things worked fine in dev but broke in release anyways.