@quilted/rollup 0.2.2 → 0.2.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/build/esm/app.mjs +124 -65
  3. package/build/esm/features/react.mjs +22 -0
  4. package/build/esm/features/typescript.mjs +2 -2
  5. package/build/esm/index.mjs +1 -1
  6. package/build/esm/module.mjs +6 -6
  7. package/build/esm/server.mjs +7 -1
  8. package/build/esm/shared/browserslist.mjs +2 -1
  9. package/build/esm/shared/rollup.mjs +5 -12
  10. package/build/tsconfig.tsbuildinfo +1 -1
  11. package/build/typescript/app.d.ts +65 -15
  12. package/build/typescript/app.d.ts.map +1 -1
  13. package/build/typescript/features/react.d.ts +28 -0
  14. package/build/typescript/features/react.d.ts.map +1 -0
  15. package/build/typescript/features/typescript.d.ts +1 -1
  16. package/build/typescript/features/typescript.d.ts.map +1 -1
  17. package/build/typescript/index.d.ts +1 -1
  18. package/build/typescript/index.d.ts.map +1 -1
  19. package/build/typescript/module.d.ts +2 -3
  20. package/build/typescript/module.d.ts.map +1 -1
  21. package/build/typescript/server.d.ts +4 -2
  22. package/build/typescript/server.d.ts.map +1 -1
  23. package/build/typescript/shared/browserslist.d.ts.map +1 -1
  24. package/build/typescript/shared/rollup.d.ts +2 -1
  25. package/build/typescript/shared/rollup.d.ts.map +1 -1
  26. package/package.json +10 -1
  27. package/source/app.ts +167 -91
  28. package/source/features/react.ts +26 -0
  29. package/source/features/typescript.ts +1 -1
  30. package/source/index.ts +3 -1
  31. package/source/module.ts +8 -14
  32. package/source/server.ts +10 -2
  33. package/source/shared/browserslist.ts +3 -1
  34. package/source/shared/rollup.ts +6 -12
  35. package/tsconfig.json +1 -1
package/source/app.ts CHANGED
@@ -3,7 +3,12 @@ import * as fs from 'fs/promises';
3
3
  import {glob} from 'glob';
4
4
  import {createRequire} from 'module';
5
5
 
6
- import type {Plugin, RollupOptions, GetManualChunk} from 'rollup';
6
+ import type {
7
+ Plugin,
8
+ RollupOptions,
9
+ InputPluginOption,
10
+ GetManualChunk,
11
+ } from 'rollup';
7
12
  import type {AssetsBuildManifest} from '@quilted/assets';
8
13
 
9
14
  import {
@@ -18,6 +23,7 @@ import {multiline} from './shared/strings.ts';
18
23
  import {
19
24
  getNodePlugins,
20
25
  removeBuildFiles,
26
+ normalizeRollupInput,
21
27
  type RollupNodePluginOptions,
22
28
  } from './shared/rollup.ts';
23
29
  import {createMagicModulePlugin} from './shared/magic-module.ts';
@@ -218,9 +224,16 @@ export interface AppServerOutputOptions
218
224
  format?: 'esmodules' | 'esm' | 'es' | 'commonjs' | 'cjs';
219
225
  }
220
226
 
227
+ export {
228
+ MAGIC_MODULE_ENTRY,
229
+ MAGIC_MODULE_APP_COMPONENT,
230
+ MAGIC_MODULE_BROWSER_ASSETS,
231
+ MAGIC_MODULE_REQUEST_ROUTER,
232
+ };
233
+
221
234
  const require = createRequire(import.meta.url);
222
235
 
