@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
@@ -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,14 +1,11 @@
1
- import * as path from 'path';
2
- import {Plugin, type RollupOptions} from 'rollup';
3
- import {glob} from 'glob';
1
+ import {type InputPluginOption, type RollupOptions} from 'rollup';
4
2
 
5
- import {resolveRoot} from './shared/path.ts';
3
+ import {Project} from './shared/project.ts';
6
4
  import {
7
5
  RollupNodePluginOptions,
8
6
  getNodePlugins,
9
7
  removeBuildFiles,
10
8
  } from './shared/rollup.ts';
11
- import {loadPackageJSON, type PackageJSON} from './shared/package-json.ts';
12
9
  import {
13
10
  getBrowserGroupTargetDetails,
14
11
  rollupGenerateOptionsForBrowsers,
@@ -63,22 +60,22 @@ export interface ModuleAssetsOptions
63
60
  }
64
61
 
65
62
  export async function quiltModule({
66
- root: rootPath = process.cwd(),
63
+ root = process.cwd(),
67
64
  entry,
68
65
  env,
69
66
  assets,
70
67
  graphql = true,
71
68
  }: ModuleOptions = {}) {
72
- const root = resolveRoot(rootPath);
69
+ const project = Project.load(root);
73
70
  const mode = (typeof env === 'object' ? env?.mode : env) ?? 'production';
74
- const outputDirectory = path.join(root, 'build/assets');
71
+ const outputDirectory = project.resolve('build/assets');
75
72
 
76
73
  const minify = assets?.minify ?? true;
77
74
  const hash = assets?.hash ?? 'async-only';
78
75
  const bundle = assets?.bundle ?? true;
79
76
 
80
77
  const browserGroup = await getBrowserGroupTargetDetails(assets?.targets, {
81
- root,
78
+ root: project.root,
82
79
  });
83
80
  const targetFilenamePart = browserGroup.name ? `.${browserGroup.name}` : '';
84
81
 
@@ -86,29 +83,34 @@ export async function quiltModule({
86
83
  {visualizer},
87
84
  {magicModuleEnv, replaceProcessEnv},
88
85
  {sourceCode},
86
+ {tsconfigAliases},
87
+ {monorepoPackageAliases},
88
+ {react},
89
89
  {esnext},
90
90
  nodePlugins,
91
- packageJSON,
92
91
  ] = await Promise.all([
93
92
  import('rollup-plugin-visualizer'),
94
93
  import('./features/env.ts'),
95
94
  import('./features/source-code.ts'),
95
+ import('./features/typescript.ts'),
96
+ import('./features/node.ts'),
97
+ import('./features/react.ts'),
96
98
  import('./features/esnext.ts'),
97
99
  getNodePlugins({bundle}),
98
- loadPackageJSON(root),
99
100
  ]);
100
101
 
101
- const finalEntry = entry
102
- ? path.resolve(root, entry)
103
- : await sourceForModule(root, packageJSON);
102
+ const finalEntry = await resolveModuleEntry(entry, project);
104
103
 
105
- const plugins: Plugin[] = [
104
+ const plugins: InputPluginOption[] = [
106
105
  ...nodePlugins,
107
106
  replaceProcessEnv({mode}),
108
107
  magicModuleEnv({...resolveEnvOption(env), mode}),
109
108
  sourceCode({mode, targets: browserGroup.browsers}),
109
+ tsconfigAliases({root: project.root}),
110
+ monorepoPackageAliases({root: project.root}),
110
111
  esnext({mode, targets: browserGroup.browsers}),
111
- removeBuildFiles(['build/assets', 'build/reports'], {root}),
112
+ react(),
113
+ removeBuildFiles(['build/assets', 'build/reports'], {root: project.root}),
112
114
  ];
113
115
 
114
116
  if (graphql) {
@@ -126,8 +128,7 @@ export async function quiltModule({
126
128
  template: 'treemap',
127
129
  open: false,
128
130
  brotliSize: true,
129
- filename: path.resolve(
130
- root,
131
+ filename: project.resolve(
131
132
  `build/reports/bundle-visualizer${targetFilenamePart}.html`,
132
133
  ),
133
134
  }),
@@ -136,18 +137,6 @@ export async function quiltModule({
136
137
  return {
137
138
  input: finalEntry,
138
139
  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
140
  output: {
152
141
  format: 'esm',
153
142
  dir: outputDirectory,
@@ -167,19 +156,22 @@ export async function quiltModule({
167
156
  } satisfies RollupOptions;
168
157
  }
169
158
 
170
- async function sourceForModule(root: string, packageJSON: PackageJSON) {
171
- const {main, exports} = packageJSON;
159
+ async function resolveModuleEntry(entry: string | undefined, project: Project) {
160
+ if (entry) {
161
+ return project.resolve(entry);
162
+ }
163
+
164
+ const {main, exports} = project.packageJSON.raw;
172
165
 
173
166
  const entryFromPackageJSON = main ?? (exports as any)?.['.'];
174
167
 
175
168
  if (entryFromPackageJSON) {
176
- return path.resolve(root, entryFromPackageJSON);
169
+ return project.resolve(entryFromPackageJSON);
177
170
  }
178
171
 
179
- const possibleSourceFiles = await glob(
172
+ const possibleSourceFiles = await project.glob(
180
173
  '{index,module,entry,input}.{ts,tsx,mjs,js,jsx}',
181
174
  {
182
- cwd: root,
183
175
  nodir: true,
184
176
  absolute: true,
185
177
  },
package/source/package.ts CHANGED
@@ -4,16 +4,14 @@ import {exec as execCommand} from 'child_process';
4
4
  import {promisify} from 'util';
5
5
 
6
6
  import {Plugin, type RollupOptions, type OutputOptions} from 'rollup';
7
- import {glob} from 'glob';
8
7
 
9
8
  import {multiline} from './shared/strings.ts';
10
- import {resolveRoot} from './shared/path.ts';
9
+ import {Project, sourceEntriesForProject} from './shared/project.ts';
11
10
  import {
12
11
  getNodePlugins,
13
12
  removeBuildFiles,
14
13
  type RollupNodePluginOptions,
15
14
  } from './shared/rollup.ts';
16
- import {loadPackageJSON, type PackageJSON} from './shared/package-json.ts';
17
15
  import {
18
16
  getBrowserGroupTargetDetails,
19
17
  rollupGenerateOptionsForBrowsers,
@@ -128,7 +126,7 @@ export interface PackageOptions extends PackageESModuleOptions {
128
126
  }
129
127
 
130
128
  export async function quiltPackage({
131
- root: rootPath = process.cwd(),
129
+ root = process.cwd(),
132
130
  commonjs = false,
133
131
  esnext: explicitESNext,
134
132
  entries,
@@ -138,10 +136,8 @@ export async function quiltPackage({
138
136
  graphql = true,
139
137
  customize,
140
138
  }: PackageOptions = {}) {
141
- const root = resolveRoot(rootPath);
142
- const packageJSON = await loadPackageJSON(root);
143
- const resolvedEntries =
144
- entries ?? (await sourceEntriesForPackage(root, packageJSON));
139
+ const project = Project.load(root);
140
+ const resolvedEntries = entries ?? (await sourceEntriesForProject(project));
145
141
 
146
142
  const includeESNext =
147
143
  explicitESNext ?? Object.keys(resolvedEntries).length > 0;
@@ -173,37 +169,39 @@ export async function quiltPackage({
173
169
  }
174
170
 
175
171
  export async function quiltPackageESModules({
176
- root: rootPath = process.cwd(),
172
+ root = process.cwd(),
177
173
  commonjs = false,
178
174
  entries,
179
175
  executable = {},
180
- react,
176
+ react: useReact,
181
177
  bundle,
182
178
  graphql = true,
183
179
  customize,
184
180
  }: PackageESModuleOptions = {}) {
185
- const root = resolveRoot(rootPath);
186
- const outputDirectory = path.resolve(root, 'build/esm');
181
+ const project = Project.load(root);
182
+ const outputDirectory = project.resolve('build/esm');
187
183
  const hasExecutables = Object.keys(executable).length > 0;
188
184
 
189
- const [{sourceCode}, {esnext}, nodePlugins, packageJSON, browserGroup] =
185
+ const [{sourceCode}, {react}, {esnext}, nodePlugins, browserGroup] =
190
186
  await Promise.all([
191
187
  import('./features/source-code.ts'),
188
+ import('./features/react.ts'),
192
189
  import('./features/esnext.ts'),
193
190
  getNodePlugins({bundle}),
194
- loadPackageJSON(root),
195
- getBrowserGroupTargetDetails({name: 'default'}, {root}),
191
+ getBrowserGroupTargetDetails({name: 'default'}, {root: project.root}),
196
192
  ]);
197
193
 
198
- const resolvedEntries =
199
- entries ?? (await sourceEntriesForPackage(root, packageJSON));
194
+ const resolvedEntries = entries ?? (await sourceEntriesForProject(project));
200
195
  const hasEntries = Object.keys(resolvedEntries).length > 0;
201
196
 
202
- const source = sourceForEntries({...resolvedEntries, ...executable}, {root});
197
+ const source = sourceForEntries(
198
+ {...resolvedEntries, ...executable},
199
+ {root: project.root},
200
+ );
203
201
 
204
202
  const plugins: Plugin[] = [
205
203
  ...nodePlugins,
206
- sourceCode({mode: 'production', react}),
204
+ sourceCode({mode: 'production', react: useReact}),
207
205
  esnext({mode: 'production', babel: false}),
208
206
  removeBuildFiles(
209
207
  [
@@ -211,12 +209,16 @@ export async function quiltPackageESModules({
211
209
  ...(commonjs ? ['build/cjs'] : []),
212
210
  ...(hasExecutables ? ['bin'] : []),
213
211
  ],
214
- {root},
212
+ {root: project.root},
215
213
  ),
216
214
  ];
217
215
 
216
+ if (useReact) {
217
+ plugins.push(react());
218
+ }
219
+
218
220
  if (hasExecutables) {
219
- plugins.push(packageExecutables(executable, {root}));
221
+ plugins.push(packageExecutables(executable, {root: project.root}));
220
222
  }
221
223
 
222
224
  if (graphql) {
@@ -261,18 +263,6 @@ export async function quiltPackageESModules({
261
263
  const options = {
262
264
  input: source.files,
263
265
  plugins,
264
- onwarn(warning, defaultWarn) {
265
- // Removes annoying warnings for React-focused libraries that
266
- // include 'use client' directives.
267
- if (
268
- warning.code === 'MODULE_LEVEL_DIRECTIVE' &&
269
- /['"]use client['"]/.test(warning.message)
270
- ) {
271
- return;
272
- }
273
-
274
- defaultWarn(warning);
275
- },
276
266
  output,
277
267
  } satisfies RollupOptions;
278
268
 
@@ -319,35 +309,38 @@ export async function quiltPackageESModules({
319
309
  * ```
320
310
  */
321
311
  export async function quiltPackageESNext({
322
- root: rootPath = process.cwd(),
323
- react,
312
+ root = process.cwd(),
313
+ react: useReact,
324
314
  graphql = true,
325
315
  entries,
326
316
  bundle,
327
317
  customize,
328
318
  }: PackageBaseOptions = {}) {
329
- const root = resolveRoot(rootPath);
330
- const outputDirectory = path.join(root, 'build/esnext');
319
+ const project = Project.load(root);
320
+ const outputDirectory = project.resolve('build/esnext');
331
321
 
332
- const [{sourceCode}, {esnext}, nodePlugins, packageJSON] = await Promise.all([
322
+ const [{sourceCode}, {react}, {esnext}, nodePlugins] = await Promise.all([
333
323
  import('./features/source-code.ts'),
324
+ import('./features/react.ts'),
334
325
  import('./features/esnext.ts'),
335
326
  getNodePlugins({bundle}),
336
- loadPackageJSON(root),
337
327
  ]);
338
328
 
339
- const resolvedEntries =
340
- entries ?? (await sourceEntriesForPackage(root, packageJSON));
329
+ const resolvedEntries = entries ?? (await sourceEntriesForProject(project));
341
330
 
342
- const source = sourceForEntries(resolvedEntries, {root});
331
+ const source = sourceForEntries(resolvedEntries, {root: project.root});
343
332
 
344
333
  const plugins: Plugin[] = [
345
334
  ...nodePlugins,
346
- sourceCode({mode: 'production', babel: false, react}),
335
+ sourceCode({mode: 'production', babel: false, react: useReact}),
347
336
  esnext({mode: 'production', babel: false}),
348
- removeBuildFiles(['build/esnext'], {root}),
337
+ removeBuildFiles(['build/esnext'], {root: project.root}),
349
338
  ];
350
339
 
340
+ if (useReact) {
341
+ plugins.push(react());
342
+ }
343
+
351
344
  if (graphql) {
352
345
  const {graphql} = await import('./features/graphql.ts');
353
346
  plugins.push(graphql({manifest: false}));
@@ -505,68 +498,3 @@ function sourceForEntries(
505
498
 
506
499
  return {root: sourceRoot, files: sourceEntryFiles};
507
500
  }
508
-
509
- async function sourceEntriesForPackage(root: string, packageJSON: PackageJSON) {
510
- const {main, exports} = packageJSON;
511
-
512
- const entries: Record<string, string> = {};
513
-
514
- if (typeof main === 'string') {
515
- entries['.'] = await resolveTargetFileAsSource(main, root);
516
- }
517
-
518
- if (typeof exports === 'string') {
519
- entries['.'] = await resolveTargetFileAsSource(exports, root);
520
- return entries;
521
- } else if (exports == null || typeof exports !== 'object') {
522
- return entries;
523
- }
524
-
525
- for (const [exportPath, exportCondition] of Object.entries(
526
- exports as Record<string, null | string | Record<string, string>>,
527
- )) {
528
- let targetFile: string | null | undefined = null;
529
-
530
- if (exportCondition == null) continue;
531
-
532
- if (typeof exportCondition === 'string') {
533
- targetFile = exportCondition;
534
- } else {
535
- targetFile ??=
536
- exportCondition['source'] ??
537
- exportCondition['quilt:source'] ??
538
- exportCondition['quilt:esnext'] ??
539
- Object.values(exportCondition).find(
540
- (condition) =>
541
- typeof condition === 'string' && condition.startsWith('./build/'),
542
- );
543
- }
544
-
545
- if (targetFile == null) continue;
546
-
547
- const sourceFile = await resolveTargetFileAsSource(targetFile, root);
548
-
549
- entries[exportPath] = sourceFile;
550
- }
551
-
552
- return entries;
553
- }
554
-
555
- async function resolveTargetFileAsSource(file: string, root: string) {
556
- const sourceFile = file.includes('/build/')
557
- ? (
558
- await glob(
559
- file
560
- .replace(/[/]build[/][^/]+[/]/, '/*/')
561
- .replace(/(\.d\.ts|\.[\w]+)$/, '.*'),
562
- {
563
- cwd: root,
564
- absolute: true,
565
- ignore: [path.resolve(root, file)],
566
- },
567
- )
568
- )[0]!
569
- : path.resolve(root, file);
570
-
571
- return sourceFile;
572
- }
package/source/server.ts CHANGED
@@ -1,14 +1,12 @@
1
- import * as path from 'path';
2
- import {Plugin, type RollupOptions} from 'rollup';
3
- import {glob} from 'glob';
1
+ import {type InputPluginOption, type RollupOptions} from 'rollup';
4
2
 
3
+ import {Project} from './shared/project.ts';
5
4
  import {
6
5
  RollupNodePluginOptions,
7
6
  getNodePlugins,
8
7
  removeBuildFiles,
9
8
  } from './shared/rollup.ts';
10
- import {resolveRoot} from './shared/path.ts';
11
- import {loadPackageJSON, type PackageJSON} from './shared/package-json.ts';
9
+
12
10
  import {magicModuleRequestRouterEntry} from './features/request-router.ts';
13
11
  import {resolveEnvOption, type MagicModuleEnvOptions} from './features/env.ts';
14
12
  import {MAGIC_MODULE_ENTRY, MAGIC_MODULE_REQUEST_ROUTER} from './constants.ts';
@@ -107,6 +105,8 @@ export interface ServerOutputOptions
107
105
  format?: 'esmodules' | 'esm' | 'es' | 'commonjs' | 'cjs';
108
106
  }
109
107
 
108
+ export {MAGIC_MODULE_ENTRY, MAGIC_MODULE_REQUEST_ROUTER};
109
+
110
110
  export async function quiltServer({
111
111
  root: rootPath = process.cwd(),
112
112
  entry,
@@ -117,10 +117,10 @@ export async function quiltServer({
117
117
  port,
118
118
  host,
119
119
  }: ServerOptions = {}) {
120
- const root = resolveRoot(rootPath);
120
+ const project = Project.load(rootPath);
121
121
  const mode =
122
122
  (typeof env === 'object' ? env?.mode : undefined) ?? 'production';
123
- const outputDirectory = path.join(root, 'build/server');
123
+ const outputDirectory = project.resolve('build/server');
124
124
 
125
125
  const minify = output?.minify ?? false;
126
126
  const bundle = output?.bundle;
@@ -131,34 +131,41 @@ export async function quiltServer({
131
131
  {visualizer},
132
132
  {magicModuleEnv, replaceProcessEnv},
133
133
  {sourceCode},
134
+ {tsconfigAliases},
135
+ {monorepoPackageAliases},
136
+ {react},
134
137
  {esnext},
135
138
  nodePlugins,
136
- packageJSON,
137
139
  ] = await Promise.all([
138
140
  import('rollup-plugin-visualizer'),
139
141
  import('./features/env.ts'),
140
142
  import('./features/source-code.ts'),
143
+ import('./features/typescript.ts'),
144
+ import('./features/node.ts'),
145
+ import('./features/react.ts'),
141
146
  import('./features/esnext.ts'),
142
147
  getNodePlugins({bundle}),
143
- loadPackageJSON(root),
144
148
  ]);
145
149
 
146
150
  const serverEntry = entry
147
- ? path.resolve(root, entry)
148
- : await sourceForServer(root, packageJSON);
151
+ ? project.resolve(entry)
152
+ : await sourceForServer(project);
149
153
 
150
154
  const finalEntry =
151
155
  format === 'request-router'
152
156
  ? MAGIC_MODULE_ENTRY
153
157
  : serverEntry ?? MAGIC_MODULE_ENTRY;
154
158
 
155
- const plugins: Plugin[] = [
159
+ const plugins: InputPluginOption[] = [
156
160
  ...nodePlugins,
157
161
  replaceProcessEnv({mode}),
158
162
  magicModuleEnv({...resolveEnvOption(env), mode}),
159
163
  sourceCode({mode, targets: ['current node']}),
164
+ tsconfigAliases({root: project.root}),
165
+ monorepoPackageAliases({root: project.root}),
166
+ react(),
160
167
  esnext({mode, targets: ['current node']}),
161
- removeBuildFiles(['build/server', 'build/reports'], {root}),
168
+ removeBuildFiles(['build/server', 'build/reports'], {root: project.root}),
162
169
  ];
163
170
 
164
171
  if (format === 'request-router') {
@@ -190,7 +197,7 @@ export async function quiltServer({
190
197
  template: 'treemap',
191
198
  open: false,
192
199
  brotliSize: true,
193
- filename: path.resolve(root, `build/reports/bundle-visualizer.html`),
200
+ filename: project.resolve(`build/reports/bundle-visualizer.html`),
194
201
  }),
195
202
  );
196
203
 
@@ -198,18 +205,6 @@ export async function quiltServer({
198
205
  input:
199
206
  finalEntry === MAGIC_MODULE_ENTRY ? {server: finalEntry} : finalEntry,
200
207
  plugins,
201
- onwarn(warning, defaultWarn) {
202
- // Removes annoying warnings for React-focused libraries that
203
- // include 'use client' directives.
204
- if (
205
- warning.code === 'MODULE_LEVEL_DIRECTIVE' &&
206
- /['"]use client['"]/.test(warning.message)
207
- ) {
208
- return;
209
- }
210
-
211
- defaultWarn(warning);
212
- },
213
208
  output: {
214
209
  format:
215
210
  outputFormat === 'commonjs' || outputFormat === 'cjs' ? 'cjs' : 'esm',
@@ -224,19 +219,18 @@ export async function quiltServer({
224
219
  } satisfies RollupOptions;
225
220
  }
226
221
 
227
- async function sourceForServer(root: string, packageJSON: PackageJSON) {
228
- const {main, exports} = packageJSON;
222
+ async function sourceForServer(project: Project) {
223
+ const {main, exports} = project.packageJSON.raw;
229
224
 
230
225
  const entryFromPackageJSON = main ?? (exports as any)?.['.'];
231
226
 
232
227
  if (entryFromPackageJSON) {
233
- return path.resolve(root, entryFromPackageJSON);
228
+ return project.resolve(entryFromPackageJSON);
234
229
  }
235
230
 
236
- const possibleSourceFiles = await glob(
231
+ const possibleSourceFiles = await project.glob(
237
232
  '{index,server,service,backend,entry,input}.{ts,tsx,mjs,js,jsx}',
238
233
  {
239
- cwd: root,
240
234
  nodir: true,
241
235
  absolute: true,
242
236
  },
@@ -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 {