build: Add exports
field and ESM build for bundlers with module
field/condition
#1695
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds an
exports
field so that AgDS can be imported in Node ESM environments (theexports
field is required is in Node ESM for imports likepackage/something
). Theexports
field also restricts imports to what's specified in it so imports like e.g.@ag.ds-next/react/src/blah
don't work, for the imports in the repo where it makes sense to do this, I've changed them to be relative which theexports
field doesn't block. All thepackage.json
changes were done withpreconstruct fix
after adding the"exports": true
option the root config. Using the"exports": true
option in Preconstruct also enforces that there's an ESM build for bundlers so this adds that as well (I'm pretty sure that was just mistakenly removed in #902), also worth noting that this ESM build is unrelated to Node ESM, it's only used by bundlers and intentionally isn't used in Node for reasons that would take a while to get into.Checklist
Preflight
accordion: Updated padding
ordocs: Updated header links
yarn changeset
. Learn more about change management.Testing
yarn test
to ensure tests are passing. If required, runyarn test -u
to update any generated snapshots.Documentation
Creating new component
docs/overview.mdx
anddocs/code.mdx
at a minimum)yarn
in the root of the repo to do this)docs/components/designSystemComponents.tsx
).storybook/stories/KitchenSink.tsx
)docs/playroom/snippets.ts
)docs/components/pictograms/index.tsx
)