223
- export async function quiltApp({
236
+ export async function quiltAppOptions({
224
237
  root: rootPath = process.cwd(),
225
238
  app,
226
239
  env,
@@ -239,7 +252,7 @@ export async function quiltApp({
239
252
 
240
253
  browserGroupEntries.forEach(([name, browsers], index) => {
241
254
  optionPromises.push(
242
- quiltAppBrowser({
255
+ quiltAppBrowserOptions({
243
256
  root,
244
257
  app,
245
258
  graphql,
@@ -262,12 +275,15 @@ export async function quiltApp({
262
275
  });
263
276
 
264
277
  optionPromises.push(
265
- quiltAppServer({
278
+ quiltAppServerOptions({
266
279
  root,
267
280
  app,
268
281
  graphql,
269
282
  ...serverOptions,
270
- env: {...resolveEnvOption(env), ...resolveEnvOption(serverOptions?.env)},
283
+ env: {
284
+ ...resolveEnvOption(env),
285
+ ...resolveEnvOption(serverOptions?.env),
286
+ },
271
287
  assets: {...assets, ...serverOptions?.assets},
272
288
  }),
273
289
  );
@@ -275,6 +291,37 @@ export async function quiltApp({
275
291
  return Promise.all(optionPromises);
276
292
  }
277
293
 
294
+ export async function quiltAppBrowserOptions(options: AppBrowserOptions = {}) {
295
+ const {root: rootPath = process.cwd(), assets} = options;
296
+ const root = resolveRoot(rootPath);
297
+
298
+ const [plugins, browserGroup] = await Promise.all([
299
+ quiltAppBrowser(options),
300
+ getBrowserGroupTargetDetails(assets?.targets, {
301
+ root,
302
+ }),
303
+ ]);
304
+
305
+ const targetFilenamePart = browserGroup.name ? `.${browserGroup.name}` : '';
306
+ const [isESM, generatedCode] = await Promise.all([
307
+ targetsSupportModules(browserGroup.browsers),
308
+ rollupGenerateOptionsForBrowsers(browserGroup.browsers),
309
+ ]);
310
+
311
+ return {
312
+ plugins,
313
+ output: {
314
+ format: isESM ? 'esm' : 'systemjs',
315
+ dir: path.resolve(root, `build/assets`),
316
+ entryFileNames: `[name]${targetFilenamePart}.[hash].js`,
317
+ assetFileNames: `[name]${targetFilenamePart}.[hash].[ext]`,
318
+ chunkFileNames: `[name]${targetFilenamePart}.[hash].js`,
319
+ manualChunks: createManualChunksSorter(),
320
+ generatedCode,
321
+ },
322
+ } satisfies RollupOptions;
323
+ }
324
+
278
325
  export async function quiltAppBrowser({
279
326
  root: rootPath = process.cwd(),
280
327
  app,
@@ -299,7 +346,8 @@ export async function quiltAppBrowser({
299
346
  {visualizer},
300
347
  {magicModuleEnv, replaceProcessEnv},
301
348
  {sourceCode},
302
- {createTSConfigAliasPlugin},
349
+ {tsconfigAliases},
350
+ {react},
303
351
  {css},
304
352
  {assetManifest, rawAssets, staticAssets},
305
353
  {asyncModules},
@@ -313,6 +361,7 @@ export async function quiltAppBrowser({
313
361
  import('./features/env.ts'),
314
362
  import('./features/source-code.ts'),
315
363
  import('./features/typescript.ts'),
364
+ import('./features/react.ts'),
316
365
  import('./features/css.ts'),
317
366
  import('./features/assets.ts'),
318
367
  import('./features/async.ts'),
@@ -323,7 +372,8 @@ export async function quiltAppBrowser({
323
372
  loadPackageJSON(root),
324
373
  ]);
325
374
 
326
- const plugins: Plugin[] = [
375
+ const plugins: InputPluginOption[] = [
376
+ quiltAppBrowserInput({root, entry}),
327
377
  ...nodePlugins,
328
378
  systemJS({minify}),
329
379
  replaceProcessEnv({mode}),
@@ -345,11 +395,12 @@ export async function quiltAppBrowser({
345
395
  },
346
396
  },
347
397
  }),
398
+ react(),
399
+ css({minify, emit: true}),
348
400
  esnext({
349
401
  mode,
350
402
  targets: browserGroup.browsers,
351
403
  }),
352
- css({minify, emit: true}),
353
404
  rawAssets(),
354
405
  staticAssets({
355
406
  baseURL,
@@ -376,6 +427,7 @@ export async function quiltAppBrowser({
376
427
  chunkFileNames: `[name]${targetFilenamePart}.[hash].js`,
377
428
  },
378
429
  }),
430
+ tsconfigAliases({root}),
379
431
  ];
380
432
 
381
433
  if (assets?.clean ?? true) {
@@ -386,12 +438,6 @@ export async function quiltAppBrowser({
386
438
  );
387
439
  }
388
440
 
389
- const tsconfigAliases = await createTSConfigAliasPlugin();
390
-
391
- if (tsconfigAliases) {
392
- plugins.push(tsconfigAliases);
393
- }
394
-
395
441
  const appEntry = await resolveAppEntry(app, {root, packageJSON});
396
442
 
397
443
  if (appEntry) {
@@ -405,7 +451,10 @@ export async function quiltAppBrowser({
405
451
 
406
452
  plugins.push(
407
453
  graphql({
408
- manifest: path.resolve(`manifests/graphql${targetFilenamePart}.json`),
454
+ manifest: path.resolve(
455
+ root,
456
+ `build/manifests/graphql${targetFilenamePart}.json`,
457
+ ),
409
458
  }),
410
459
  );
411
460
  }
@@ -425,7 +474,10 @@ export async function quiltAppBrowser({
425
474
  assetManifest({
426
475
  baseURL,
427
476
  cacheKey,
428
- file: path.resolve(`build/manifests/assets${targetFilenamePart}.json`),
477
+ file: path.resolve(
478
+ root,
479
+ `build/manifests/assets${targetFilenamePart}.json`,
480
+ ),
429
481
  priority: assets?.priority,
430
482
  }),
431
483
  visualizer({
@@ -433,49 +485,69 @@ export async function quiltAppBrowser({
433
485
  open: false,
434
486
  brotliSize: true,
435
487
  filename: path.resolve(
488
+ root,
436
489
  `build/reports/bundle-visualizer${targetFilenamePart}.html`,
437
490
  ),
438
491
  }),
439
492
  );
440
493
 
441
- const finalEntry = entry
442
- ? path.resolve(root, entry)
443
- : (await glob('{browser,client,web}.{ts,tsx,mjs,js,jsx}', {
444
- cwd: root,
445
- nodir: true,
446
- absolute: true,
447
- }).then((files) => files[0])) ?? MAGIC_MODULE_ENTRY;
494
+ return plugins;
495
+ }
448
496
 
449
- const isESM = await targetsSupportModules(browserGroup.browsers);
497
+ export function quiltAppBrowserInput({
498
+ root: rootPath = process.cwd(),
499
+ entry,
500
+ }: Pick<AppBrowserOptions, 'root' | 'entry'> = {}) {
501
+ const root = resolveRoot(rootPath);
450
502
 
451
503
  return {
452
- // If we are using the "magic entry", give it an explicit name of `browser`.
453
- // Otherwise, Rollup will use the file name as the output name.
454
- input:
455
- finalEntry === MAGIC_MODULE_ENTRY ? {browser: finalEntry} : finalEntry,
456
- plugins,
457
- onwarn(warning, defaultWarn) {
458
- // Removes annoying warnings for React-focused libraries that
459
- // include 'use client' directives.
460
- if (
461
- warning.code === 'MODULE_LEVEL_DIRECTIVE' &&
462
- /['"]use client['"]/.test(warning.message)
463
- ) {
464
- return;
465
- }
466
-
467
- defaultWarn(warning);
504
+ name: '@quilted/app-browser/input',
505
+ async options(options) {
506
+ const finalEntry =
507
+ normalizeRollupInput(options.input) ??
508
+ (entry
509
+ ? path.resolve(root, entry)
510
+ : await glob('{browser,client,web}.{ts,tsx,mjs,js,jsx}', {
511
+ cwd: root,
512
+ nodir: true,
513
+ absolute: true,
514
+ }).then((files) => files[0])) ??
515
+ MAGIC_MODULE_ENTRY;
516
+
517
+ return {
518
+ ...options,
519
+ // If we are using the "magic entry", give it an explicit name of `browser`.
520
+ // Otherwise, Rollup will use the file name as the output name.
521
+ input:
522
+ finalEntry === MAGIC_MODULE_ENTRY
523
+ ? {browser: finalEntry}
524
+ : finalEntry,
525
+ };
468
526
  },
527
+ } satisfies Plugin;
528
+ }
529
+
530
+ export async function quiltAppServerOptions(options: AppServerOptions = {}) {
531
+ const {root: rootPath = process.cwd(), output} = options;
532
+
533
+ const root = resolveRoot(rootPath);
534
+ const hash = output?.hash ?? 'async-only';
535
+ const outputFormat = output?.format ?? 'esmodules';
536
+
537
+ const plugins = await quiltAppServer(options);
538
+
539
+ return {
540
+ plugins,
469
541
  output: {
470
- format: isESM ? 'esm' : 'systemjs',
471
- dir: path.resolve(root, `build/assets`),
472
- entryFileNames: `[name]${targetFilenamePart}.[hash].js`,
473
- assetFileNames: `[name]${targetFilenamePart}.[hash].[ext]`,
474
- chunkFileNames: `[name]${targetFilenamePart}.[hash].js`,
475
- manualChunks: createManualChunksSorter(),
476
- generatedCode: await rollupGenerateOptionsForBrowsers(
477
- browserGroup.browsers,
478
- ),
542
+ format:
543
+ outputFormat === 'commonjs' || outputFormat === 'cjs' ? 'cjs' : 'esm',
544
+ dir: path.resolve(root, `build/server`),
545
+ entryFileNames: `[name]${hash === true ? `.[hash]` : ''}.js`,
546
+ chunkFileNames: `[name]${
547
+ hash === true || hash === 'async-only' ? `.[hash]` : ''
548
+ }.js`,
549
+ assetFileNames: `[name]${hash === true ? `.[hash]` : ''}.[ext]`,
550
+ generatedCode: 'es2015',
479
551
  },
480
552
  } satisfies RollupOptions;
481
553
  }
@@ -498,14 +570,13 @@ export async function quiltAppServer({
498
570
 
499
571
  const bundle = output?.bundle;
500
572
  const minify = output?.minify ?? false;
501
- const hash = output?.hash ?? 'async-only';
502
- const outputFormat = output?.format ?? 'esmodules';
503
573
 
504
574
  const [
505
575
  {visualizer},
506
576
  {magicModuleEnv, replaceProcessEnv},
507
577
  {sourceCode},
508
- {createTSConfigAliasPlugin},
578
+ {react},
579
+ {tsconfigAliases},
509
580
  {css},
510
581
  {rawAssets, staticAssets},
511
582
  {asyncModules},
@@ -516,6 +587,7 @@ export async function quiltAppServer({
516
587
  import('rollup-plugin-visualizer'),
517
588
  import('./features/env.ts'),
518
589
  import('./features/source-code.ts'),
590
+ import('./features/react.ts'),
519
591
  import('./features/typescript.ts'),
520
592
  import('./features/css.ts'),
521
593
  import('./features/assets.ts'),
@@ -525,7 +597,8 @@ export async function quiltAppServer({
525
597
  loadPackageJSON(root),
526
598
  ]);
527
599
 
528
- const plugins: Plugin[] = [
600
+ const plugins: InputPluginOption[] = [
601
+ quiltAppServerInput({root, entry, format}),
529
602
  ...nodePlugins,
530
603
  replaceProcessEnv({mode}),
531
604
  magicModuleEnv({...resolveEnvOption(env), mode}),
@@ -545,6 +618,7 @@ export async function quiltAppServer({
545
618
  },
546
619
  },
547
620
  }),
621
+ react(),
548
622
  esnext({
549
623
  mode,
550
624
  targets: ['current node'],
@@ -566,14 +640,9 @@ export async function quiltAppServer({
566
640
  moduleID: ({imported}) => path.relative(root, imported),
567
641
  }),
568
642
  removeBuildFiles(['build/server'], {root}),
643
+ tsconfigAliases({root}),
569
644
  ];
570
645
 
571
- const tsconfigAliases = await createTSConfigAliasPlugin();
572
-
573
- if (tsconfigAliases) {
574
- plugins.push(tsconfigAliases);
575
- }
576
-
577
646
  const appEntry = await resolveAppEntry(app, {root, packageJSON});
578
647
 
579
648
  if (appEntry) {
@@ -588,11 +657,6 @@ export async function quiltAppServer({
588
657
  absolute: true,
589
658
  }).then((files) => files[0]);
590
659
 
591
- const finalEntry =
592
- format === 'request-router'
593
- ? MAGIC_MODULE_ENTRY
594
- : serverEntry ?? MAGIC_MODULE_ENTRY;
595
-
596
660
  plugins.push(
597
661
  magicModuleAppServerEntry({
598
662
  assets: {baseURL},
@@ -616,40 +680,52 @@ export async function quiltAppServer({
616
680
  template: 'treemap',
617
681
  open: false,
618
682
  brotliSize: false,
619
- filename: path.resolve(`build/reports/bundle-visualizer.server.html`),
683
+ filename: path.resolve(
684
+ root,
685
+ `build/reports/bundle-visualizer.server.html`,
686
+ ),
620
687
  }),
621
688
  );
622
689
 
690
+ return plugins;
691
+ }
692
+
693
+ export function quiltAppServerInput({
694
+ root: rootPath = process.cwd(),
695
+ entry,
696
+ format = 'request-router',
697
+ }: Pick<AppServerOptions, 'root' | 'entry' | 'format'> = {}) {
698
+ const root = resolveRoot(rootPath);
699
+
623
700
  return {
624
- // If we are using the "magic entry", give it an explicit name of `server`.
625
- // Otherwise, Rollup will use the file name as the output name.
626
- input:
627
- finalEntry === MAGIC_MODULE_ENTRY ? {server: finalEntry} : finalEntry,
628
- plugins,
629
- onwarn(warning, defaultWarn) {
630
- // Removes annoying warnings for React-focused libraries that
631
- // include 'use client' directives.
632
- if (
633
- warning.code === 'MODULE_LEVEL_DIRECTIVE' &&
634
- /['"]use client['"]/.test(warning.message)
635
- ) {
636
- return;
701
+ name: '@quilted/app-server/input',
702
+ async options(options) {
703
+ let finalEntry = normalizeRollupInput(options.input);
704
+
705
+ if (!finalEntry) {
706
+ const serverEntry = entry
707
+ ? path.resolve(root, entry)
708
+ : await glob('{server,service,backend}.{ts,tsx,mjs,js,jsx}', {
709
+ cwd: root,
710
+ nodir: true,
711
+ absolute: true,
712
+ }).then((files) => files[0]);
713
+
714
+ finalEntry =
715
+ format === 'request-router'
716
+ ? MAGIC_MODULE_ENTRY
717
+ : serverEntry ?? MAGIC_MODULE_ENTRY;
637
718
  }
638
719
 
639
- defaultWarn(warning);
640
- },
641
- output: {
642
- format:
643
- outputFormat === 'commonjs' || outputFormat === 'cjs' ? 'cjs' : 'esm',
644
- dir: path.resolve(`build/server`),
645
- entryFileNames: `[name]${hash === true ? `.[hash]` : ''}.js`,
646
- chunkFileNames: `[name]${
647
- hash === true || hash === 'async-only' ? `.[hash]` : ''
648
- }.js`,
649
- assetFileNames: `[name]${hash === true ? `.[hash]` : ''}.[ext]`,
650
- generatedCode: 'es2015',
720
+ return {
721
+ ...options,
722
+ // If we are using the "magic entry", give it an explicit name of `server`.
723
+ // Otherwise, Rollup will use the file name as the output name.
724
+ input:
725
+ finalEntry === MAGIC_MODULE_ENTRY ? {server: finalEntry} : finalEntry,
726
+ };
651
727
  },
652
- } satisfies RollupOptions;
728
+ } satisfies Plugin;
653
729
  }
654
730
 
655
731
  export function magicModuleAppComponent({entry}: {entry: string}) {
@@ -0,0 +1,26 @@
1
+ import type {Plugin} from 'rollup';
2
+
3
+ export function react() {
4
+ return {
5
+ name: '@quilted/react',
6
+ options(options) {
7
+ return {
8
+ ...options,
9
+ onLog(level, log, handler) {
10
+ if (
11
+ log.code === 'MODULE_LEVEL_DIRECTIVE' &&
12
+ /['"]use client['"]/.test(log.message)
13
+ ) {
14
+ return;
15
+ }
16
+
17
+ if (options.onLog) {
18
+ options.onLog(level, log, handler);
19
+ } else {
20
+ handler(level, log);
21
+ }
22
+ },
23
+ };
24
+ },
25
+ } satisfies Plugin;
26
+ }
@@ -1,7 +1,7 @@
1
1
  import * as path from 'path';
2
2
  import * as fs from 'fs';
3
3
 
4
- export async function createTSConfigAliasPlugin({
4
+ export async function tsconfigAliases({
5
5
  root = process.cwd(),
6
6
  }: {root?: string} = {}) {
7
7
  const [{default: alias}, tsconfig] = await Promise.all([
package/source/index.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  export {
2
- quiltApp,
2
+ quiltAppOptions,
3
3
  quiltAppBrowser,
4
+ quiltAppBrowserOptions,
4
5
  quiltAppServer,
6
+ quiltAppServerOptions,
5
7
  type AppOptions,
6
8
  type AppBaseOptions,
7
9
  type AppBrowserOptions,
package/source/module.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as path from 'path';
2
- import {Plugin, type RollupOptions} from 'rollup';
2
+ import {type InputPluginOption, type RollupOptions} from 'rollup';
3
3
  import {glob} from 'glob';
4
4
 
5
5
  import {resolveRoot} from './shared/path.ts';
@@ -86,6 +86,8 @@ export async function quiltModule({
86
86
  {visualizer},
87
87
  {magicModuleEnv, replaceProcessEnv},
88
88
  {sourceCode},
89
+ {tsconfigAliases},
90
+ {react},
89
91
  {esnext},
90
92
  nodePlugins,
91
93
  packageJSON,
@@ -93,6 +95,8 @@ export async function quiltModule({
93
95
  import('rollup-plugin-visualizer'),
94
96
  import('./features/env.ts'),
95
97
  import('./features/source-code.ts'),
98
+ import('./features/typescript.ts'),
99
+ import('./features/react.ts'),
96
100
  import('./features/esnext.ts'),
97
101
  getNodePlugins({bundle}),
98
102
  loadPackageJSON(root),
@@ -102,12 +106,14 @@ export async function quiltModule({
102
106
  ? path.resolve(root, entry)
103
107
  : await sourceForModule(root, packageJSON);
104
108
 
105
- const plugins: Plugin[] = [
109
+ const plugins: InputPluginOption[] = [
106
110
  ...nodePlugins,
107
111
  replaceProcessEnv({mode}),
108
112
  magicModuleEnv({...resolveEnvOption(env), mode}),
109
113
  sourceCode({mode, targets: browserGroup.browsers}),
114
+ tsconfigAliases({root}),
110
115
  esnext({mode, targets: browserGroup.browsers}),
116
+ react(),
111
117
  removeBuildFiles(['build/assets', 'build/reports'], {root}),
112
118
  ];
113
119
 
@@ -136,18 +142,6 @@ export async function quiltModule({
136
142
  return {
137
143
  input: finalEntry,
138
144
  plugins,
139
- onwarn(warning, defaultWarn) {
140
- // Removes annoying warnings for React-focused libraries that
141
- // include 'use client' directives.
142
- if (
143
- warning.code === 'MODULE_LEVEL_DIRECTIVE' &&
144
- /['"]use client['"]/.test(warning.message)
145
- ) {
146
- return;
147
- }
148
-
149
- defaultWarn(warning);
150
- },
151
145
  output: {
152
146
  format: 'esm',
153
147
  dir: outputDirectory,
package/source/server.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as path from 'path';
2
- import {Plugin, type RollupOptions} from 'rollup';
2
+ import {type InputPluginOption, type RollupOptions} from 'rollup';
3
3
  import {glob} from 'glob';
4
4
 
5
5
  import {
@@ -107,6 +107,8 @@ export interface ServerOutputOptions
107
107
  format?: 'esmodules' | 'esm' | 'es' | 'commonjs' | 'cjs';
108
108
  }
109
109
 
110
+ export {MAGIC_MODULE_ENTRY, MAGIC_MODULE_REQUEST_ROUTER};
111
+
110
112
  export async function quiltServer({
111
113
  root: rootPath = process.cwd(),
112
114
  entry,
@@ -131,6 +133,8 @@ export async function quiltServer({
131
133
  {visualizer},
132
134
  {magicModuleEnv, replaceProcessEnv},
133
135
  {sourceCode},
136
+ {tsconfigAliases},
137
+ {react},
134
138
  {esnext},
135
139
  nodePlugins,
136
140
  packageJSON,
@@ -138,6 +142,8 @@ export async function quiltServer({
138
142
  import('rollup-plugin-visualizer'),
139
143
  import('./features/env.ts'),
140
144
  import('./features/source-code.ts'),
145
+ import('./features/typescript.ts'),
146
+ import('./features/react.ts'),
141
147
  import('./features/esnext.ts'),
142
148
  getNodePlugins({bundle}),
143
149
  loadPackageJSON(root),
@@ -152,11 +158,13 @@ export async function quiltServer({
152
158
  ? MAGIC_MODULE_ENTRY
153
159
  : serverEntry ?? MAGIC_MODULE_ENTRY;
154
160
 
155
- const plugins: Plugin[] = [
161
+ const plugins: InputPluginOption[] = [
156
162
  ...nodePlugins,
157
163
  replaceProcessEnv({mode}),
158
164
  magicModuleEnv({...resolveEnvOption(env), mode}),
159
165
  sourceCode({mode, targets: ['current node']}),
166
+ tsconfigAliases({root}),
167
+ react(),
160
168
  esnext({mode, targets: ['current node']}),
161
169
  removeBuildFiles(['build/server', 'build/reports'], {root}),
162
170
  ];
@@ -30,7 +30,9 @@ export async function getBrowserGroupTargetDetails(
30
30
  return config[targetName] ?? ['defaults'];
31
31
  })());
32
32
 
33
- return {name: targets.name, browsers: browserslist(targetBrowsers)};
33
+ const browsers = browserslist(targetBrowsers);
34
+
35
+ return {name: targets.name, browsers};
34
36
  }
35
37
 
36
38
  export interface BrowserGroups {
@@ -1,7 +1,7 @@
1
1
  import * as fs from 'fs/promises';
2
2
  import {glob} from 'glob';
3
3
 
4
- import type {Plugin, InputOptions} from 'rollup';
4
+ import type {Plugin, InputOption, InputOptions} from 'rollup';
5
5
  import replace, {type RollupReplaceOptions} from '@rollup/plugin-replace';
6
6
 
7
7
  export function smartReplace(
@@ -39,6 +39,10 @@ export function removeBuildFiles(
39
39
  } satisfies Plugin;
40
40
  }
41
41
 
42
+ export function normalizeRollupInput(input?: InputOption) {
43
+ return Array.isArray(input) && input.length === 0 ? undefined : input;
44
+ }
45
+
42
46
  export interface RollupNodeBundle {
43
47
  readonly builtins?: boolean;
44
48
  readonly dependencies?: boolean;
@@ -139,17 +143,7 @@ export async function getNodePlugins({
139
143
  nodeResolve({
140
144
  preferBuiltins: true,
141
145
  dedupe: [],
142
- extensions: [
143
- '.ts',
144
- '.tsx',
145
- '.mts',
146
- '.mtsx',
147
- '.js',
148
- '.jsx',
149
- '.es6',
150
- '.es',
151
- '.mjs',
152
- ],
146
+ extensions: ['.ts', '.tsx', '.mts', '.mtsx', '.mjs', '.js', '.jsx'],
153
147
  exportConditions: [
154
148
  'esnext',
155
149
  'quilt:esnext',
package/tsconfig.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "extends": "@quilted/typescript/project.json",
2
+ "extends": "@quilted/craft/typescript/project.json",
3
3
  "compilerOptions": {
4
4
  "rootDir": "source",
5
5
  "outDir": "build/typescript"