diff --git a/.changeset/import-aliases-no-preconditions.md b/.changeset/import-aliases-no-preconditions.md new file mode 100644 index 0000000000000..252399d58c0f9 --- /dev/null +++ b/.changeset/import-aliases-no-preconditions.md @@ -0,0 +1,8 @@ +--- +'@node-core/ui-components': patch +--- + +Resolve the `#ui/*` import alias to the compiled output by default, so consumers +of the published package no longer need to opt into a bundler-specific +`rolldown` resolution condition. The uncompiled sources stay reachable through +the new `source` condition, which this repository's own tooling opts into. diff --git a/packages/ui-components/.storybook/main.ts b/packages/ui-components/.storybook/main.ts index 5580f40838c5b..87d435aae39eb 100644 --- a/packages/ui-components/.storybook/main.ts +++ b/packages/ui-components/.storybook/main.ts @@ -7,6 +7,14 @@ const config: StorybookConfig = { core: { disableTelemetry: true, disableWhatsNewNotifications: true }, framework: '@storybook/react-webpack5', swc: () => ({ jsc: { transform: { react: { runtime: 'automatic' } } } }), + // Storybook renders the components straight from `src`, so `#ui/*` must + // resolve to the uncompiled sources rather than to the published `dist` output + webpackFinal: async config => { + config.resolve ??= {}; + config.resolve.conditionNames = ['source', '...']; + + return config; + }, addons: [ '@storybook/addon-webpack5-compiler-swc', '@storybook/addon-themes', diff --git a/packages/ui-components/.stylelintrc.mjs b/packages/ui-components/.stylelintrc.mjs index eed4b8c01f612..e371180e8fe7c 100644 --- a/packages/ui-components/.stylelintrc.mjs +++ b/packages/ui-components/.stylelintrc.mjs @@ -26,7 +26,9 @@ export default { plugins: [ 'stylelint-order', 'stylelint-selector-bem-pattern', - '#ui/stylelint/one-utility-class-per-line.mjs', + // Stylelint resolves plugins with its own resolver, which cannot be told to + // prefer the `source` condition, so we point at the uncompiled source directly + './src/stylelint/one-utility-class-per-line.mjs', ], rules: { // Enforces Element Class Names to be camelCase diff --git a/packages/ui-components/package.json b/packages/ui-components/package.json index 328b62735bd31..d30ffc949d6b7 100644 --- a/packages/ui-components/package.json +++ b/packages/ui-components/package.json @@ -45,7 +45,7 @@ "storybook": "cross-env NODE_NO_WARNINGS=1 storybook dev -p 6006 --quiet", "storybook:build": "cross-env NODE_NO_WARNINGS=1 storybook build --quiet --webpack-stats-json", "test": "node --run test:unit", - "test:unit": "cross-env NODE_NO_WARNINGS=1 node --experimental-test-coverage --test-coverage-exclude=**/*.test.* --enable-source-maps --import=global-jsdom/register --import=tsx --import=../../tests/setup.mjs --test **/*.test.*", + "test:unit": "cross-env NODE_NO_WARNINGS=1 node --conditions=source --experimental-test-coverage --test-coverage-exclude=**/*.test.* --enable-source-maps --import=global-jsdom/register --import=tsx --import=../../tests/setup.mjs --test **/*.test.*", "test:unit:watch": "node --run test:unit -- --watch" }, "dependencies": { @@ -97,17 +97,24 @@ }, "imports": { "#ui/*": { - "rolldown": [ - "./dist/*", - "./dist/*.js", - "./dist/*/index.js" + "types": [ + "./src/*", + "./src/*.tsx", + "./src/*/index.tsx", + "./src/*.ts", + "./src/*/index.ts" ], - "default": [ + "source": [ "./src/*", "./src/*.tsx", "./src/*/index.tsx", "./src/*.ts", "./src/*/index.ts" + ], + "default": [ + "./dist/*", + "./dist/*.js", + "./dist/*/index.js" ] } },