@astryxdesign/build 0.6.4-canary.f0355e3 → 0.6.4

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/dist/vite.mjs CHANGED
@@ -86,34 +86,18 @@ function astryxStylex(options = {}) {
86
86
  }
87
87
  } catch {
88
88
  }
89
- const corePackageDir = path.resolve(
90
- rootDir,
91
- "node_modules/@astryxdesign/core"
92
- );
93
- const coreSourceDir = path.join(corePackageDir, "src");
94
89
  return {
95
90
  resolve: {
96
- alias: [
97
- {
98
- find: /^@astryxdesign\/core\/locales\/(.+)\.generated\.js$/,
99
- replacement: path.join(
100
- coreSourceDir,
101
- "i18n/generated-locales/$1.generated.ts"
102
- )
103
- },
104
- {
105
- find: /^@astryxdesign\/core\/locales\/(.+)\.json$/,
106
- replacement: path.join(corePackageDir, "locales/$1.json")
107
- },
108
- {
109
- find: "@astryxdesign/core/theme/tokens.stylex",
110
- replacement: path.join(coreSourceDir, "theme/tokens.stylex.ts")
111
- },
112
- {
113
- find: "@astryxdesign/core",
114
- replacement: coreSourceDir
115
- }
116
- ]
91
+ alias: {
92
+ "@astryxdesign/core/theme/tokens.stylex": path.resolve(
93
+ rootDir,
94
+ "node_modules/@astryxdesign/core/src/theme/tokens.stylex.ts"
95
+ ),
96
+ "@astryxdesign/core": path.resolve(
97
+ rootDir,
98
+ "node_modules/@astryxdesign/core/src"
99
+ )
100
+ }
117
101
  },
118
102
  optimizeDeps: {
119
103
  exclude: xdsPackages
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/build",
3
- "version": "0.6.4-canary.f0355e3",
3
+ "version": "0.6.4",
4
4
  "description": "Build plugins for Astryx source builds — babel, PostCSS, and Vite integrations",
5
5
  "author": "Meta Open Source",
6
6
  "license": "MIT",
@@ -33,16 +33,7 @@
33
33
  import {describe, it, expect, beforeAll, afterAll} from 'vitest';
34
34
  import {build} from 'vite';
35
35
  import react from '@vitejs/plugin-react';
36
- import {
37
- mkdirSync,
38
- mkdtempSync,
39
- readdirSync,
40
- readFileSync,
41
- realpathSync,
42
- rmSync,
43
- symlinkSync,
44
- writeFileSync,
45
- } from 'node:fs';
36
+ import {mkdtempSync, readdirSync, readFileSync, rmSync} from 'node:fs';
46
37
  import {tmpdir} from 'node:os';
47
38
  import * as path from 'node:path';
48
39
  import {fileURLToPath} from 'node:url';
@@ -52,7 +43,6 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
52
43
  const REPO_ROOT = path.resolve(__dirname, '../../..');
53
44
  const FIXTURES = path.resolve(__dirname, '../__fixtures__');
54
45
  const CORE_SRC = path.join(REPO_ROOT, 'packages/core/src');
55
- const CORE_PACKAGE = path.join(REPO_ROOT, 'packages/core');
56
46
 
57
47
  /** The class prefixes @astryxdesign/build/babel assigns per origin. */
58
48
  const LIBRARY_CLASS = /\.astryx[a-z0-9]{5,}/g;
@@ -215,43 +205,6 @@ function itSplitsCorrectly(get: () => Built) {
215
205
  });
216
206
  }
217
207
 
