@yahoo/uds-create-loader 2.22.0 → 2.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yahoo/uds-create-loader",
3
- "version": "2.22.0",
3
+ "version": "2.24.0",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "files": [
@@ -38,7 +38,7 @@
38
38
  "test:update": "bun test src/ --update-snapshots"
39
39
  },
40
40
  "dependencies": {
41
- "@yahoo/uds-create-config": "2.22.0",
41
+ "@yahoo/uds-create-config": "2.24.0",
42
42
  "@babel/parser": "^7.29.0",
43
43
  "@babel/traverse": "^7.29.0",
44
44
  "@babel/types": "^7.29.0",
@@ -241,6 +241,74 @@ export function Demo() {
241
241
  expect(output).toBe(source);
242
242
  });
243
243
 
244
+ it('returns source unchanged for files inside `.uds-registry/` (linked systems)', () => {
245
+ const config = makeBoxConfig();
246
+ // A linked node's sealed source: same shape as consumer code, but its
247
+ // alias imports must never rewrite to the CONSUMER's #uds/ downleveled
248
+ // modules — that would render a linked component with the consumer's
249
+ // implementation (cross-system wiring). Linked components render through
250
+ // the node-scoped modules generated under .uds/components/_linked/.
251
+ const source = `
252
+ import { Box } from '@/uds/components/box';
253
+
254
+ export function Demo() {
255
+ return <Box bg="brand">hi</Box>;
256
+ }
257
+ `;
258
+ const output = runLoader(source, config, {
259
+ resourcePath: path.join(
260
+ process.cwd(),
261
+ '.uds-registry/aaaaaaaa-1111-4111-8111-111111111111@1.0.0/src/uds/components/demo.tsx',
262
+ ),
263
+ });
264
+
265
+ expect(output).toBe(source);
266
+ });
267
+
268
+ it('skips the default registry location under componentsDir', () => {
269
+ const config = {
270
+ ...makeBoxConfig(),
271
+ buildOptions: { componentsDir: 'src/uds' },
272
+ };
273
+ const source = `
274
+ import { Box } from '@/uds/components/box';
275
+
276
+ export function Demo() {
277
+ return <Box bg="brand">hi</Box>;
278
+ }
279
+ `;
280
+ const output = runLoader(source, config, {
281
+ resourcePath: path.join(
282
+ process.cwd(),
283
+ 'src/uds/registry/aaaaaaaa-1111-4111-8111-111111111111@1.0.0/src/uds/components/demo.tsx',
284
+ ),
285
+ });
286
+
287
+ expect(output).toBe(source);
288
+ });
289
+
290
+ it('skips an explicit buildOptions.registryDir', () => {
291
+ const config = {
292
+ ...makeBoxConfig(),
293
+ buildOptions: { registryDir: 'vendor/linked' },
294
+ };
295
+ const source = `
296
+ import { Box } from '@/uds/components/box';
297
+
298
+ export function Demo() {
299
+ return <Box bg="brand">hi</Box>;
300
+ }
301
+ `;
302
+ const output = runLoader(source, config, {
303
+ resourcePath: path.join(
304
+ process.cwd(),
305
+ 'vendor/linked/aaaaaaaa-1111-4111-8111-111111111111@1.0.0/demo.tsx',
306
+ ),
307
+ });
308
+
309
+ expect(output).toBe(source);
310
+ });
311
+
244
312
  it('returns source unchanged when no manifest component is referenced', () => {
245
313
  const config = makeBoxConfig();
246
314
  const source = `
package/src/loader.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { parse } from '@babel/parser';
2
2
  import _traverse from '@babel/traverse';
3
+ import { resolveRegistryDir } from '@yahoo/uds-create-config';
3
4
  import type { LoaderDefinitionFunction } from 'webpack';
4
5
  import {
5
6
  getLoaderProjection,
@@ -47,6 +48,16 @@ const transformLoader: LoaderDefinitionFunction = function (source) {
47
48
  return source;
48
49
  }
49
50
 
51
+ // Skip materialized linked-system sources (legacy project-root layout):
52
+ // their alias imports must never rewrite to the CONSUMER's
53
+ // `#uds/components/*` downleveled modules — that would render a linked
54
+ // component with the consumer's implementation. Linked components render
55
+ // through the node-scoped modules the consumer build generates under
56
+ // `.uds/components/_linked/` (see linked-system isolation, UDS-2771).
57
+ if (resourcePath.includes('.uds-registry/')) {
58
+ return source;
59
+ }
60
+
50
61
  // Tell webpack to watch generated uds artifacts for changes.
51
62
  // Skipped when the host app has its own reload mechanism (Studio
52
63
  // WebSocket) to avoid full-page reloads on artifact regeneration.
@@ -58,6 +69,14 @@ const transformLoader: LoaderDefinitionFunction = function (source) {
58
69
  // belong to UDS. Returning early keeps non-UDS files untouched.
59
70
  const config = loadUdsConfig(dataPath, isDev);
60
71
  if (!config) return source;
72
+
73
+ // Configurable registry location (`buildOptions.registryDir`, defaulting
74
+ // to `<componentsDir>/registry`) — same skip rationale as above.
75
+ const registryRel = resolveRegistryDir(config.buildOptions);
76
+ if (resourcePath.replace(/\\/g, '/').includes(`/${registryRel}/`)) {
77
+ return source;
78
+ }
79
+
61
80
  const projection = getLoaderProjection(config);
62
81
 
63
82
  // Cheap pre-filter: only parse files that look like they import or