Skip to content

Conversation

emmatown
Copy link
Contributor

This adds an exports field so that AgDS can be imported in Node ESM environments (the exports field is required is in Node ESM for imports like package/something). The exports 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 the exports field doesn't block. All the package.json changes were done with preconstruct 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

  • Prefix the PR title with the slug of the package or component - e.g. accordion: Updated padding or docs: Updated header links
  • Describe the changes clearly in the PR description
  • Read and check your code before tagging someone for review
  • Create a changeset file by running yarn changeset. Learn more about change management.

Testing

  • Manually test component in various modern browsers at various sizes (use Browserstack)
  • Manually test component in various devices (phone, tablet, desktop)
  • Manually test component using a keyboard
  • Manually test component using a screen reader
  • Manually tested in dark mode
  • Component meets Web Content Accessibility Guidelines (WCAG) 2.1 standards
  • Add any necessary unit tests (HTML validation, snapshots etc)
  • Run yarn test to ensure tests are passing. If required, run yarn test -u to update any generated snapshots.

Documentation

  • Create or update documentation on the website
  • Create or update stories for Storybook
  • Create or update stories for Playroom snippets

Creating new component

  • Document the component for the website (docs/overview.mdx and docs/code.mdx at a minimum)
  • Preconstruct entrypoint has been created (run yarn in the root of the repo to do this)
  • Changeset file includes a minor
  • Export components for docs site and Playroom (docs/components/designSystemComponents.tsx)
  • Add component to Kitchen Sink (.storybook/stories/KitchenSink.tsx)
  • Add snippets to Playroom (docs/playroom/snippets.ts)
  • Add pictogram to Docs (docs/components/pictograms/index.tsx)

Copy link

changeset-bot bot commented Jun 13, 2024

🦋 Changeset detected

Latest commit: aad733f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@ag.ds-next/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@stowball stowball changed the base branch from main to develop September 12, 2024 05:01
@emmatown emmatown force-pushed the exports-field-and-esm-dist-for-bundlers branch 3 times, most recently from eaa78ae to d6fd153 Compare March 26, 2025 05:16
@emmatown emmatown force-pushed the exports-field-and-esm-dist-for-bundlers branch from d6fd153 to 557db0d Compare March 26, 2025 05:27
@stowball
Copy link
Contributor

@emmatown When you plop create a new component (with yarn new:package) it asks "A package.json file does not exist for this entrypoint, would you like to create one automatically?". With this change, it now errors with "error @ag.ds-next/react exports field is invalid, found… Some of the errors above can be fixed automatically by running preconstruct fix".

yarn preconstruct fix does correctly update the package.json, but is it possible to automate this?

@emmatown
Copy link
Contributor Author

Is this what you're thinking? aad733f

Copy link

@stowball
Copy link
Contributor

Is this what you're thinking? aad733f

Awesome! Now it doesn't even ask, it just does it! 🎉

Copy link
Contributor

@stowball stowball left a comment

Choose a reason for hiding this comment

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

Thank you for this!

@stowball stowball merged commit 7836f3a into agriculturegovau:develop Apr 1, 2025
5 of 6 checks passed
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