@quilted/rollup 0.2.3 → 0.2.5

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/esm/app.mjs +151 -113
  3. package/build/esm/features/node.mjs +57 -0
  4. package/build/esm/features/react.mjs +22 -0
  5. package/build/esm/features/typescript.mjs +2 -2
  6. package/build/esm/index.mjs +1 -1
  7. package/build/esm/module.mjs +26 -27
  8. package/build/esm/package.mjs +36 -79
  9. package/build/esm/server.mjs +22 -25
  10. package/build/esm/shared/browserslist.mjs +2 -1
  11. package/build/esm/shared/project.mjs +100 -0
  12. package/build/esm/shared/rollup.mjs +4 -1
  13. package/build/tsconfig.tsbuildinfo +1 -1
  14. package/build/typescript/app.d.ts +64 -14
  15. package/build/typescript/app.d.ts.map +1 -1
  16. package/build/typescript/features/node.d.ts +4 -0
  17. package/build/typescript/features/node.d.ts.map +1 -0
  18. package/build/typescript/features/react.d.ts +28 -0
  19. package/build/typescript/features/react.d.ts.map +1 -0
  20. package/build/typescript/features/typescript.d.ts +1 -1
  21. package/build/typescript/features/typescript.d.ts.map +1 -1
  22. package/build/typescript/index.d.ts +1 -1
  23. package/build/typescript/index.d.ts.map +1 -1
  24. package/build/typescript/module.d.ts +3 -4
  25. package/build/typescript/module.d.ts.map +1 -1
  26. package/build/typescript/package.d.ts +3 -5
  27. package/build/typescript/package.d.ts.map +1 -1
  28. package/build/typescript/server.d.ts +4 -3
  29. package/build/typescript/server.d.ts.map +1 -1
  30. package/build/typescript/shared/browserslist.d.ts.map +1 -1
  31. package/build/typescript/shared/project.d.ts +33 -0
  32. package/build/typescript/shared/project.d.ts.map +1 -0
  33. package/build/typescript/shared/rollup.d.ts +2 -1
  34. package/build/typescript/shared/rollup.d.ts.map +1 -1
  35. package/package.json +19 -1
  36. package/source/app.ts +200 -141
  37. package/source/features/node.ts +74 -0
  38. package/source/features/react.ts +26 -0
  39. package/source/features/typescript.ts +1 -1
  40. package/source/index.ts +3 -1
  41. package/source/module.ts +27 -35
  42. package/source/package.ts +37 -109
  43. package/source/server.ts +25 -31
  44. package/source/shared/browserslist.ts +3 -1
  45. package/source/shared/project.ts +150 -0
  46. package/source/shared/rollup.ts +5 -1
  47. package/build/esm/shared/package-json.mjs +0 -16
  48. package/build/esm/shared/path.mjs +0 -7
  49. package/source/shared/package-json.ts +0 -20
  50. package/source/shared/path.ts +0 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @quilted/rollup
2
2
 
