Skip to content

Commit 27ec25e

Browse files
avivkellerovflowd
andauthored
fix(ui): import aliases should not require preconditions (#9097)
* fix(ui): import aliases should not require preconditions Signed-off-by: Aviv Keller <me@aviv.sh> * fixup! --------- Signed-off-by: Aviv Keller <me@aviv.sh> Co-authored-by: Claudio Wunder <cwunder@gnome.org>
1 parent 28d264a commit 27ec25e

4 files changed

Lines changed: 32 additions & 7 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@node-core/ui-components': patch
3+
---
4+
5+
Resolve the `#ui/*` import alias to the compiled output by default, so consumers
6+
of the published package no longer need to opt into a bundler-specific
7+
`rolldown` resolution condition. The uncompiled sources stay reachable through
8+
the new `source` condition, which this repository's own tooling opts into.

‎packages/ui-components/.storybook/main.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ const config: StorybookConfig = {
77
core: { disableTelemetry: true, disableWhatsNewNotifications: true },
88
framework: '@storybook/react-webpack5',
99
swc: () => ({ jsc: { transform: { react: { runtime: 'automatic' } } } }),
10+
// Storybook renders the components straight from `src`, so `#ui/*` must
11+
// resolve to the uncompiled sources rather than to the published `dist` output
12+
webpackFinal: async config => {
13+
config.resolve ??= {};
14+
config.resolve.conditionNames = ['source', '...'];
15+
16+
return config;
17+
},
1018
addons: [
1119
'@storybook/addon-webpack5-compiler-swc',
1220
'@storybook/addon-themes',

‎packages/ui-components/.stylelintrc.mjs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ export default {
2626
plugins: [
2727
'stylelint-order',
2828
'stylelint-selector-bem-pattern',
29-
'#ui/stylelint/one-utility-class-per-line.mjs',
29+
// Stylelint resolves plugins with its own resolver, which cannot be told to
30+
// prefer the `source` condition, so we point at the uncompiled source directly
31+
'./src/stylelint/one-utility-class-per-line.mjs',
3032
],
3133
rules: {
3234
// Enforces Element Class Names to be camelCase

‎packages/ui-components/package.json‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"storybook": "cross-env NODE_NO_WARNINGS=1 storybook dev -p 6006 --quiet",
4646
"storybook:build": "cross-env NODE_NO_WARNINGS=1 storybook build --quiet --webpack-stats-json",
4747
"test": "node --run test:unit",
48-
"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.*",
48+
"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.*",
4949
"test:unit:watch": "node --run test:unit -- --watch"
5050
},
5151
"dependencies": {
@@ -97,17 +97,24 @@
9797
},
9898
"imports": {
9999
"#ui/*": {
100-
"rolldown": [
101-
"./dist/*",
102-
"./dist/*.js",
103-
"./dist/*/index.js"
100+
"types": [
101+
"./src/*",
102+
"./src/*.tsx",
103+
"./src/*/index.tsx",
104+
"./src/*.ts",
105+
"./src/*/index.ts"
104106
],
105-
"default": [
107+
"source": [
106108
"./src/*",
107109
"./src/*.tsx",
108110
"./src/*/index.tsx",
109111
"./src/*.ts",
110112
"./src/*/index.ts"
113+
],
114+
"default": [
115+
"./dist/*",
116+
"./dist/*.js",
117+
"./dist/*/index.js"
111118
]
112119
}
113120
},

0 commit comments

Comments
 (0)