218
- describe('a production build resolves generated locale modules', () => {
219
- it('loads a generated string map through the standard Astryx Vite aliases', async () => {
220
- const root = realpathSync(
221
- mkdtempSync(path.join(tmpdir(), 'astryx-locale-import-')),
222
- );
223
- const packageDir = path.join(root, 'node_modules/@astryxdesign');
224
- const outDir = path.join(root, 'dist');
225
- mkdirSync(packageDir, {recursive: true});
226
- symlinkSync(CORE_PACKAGE, path.join(packageDir, 'core'), 'dir');
227
- writeFileSync(
228
- path.join(root, 'index.html'),
229
- '<script type="module" src="/main.ts"></script>',
230
- );
231
- writeFileSync(
232
- path.join(root, 'main.ts'),
233
- `import frFR from '@astryxdesign/core/locales/fr-FR.generated.js';\ndocument.body.textContent = frFR['@astryx.pagination.next'];\n`,
234
- );
235
-
236
- try {
237
- await build({
238
- root,
239
- logLevel: 'error',
240
- build: {outDir, emptyOutDir: true, minify: false},
241
- plugins: [...astryxStylex({rootDir: root})],
242
- });
243
- const assets = path.join(outDir, 'assets');
244
- const jsName = readdirSync(assets).find(file => file.endsWith('.js'));
245
- expect(jsName).toBeTruthy();
246
- expect(readFileSync(path.join(assets, jsName!), 'utf8')).toContain(
247
- 'Aller à la page suivante',
248
- );
249
- } finally {
250
- rmSync(root, {recursive: true, force: true});
251
- }
252
- }, 180_000);
253
- });
254
-
255
208
  describe('a production build separates Astryx and product styles by layer', () => {
256
209
  describe('when the app imports a stylesheet of its own', () => {
257
210
  let built: Built;
package/src/vite.test.ts CHANGED
@@ -16,26 +16,6 @@ import {astryxStylex} from './vite';
16
16
 
17
17
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
18
18
 
19
- function getInjectedConfig(rootDir: string): any {
20
- const plugins = astryxStylex({rootDir});
21
- const configPlugin = plugins.find(p => p.name === 'astryx-config');
22
- expect(configPlugin, 'astryx-config plugin should exist').toBeTruthy();
23
- const config = (configPlugin as any).config;
24
- return typeof config === 'function' ? config() : config.handler();
25
- }
26
-
27
- function applyAlias(aliases: any[], id: string): string {
28
- for (const alias of aliases) {
29
- if (
30
- (typeof alias.find === 'string' && id.startsWith(alias.find)) ||
31
- (alias.find instanceof RegExp && alias.find.test(id))
32
- ) {
33
- return id.replace(alias.find, alias.replacement);
34
- }
35
- }
36
- return id;
37
- }
38
-
39
19
  /** Pull the injected `@layer ...;` order statement out of the plugin set. */
40
20
  function getLayerOrder(plugins: ReturnType<typeof astryxStylex>): string {
41
21
  const layerPlugin = plugins.find(p => p.name === 'astryx-css-layer-order');
@@ -119,26 +99,6 @@ describe('astryxStylex build-time layer split', () => {
119
99
  });
120
100
  });
121
101
 
122
- describe('astryxStylex locale aliases', () => {
123
- it('routes generated and rich locale imports to their real package files', () => {
124
- const rootDir = path.join(tmpdir(), 'astryx-vite-alias');
125
- const aliases = getInjectedConfig(rootDir).resolve.alias;
126
- const corePackage = path.join(rootDir, 'node_modules/@astryxdesign/core');
127
-
128
- expect(
129
- applyAlias(aliases, '@astryxdesign/core/locales/fr-FR.generated.js'),
130
- ).toBe(
131
- path.join(corePackage, 'src/i18n/generated-locales/fr-FR.generated.ts'),
132
- );
133
- expect(applyAlias(aliases, '@astryxdesign/core/locales/fr-FR.json')).toBe(
134
- path.join(corePackage, 'locales/fr-FR.json'),
135
- );
136
- expect(applyAlias(aliases, '@astryxdesign/core/Button')).toBe(
137
- path.join(corePackage, 'src/Button'),
138
- );
139
- });
140
- });
141
-
142
102
  describe('astryxStylex optimizeDeps package discovery', () => {
143
103
  let rootDir: string;
144
104
 
package/src/vite.ts CHANGED
@@ -204,35 +204,18 @@ export function astryxStylex(
204
204
  // Fallback to just @astryxdesign/core if discovery fails
205
205
  }
206
206
 
207
- const corePackageDir = path.resolve(
208
- rootDir,
209
- 'node_modules/@astryxdesign/core',
210
- );
211
- const coreSourceDir = path.join(corePackageDir, 'src');
212
-
213
207
  return {
214
208
  resolve: {
215
- alias: [
216
- {
217
- find: /^@astryxdesign\/core\/locales\/(.+)\.generated\.js$/,
218
- replacement: path.join(
219
- coreSourceDir,
220
- 'i18n/generated-locales/$1.generated.ts',
221
- ),
222
- },
223
- {
224
- find: /^@astryxdesign\/core\/locales\/(.+)\.json$/,
225
- replacement: path.join(corePackageDir, 'locales/$1.json'),
226
- },
227
- {
228
- find: '@astryxdesign/core/theme/tokens.stylex',
229
- replacement: path.join(coreSourceDir, 'theme/tokens.stylex.ts'),
230
- },
231
- {
232
- find: '@astryxdesign/core',
233
- replacement: coreSourceDir,
234
- },
235
- ],
209
+ alias: {
210
+ '@astryxdesign/core/theme/tokens.stylex': path.resolve(
211
+ rootDir,
212
+ 'node_modules/@astryxdesign/core/src/theme/tokens.stylex.ts',
213
+ ),
214
+ '@astryxdesign/core': path.resolve(
215
+ rootDir,
216
+ 'node_modules/@astryxdesign/core/src',
217
+ ),
218
+ },
236
219
  },
237
220
  optimizeDeps: {
238
221
  exclude: xdsPackages,