3
+ ## 0.2.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [`465883e1`](https://github.com/lemonmade/quilt/commit/465883e12571bee9d6e8c8d517ebf6da384687b2) Thanks [@lemonmade](https://github.com/lemonmade)! - Add support for automatic in-repo source aliases
8
+
9
+ ## 0.2.4
10
+
11
+ ### Patch Changes
12
+
13
+ - [`533e7d76`](https://github.com/lemonmade/quilt/commit/533e7d766fb1a0d023c3aabf60cadb59cadecd73) Thanks [@lemonmade](https://github.com/lemonmade)! - Improve Vite and Rollup plugins
14
+
3
15
  ## 0.2.3
4
16
 
5
17
  ### Patch Changes
package/build/esm/app.mjs CHANGED
@@ -1,19 +1,17 @@
1
1
  import * as path from 'node:path';
2
2
  import * as fs from 'node:fs/promises';
3
- import { glob } from 'glob';
4
3
  import { createRequire } from 'node:module';
5
4
  import { MAGIC_MODULE_ENTRY, MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_REQUEST_ROUTER, MAGIC_MODULE_BROWSER_ASSETS } from './constants.mjs';
6
5
  import { resolveEnvOption } from './features/env.mjs';
7
6
  import { multiline } from './shared/strings.mjs';
8
- import { getNodePlugins, removeBuildFiles } from './shared/rollup.mjs';
7
+ import { getNodePlugins, removeBuildFiles, normalizeRollupInput } from './shared/rollup.mjs';
9
8
  import { createMagicModulePlugin } from './shared/magic-module.mjs';
10
9
  import { getBrowserGroups, getBrowserGroupTargetDetails, targetsSupportModules, rollupGenerateOptionsForBrowsers, getBrowserGroupRegularExpressions } from './shared/browserslist.mjs';
11
- import { loadPackageJSON } from './shared/package-json.mjs';
12
- import { resolveRoot } from './shared/path.mjs';
10
+ import { Project } from './shared/project.mjs';
13
11
 
14
12
  const require = createRequire(import.meta.url);
15
- async function quiltApp({
16
- root: rootPath = process.cwd(),
13
+ async function quiltAppOptions({
14
+ root = process.cwd(),
17
15
  app,
18
16
  env,
19
17
  graphql,
@@ -21,15 +19,15 @@ async function quiltApp({
21
19
  browser: browserOptions,
22
20
  server: serverOptions
23
21
  } = {}) {
24
- const root = resolveRoot(rootPath);
25
- const browserGroups = await getBrowserGroups({ root });
22
+ const project = Project.load(root);
23
+ const browserGroups = await getBrowserGroups({ root: project.root });
26
24
  const browserGroupEntries = Object.entries(browserGroups);
27
25
  const hasMultipleBrowserGroups = browserGroupEntries.length > 1;
28
26
  const optionPromises = [];
29
27
  browserGroupEntries.forEach(([name, browsers], index) => {
30
28
  optionPromises.push(
31
- quiltAppBrowser({
32
- root,
29
+ quiltAppBrowserOptions({
30
+ root: project.root,
33
31
  app,
34
32
  graphql,
35
33
  ...browserOptions,
@@ -50,19 +48,49 @@ async function quiltApp({
50
48
  );
51
49
  });
52
50
  optionPromises.push(
53
- quiltAppServer({
54
- root,
51
+ quiltAppServerOptions({
52
+ root: project.root,
55
53
  app,
56
54
  graphql,
57
55
  ...serverOptions,
58
- env: { ...resolveEnvOption(env), ...resolveEnvOption(serverOptions?.env) },
56
+ env: {
57
+ ...resolveEnvOption(env),
58
+ ...resolveEnvOption(serverOptions?.env)
59
+ },
59
60
  assets: { ...assets, ...serverOptions?.assets }
60
61
  })
61
62
  );
62
63
  return Promise.all(optionPromises);
63
64
  }
65
+ async function quiltAppBrowserOptions(options = {}) {
66
+ const { root = process.cwd(), assets } = options;
67
+ const project = Project.load(root);
68
+ const [plugins, browserGroup] = await Promise.all([
69
+ quiltAppBrowser(options),
70
+ getBrowserGroupTargetDetails(assets?.targets, {
71
+ root: project.root
72
+ })
73
+ ]);
74
+ const targetFilenamePart = browserGroup.name ? `.${browserGroup.name}` : "";
75
+ const [isESM, generatedCode] = await Promise.all([
76
+ targetsSupportModules(browserGroup.browsers),
77
+ rollupGenerateOptionsForBrowsers(browserGroup.browsers)
78
+ ]);
79
+ return {
80
+ plugins,
81
+ output: {
82
+ format: isESM ? "esm" : "systemjs",
83
+ dir: project.resolve(`build/assets`),
84
+ entryFileNames: `[name]${targetFilenamePart}.[hash].js`,
85
+ assetFileNames: `[name]${targetFilenamePart}.[hash].[ext]`,
86
+ chunkFileNames: `[name]${targetFilenamePart}.[hash].js`,
87
+ manualChunks: createManualChunksSorter(),
88
+ generatedCode
89
+ }
90
+ };
91
+ }
64
92
  async function quiltAppBrowser({
65
- root: rootPath = process.cwd(),
93
+ root = process.cwd(),
66
94
  app,
67
95
  entry,
68
96
  env,
@@ -70,43 +98,46 @@ async function quiltAppBrowser({
70
98
  module,
71
99
  graphql = true
72
100
  } = {}) {
73
- const root = resolveRoot(rootPath);
101
+ const project = Project.load(root);
74
102
  const mode = (typeof env === "object" ? env?.mode : env) ?? "production";
75
103
  const minify = assets?.minify ?? mode === "production";
76
104
  const baseURL = assets?.baseURL ?? "/assets/";
77
105
  const assetsInline = assets?.inline ?? true;
78
106
  const browserGroup = await getBrowserGroupTargetDetails(assets?.targets, {
79
- root
107
+ root: project.root
80
108
  });
81
109
  const targetFilenamePart = browserGroup.name ? `.${browserGroup.name}` : "";
82
110
  const [
83
111
  { visualizer },
84
112
  { magicModuleEnv, replaceProcessEnv },
85
113
  { sourceCode },
86
- { createTSConfigAliasPlugin },
114
+ { tsconfigAliases },
115
+ { monorepoPackageAliases },
116
+ { react },
87
117
  { css },
88
118
  { assetManifest, rawAssets, staticAssets },
89
119
  { asyncModules },
90
120
  { systemJS },
91
121
  { workers },
92
122
  { esnext },
93
- nodePlugins,
94
- packageJSON
123
+ nodePlugins
95
124
  ] = await Promise.all([
96
125
  import('rollup-plugin-visualizer'),
97
126
  import('./features/env.mjs'),
98
127
  import('./features/source-code.mjs'),
99
128
  import('./features/typescript.mjs'),
129
+ import('./features/node.mjs'),
130
+ import('./features/react.mjs'),
100
131
  import('./features/css.mjs'),
101
132
  import('./features/assets.mjs'),
102
133
  import('./features/async.mjs'),
103
134
  import('./features/system-js.mjs'),
104
135
  import('./features/workers.mjs'),
105
136
  import('./features/esnext.mjs'),
106
- getNodePlugins({ bundle: true }),
107
- loadPackageJSON(root)
137
+ getNodePlugins({ bundle: true })
108
138
  ]);
109
139
  const plugins = [
140
+ quiltAppBrowserInput({ root: project.root, entry }),
110
141
  ...nodePlugins,
111
142
  systemJS({ minify }),
112
143
  replaceProcessEnv({ mode }),
@@ -128,11 +159,12 @@ async function quiltAppBrowser({
128
159
  }
129
160
  }
130
161
  }),
162
+ react(),
163
+ css({ minify, emit: true }),
131
164
  esnext({
132
165
  mode,
133
166
  targets: browserGroup.browsers
134
167
  }),
135
- css({ minify, emit: true }),
136
168
  rawAssets(),
137
169
  staticAssets({
138
170
  baseURL,
@@ -142,32 +174,30 @@ async function quiltAppBrowser({
142
174
  asyncModules({
143
175
  baseURL,
144
176
  preload: true,
145
- moduleID: ({ imported }) => path.relative(root, imported)
177
+ moduleID: ({ imported }) => path.relative(project.root, imported)
146
178
  }),
147
179
  workers({
148
180
  baseURL,
149
181
  outputOptions: {
150
182
  format: "iife",
151
183
  inlineDynamicImports: true,
152
- dir: path.resolve(root, `build/assets`),
184
+ dir: project.resolve(`build/assets`),
153
185
  entryFileNames: `[name]${targetFilenamePart}.[hash].js`,
154
186
  assetFileNames: `[name]${targetFilenamePart}.[hash].[ext]`,
155
187
  chunkFileNames: `[name]${targetFilenamePart}.[hash].js`
156
188
  }
157
- })
189
+ }),
190
+ tsconfigAliases({ root: project.root }),
191
+ monorepoPackageAliases({ root: project.root })
158
192
  ];
159
193
  if (assets?.clean ?? true) {
160
194
  plugins.push(
161
195
  removeBuildFiles(["build/assets", "build/manifests", "build/reports"], {
162
- root
196
+ root: project.root
163
197
  })
164
198
  );
165
199
  }
166
- const tsconfigAliases = await createTSConfigAliasPlugin();
167
- if (tsconfigAliases) {
168
- plugins.push(tsconfigAliases);
169
- }
170
- const appEntry = await resolveAppEntry(app, { root, packageJSON });
200
+ const appEntry = await resolveAppEntry(app, project);
171
201
  if (appEntry) {
172
202
  plugins.push(magicModuleAppComponent({ entry: appEntry }));
173
203
  }
@@ -176,8 +206,7 @@ async function quiltAppBrowser({
176
206
  const { graphql: graphql2 } = await import('./features/graphql.mjs');
177
207
  plugins.push(
178
208
  graphql2({
179
- manifest: path.resolve(
180
- root,
209
+ manifest: project.resolve(
181
210
  `build/manifests/graphql${targetFilenamePart}.json`
182
211
  )
183
212
  })
@@ -195,54 +224,61 @@ async function quiltAppBrowser({
195
224
  assetManifest({
196
225
  baseURL,
197
226
  cacheKey,
198
- file: path.resolve(
199
- root,
200
- `build/manifests/assets${targetFilenamePart}.json`
201
- ),
227
+ file: project.resolve(`build/manifests/assets${targetFilenamePart}.json`),
202
228
  priority: assets?.priority
203
229
  }),
204
230
  visualizer({
205
231
  template: "treemap",
206
232
  open: false,
207
233
  brotliSize: true,
208
- filename: path.resolve(
209
- root,
234
+ filename: project.resolve(
210
235
  `build/reports/bundle-visualizer${targetFilenamePart}.html`
211
236
  )
212
237
  })
213
238
  );
214
- const finalEntry = entry ? path.resolve(root, entry) : await glob("{browser,client,web}.{ts,tsx,mjs,js,jsx}", {
215
- cwd: root,
216
- nodir: true,
217
- absolute: true
218
- }).then((files) => files[0]) ?? MAGIC_MODULE_ENTRY;
219
- const isESM = await targetsSupportModules(browserGroup.browsers);
239
+ return plugins;
240
+ }
241
+ function quiltAppBrowserInput({
242
+ root = process.cwd(),
243
+ entry
244
+ } = {}) {
245
+ const project = Project.load(root);
246
+ return {
247
+ name: "@quilted/app-browser/input",
248
+ async options(options) {
249
+ const finalEntry = normalizeRollupInput(options.input) ?? (entry ? project.resolve(entry) : await project.glob("{browser,client,web}.{ts,tsx,mjs,js,jsx}", {
250
+ nodir: true,
251
+ absolute: true
252
+ }).then((files) => files[0])) ?? MAGIC_MODULE_ENTRY;
253
+ return {
254
+ ...options,
255
+ // If we are using the "magic entry", give it an explicit name of `browser`.
256
+ // Otherwise, Rollup will use the file name as the output name.
257
+ input: finalEntry === MAGIC_MODULE_ENTRY ? { browser: finalEntry } : finalEntry
258
+ };
259
+ }
260
+ };
261
+ }
262
+ async function quiltAppServerOptions(options = {}) {
263
+ const { root = process.cwd(), output } = options;
264
+ const project = Project.load(root);
265
+ const hash = output?.hash ?? "async-only";
266
+ const outputFormat = output?.format ?? "esmodules";
267
+ const plugins = await quiltAppServer(options);
220
268
  return {
221
- // If we are using the "magic entry", give it an explicit name of `browser`.
222
- // Otherwise, Rollup will use the file name as the output name.
223
- input: finalEntry === MAGIC_MODULE_ENTRY ? { browser: finalEntry } : finalEntry,
224
269
  plugins,
225
- onwarn(warning, defaultWarn) {
226
- if (warning.code === "MODULE_LEVEL_DIRECTIVE" && /['"]use client['"]/.test(warning.message)) {
227
- return;
228
- }
229
- defaultWarn(warning);
230
- },
231
270
  output: {
232
- format: isESM ? "esm" : "systemjs",
233
- dir: path.resolve(root, `build/assets`),
234
- entryFileNames: `[name]${targetFilenamePart}.[hash].js`,
235
- assetFileNames: `[name]${targetFilenamePart}.[hash].[ext]`,
236
- chunkFileNames: `[name]${targetFilenamePart}.[hash].js`,
237
- manualChunks: createManualChunksSorter(),
238
- generatedCode: await rollupGenerateOptionsForBrowsers(
239
- browserGroup.browsers
240
- )
271
+ format: outputFormat === "commonjs" || outputFormat === "cjs" ? "cjs" : "esm",
272
+ dir: project.resolve(`build/server`),
273
+ entryFileNames: `[name]${hash === true ? `.[hash]` : ""}.js`,
274
+ chunkFileNames: `[name]${hash === true || hash === "async-only" ? `.[hash]` : ""}.js`,
275
+ assetFileNames: `[name]${hash === true ? `.[hash]` : ""}.[ext]`,
276
+ generatedCode: "es2015"
241
277
  }
242
278
  };
243
279
  }
244
280
  async function quiltAppServer({
245
- root: rootPath = process.cwd(),
281
+ root = process.cwd(),
246
282
  app,
247
283
  env,
248
284
  entry,
@@ -251,38 +287,39 @@ async function quiltAppServer({
251
287
  assets,
252
288
  output
253
289
  } = {}) {
254
- const root = resolveRoot(rootPath);
290
+ const project = Project.load(root);
255
291
  const mode = (typeof env === "object" ? env?.mode : env) ?? "production";
256
292
  const baseURL = assets?.baseURL ?? "/assets/";
257
293
  const assetsInline = assets?.inline ?? true;
258
294
  const bundle = output?.bundle;
259
295
  const minify = output?.minify ?? false;
260
- const hash = output?.hash ?? "async-only";
261
- const outputFormat = output?.format ?? "esmodules";
262
296
  const [
263
297
  { visualizer },
264
298
  { magicModuleEnv, replaceProcessEnv },
265
299
  { sourceCode },
266
- { createTSConfigAliasPlugin },
300
+ { react },
301
+ { tsconfigAliases },
302
+ { monorepoPackageAliases },
267
303
  { css },
268
304
  { rawAssets, staticAssets },
269
305
  { asyncModules },
270
306
  { esnext },
271
- nodePlugins,
272
- packageJSON
307
+ nodePlugins
273
308
  ] = await Promise.all([
274
309
  import('rollup-plugin-visualizer'),
275
310
  import('./features/env.mjs'),
276
311
  import('./features/source-code.mjs'),
312
+ import('./features/react.mjs'),
277
313
  import('./features/typescript.mjs'),
314
+ import('./features/node.mjs'),
278
315
  import('./features/css.mjs'),
279
316
  import('./features/assets.mjs'),
280
317
  import('./features/async.mjs'),
281
318
  import('./features/esnext.mjs'),
282
- getNodePlugins({ bundle }),
283
- loadPackageJSON(root)
319
+ getNodePlugins({ bundle })
284
320
  ]);
285
321
  const plugins = [
322
+ quiltAppServerInput({ root: project.root, entry, format }),
286
323
  ...nodePlugins,
287
324
  replaceProcessEnv({ mode }),
288
325
  magicModuleEnv({ ...resolveEnvOption(env), mode }),
@@ -302,6 +339,7 @@ async function quiltAppServer({
302
339
  }
303
340
  }
304
341
  }),
342
+ react(),
305
343
  esnext({
306
344
  mode,
307
345
  targets: ["current node"]
@@ -316,24 +354,20 @@ async function quiltAppServer({
316
354
  asyncModules({
317
355
  baseURL,
318
356
  preload: false,
319
- moduleID: ({ imported }) => path.relative(root, imported)
357
+ moduleID: ({ imported }) => path.relative(project.root, imported)
320
358
  }),
321
- removeBuildFiles(["build/server"], { root })
359
+ removeBuildFiles(["build/server"], { root: project.root }),
360
+ tsconfigAliases({ root: project.root }),
361
+ monorepoPackageAliases({ root: project.root })
322
362
  ];
323
- const tsconfigAliases = await createTSConfigAliasPlugin();
324
- if (tsconfigAliases) {
325
- plugins.push(tsconfigAliases);
326
- }
327
- const appEntry = await resolveAppEntry(app, { root, packageJSON });
363
+ const appEntry = await resolveAppEntry(app, project);
328
364
  if (appEntry) {
329
365
  plugins.push(magicModuleAppComponent({ entry: appEntry }));
330
366
  }
331
- const serverEntry = entry ? path.resolve(root, entry) : await glob("{server,service,backend}.{ts,tsx,mjs,js,jsx}", {
332
- cwd: root,
367
+ const serverEntry = entry ? project.resolve(entry) : await project.glob("{server,service,backend}.{ts,tsx,mjs,js,jsx}", {
333
368
  nodir: true,
334
369
  absolute: true
335
370
  }).then((files) => files[0]);
336
- const finalEntry = format === "request-router" ? MAGIC_MODULE_ENTRY : serverEntry ?? MAGIC_MODULE_ENTRY;
337
371
  plugins.push(
338
372
  magicModuleAppServerEntry({
339
373
  assets: { baseURL }
@@ -354,30 +388,34 @@ async function quiltAppServer({
354
388
  template: "treemap",
355
389
  open: false,
356
390
  brotliSize: false,
357
- filename: path.resolve(
358
- root,
359
- `build/reports/bundle-visualizer.server.html`
360
- )
391
+ filename: project.resolve(`build/reports/bundle-visualizer.server.html`)
361
392
  })
362
393
  );
394
+ return plugins;
395
+ }
396
+ function quiltAppServerInput({
397
+ root = process.cwd(),
398
+ entry,
399
+ format = "request-router"
400
+ } = {}) {
401
+ const project = Project.load(root);
363
402
  return {
364
- // If we are using the "magic entry", give it an explicit name of `server`.
365
- // Otherwise, Rollup will use the file name as the output name.
366
- input: finalEntry === MAGIC_MODULE_ENTRY ? { server: finalEntry } : finalEntry,
367
- plugins,
368
- onwarn(warning, defaultWarn) {
369
- if (warning.code === "MODULE_LEVEL_DIRECTIVE" && /['"]use client['"]/.test(warning.message)) {
370
- return;
403
+ name: "@quilted/app-server/input",
404
+ async options(options) {
405
+ let finalEntry = normalizeRollupInput(options.input);
406
+ if (!finalEntry) {
407
+ const serverEntry = entry ? project.resolve(entry) : await project.glob("{server,service,backend}.{ts,tsx,mjs,js,jsx}", {
408
+ nodir: true,
409
+ absolute: true
410
+ }).then((files) => files[0]);
411
+ finalEntry = format === "request-router" ? MAGIC_MODULE_ENTRY : serverEntry ?? MAGIC_MODULE_ENTRY;
371
412
  }
372
- defaultWarn(warning);
373
- },
374
- output: {
375
- format: outputFormat === "commonjs" || outputFormat === "cjs" ? "cjs" : "esm",
376
- dir: path.resolve(root, `build/server`),
377
- entryFileNames: `[name]${hash === true ? `.[hash]` : ""}.js`,
378
- chunkFileNames: `[name]${hash === true || hash === "async-only" ? `.[hash]` : ""}.js`,
379
- assetFileNames: `[name]${hash === true ? `.[hash]` : ""}.[ext]`,
380
- generatedCode: "es2015"
413
+ return {
414
+ ...options,
415
+ // If we are using the "magic entry", give it an explicit name of `server`.
416
+ // Otherwise, Rollup will use the file name as the output name.
417
+ input: finalEntry === MAGIC_MODULE_ENTRY ? { server: finalEntry } : finalEntry
418
+ };
381
419
  }
382
420
  };
383
421
  }
@@ -500,8 +538,8 @@ function magicModuleAppAssetManifests() {
500
538
  name: "@quilted/magic-module/asset-manifests",
501
539
  module: MAGIC_MODULE_BROWSER_ASSETS,
502
540
  async source() {
503
- const { glob: glob2 } = await import('glob');
504
- const manifestFiles = await glob2("assets*.json", {
541
+ const { glob } = await import('glob');
542
+ const manifestFiles = await glob("assets*.json", {
505
543
  nodir: true,
506
544
  absolute: true,
507
545
  cwd: path.resolve(`build/manifests`)
@@ -630,23 +668,23 @@ function createManualChunksSorter() {
630
668
  return `${bundleBaseName}-${relativeId.split(path.sep)[0]?.split(".")[0]}`;
631
669
  };
632
670
  }
633
- async function resolveAppEntry(entry, { root, packageJSON }) {
671
+ async function resolveAppEntry(entry, project) {
634
672
  if (entry) {
635
- return path.resolve(root, entry);
673
+ return project.resolve(entry);
636
674
  }
637
- if (typeof packageJSON.main === "string") {
638
- return path.resolve(root, packageJSON.main);
675
+ const { packageJSON } = project;
676
+ if (typeof packageJSON.raw.main === "string") {
677
+ return project.resolve(packageJSON.raw.main);
639
678
  }
640
- const rootEntry = packageJSON.exports?.["."];
679
+ const rootEntry = packageJSON.raw.exports?.["."];
641
680
  if (typeof rootEntry === "string") {
642
- return path.resolve(root, rootEntry);
681
+ return project.resolve(rootEntry);
643
682
  }
644
- const globbed = await glob("{App,app,index}.{ts,tsx,mjs,js,jsx}", {
645
- cwd: root,
683
+ const globbed = await project.glob("{App,app,index}.{ts,tsx,mjs,js,jsx}", {
646
684
  nodir: true,
647
685
  absolute: true
648
686
  });
649
687
  return globbed[0];
650
688
  }
651
689
 
652
- export { magicModuleAppAssetManifests, magicModuleAppBrowserEntry, magicModuleAppComponent, magicModuleAppRequestRouter, magicModuleAppServerEntry, quiltApp, quiltAppBrowser, quiltAppServer };
690
+ export { MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_BROWSER_ASSETS, MAGIC_MODULE_ENTRY, MAGIC_MODULE_REQUEST_ROUTER, magicModuleAppAssetManifests, magicModuleAppBrowserEntry, magicModuleAppComponent, magicModuleAppRequestRouter, magicModuleAppServerEntry, quiltAppBrowser, quiltAppBrowserInput, quiltAppBrowserOptions, quiltAppOptions, quiltAppServer, quiltAppServerInput, quiltAppServerOptions };
@@ -0,0 +1,57 @@
1
+ import { realpathSync } from 'node:fs';
2
+ import { Project, sourceEntriesForProject } from '../shared/project.mjs';
3
+
4
+ async function monorepoPackageAliases({
5
+ root = process.cwd()
6
+ } = {}) {
7
+ const project = Project.load(root);
8
+ const seenDependencies = /* @__PURE__ */ new Set();
9
+ const seenProjects = /* @__PURE__ */ new Set();
10
+ function processProject(project2) {
11
+ const { dependencies, devDependencies } = project2.packageJSON.raw;
12
+ for (const pkg of Object.keys({ ...dependencies, ...devDependencies })) {
13
+ if (seenDependencies.has(pkg))
14
+ continue;
15
+ seenDependencies.add(pkg);
16
+ let packageRoot;
17
+ try {
18
+ packageRoot = realpathSync(project2.resolve("node_modules", pkg));
19
+ } catch {
20
+ }
21
+ if (packageRoot == null || packageRoot.includes("node_modules") || packageRoot === root) {
22
+ continue;
23
+ }
24
+ const packageProject = Project.load(packageRoot);
25
+ if (seenProjects.has(packageProject))
26
+ continue;
27
+ seenProjects.add(packageProject);
28
+ processProject(packageProject);
29
+ }
30
+ }
31
+ processProject(project);
32
+ const [{ default: alias }, projectsWithEntries] = await Promise.all([
33
+ import('@rollup/plugin-alias'),
34
+ Promise.all(
35
+ Array.from(seenProjects, async (project2) => {
36
+ const entries = await sourceEntriesForProject(project2);
37
+ return { project: project2, entries };
38
+ })
39
+ )
40
+ ]);
41
+ const aliases = [];
42
+ for (const { project: project2, entries } of projectsWithEntries) {
43
+ const { name } = project2;
44
+ for (const [entry, source] of Object.entries(entries)) {
45
+ const entryName = entry === "." ? name : `${name}/${entry}`;
46
+ aliases.push({
47
+ find: new RegExp(`^${entryName}$`),
48
+ replacement: source
49
+ });
50
+ }
51
+ }
52
+ return alias({
53
+ entries: aliases
54
+ });
55
+ }
56
+
57
+ export { monorepoPackageAliases };
@@ -0,0 +1,22 @@
1
+ function react() {
2
+ return {
3
+ name: "@quilted/react",
4
+ options(options) {
5
+ return {
6
+ ...options,
7
+ onLog(level, log, handler) {
8
+ if (log.code === "MODULE_LEVEL_DIRECTIVE" && /['"]use client['"]/.test(log.message)) {
9
+ return;
10
+ }
11
+ if (options.onLog) {
12
+ options.onLog(level, log, handler);
13
+ } else {
14
+ handler(level, log);
15
+ }
16
+ }
17
+ };
18
+ }
19
+ };
20
+ }
21
+
22
+ export { react };
@@ -1,7 +1,7 @@
1
1
  import * as path from 'node:path';
2
2
  import * as fs from 'node:fs';
3
3
 
4
- async function createTSConfigAliasPlugin({
4
+ async function tsconfigAliases({
5
5
  root = process.cwd()
6
6
  } = {}) {
7
7
  const [{ default: alias }, tsconfig] = await Promise.all([
@@ -34,4 +34,4 @@ async function getTSConfig(root) {
34
34
  }
35
35
  }
36
36
 
37
- export { createTSConfigAliasPlugin };
37
+ export { tsconfigAliases };
@@ -1,4 +1,4 @@
1
- export { quiltApp, quiltAppBrowser, quiltAppServer } from './app.mjs';
1
+ export { quiltAppBrowser, quiltAppBrowserOptions, quiltAppOptions, quiltAppServer, quiltAppServerOptions } from './app.mjs';
2
2
  export { quiltModule } from './module.mjs';
3
3
  export { quiltPackage, quiltPackageESModules, quiltPackageESNext } from './package.mjs';
4
4
  export { quiltServer } from './server.mjs';