@quilted/rollup 0.2.45 → 0.2.47

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.
@@ -64,11 +64,72 @@ export interface AppBrowserOptions extends AppBaseOptions {
64
64
  * The entry module for this browser. This should be an absolute path, or relative
65
65
  * path from the root directory containing your project. This entry should be the
66
66
  * browser entrypoint. If you don’t provide a module, Quilt will automatically pick
67
- *
67
+ * a default entry module for you, based on the conventions [described here](TODO).
68
68
  *
69
69
  * @example './browser.tsx'
70
70
  */
71
71
  entry?: string;
72
+ /**
73
+ * Instead of providing a single `entry` module, you can use this option to list multiple
74
+ * independent entry modules for your browser application. This can be useful if you have
75
+ * parts of the codebase you want to load separately from one another; for example, as an
76
+ * inline script or style, or assets loaded inside an iframe rendered by the “main” part of
77
+ * the application.
78
+ *
79
+ * Entries should be defined similarly to how you would define the `exports` field in a Node.js
80
+ * [`package.json` file](https://nodejs.org/api/packages.html#exports). Keys should be prefixed
81
+ * with a `./`, and the key names can then be passed to Quilt’s `BrowserAssets` object to retrieve
82
+ * the built asset names on your server. The values should be relative paths to the source file
83
+ * that acts as the entrypoint for that asset. Entrypoints can be either JavaScript or CSS files.
84
+ *
85
+ * When using this option, you can override the “main” entrypoint by setting one of the keys
86
+ * of this object to the string: `'.'`. You can do this in addition to providing additional
87
+ * entry modules, but if you don’t provide the main entrypoint, a default will be used.
88
+ *
89
+ * @example
90
+ * ```js
91
+ * quiltApp({
92
+ * browser: {
93
+ * entry: {
94
+ * '.': './main.tsx',
95
+ * './inline.css': './inline.css',
96
+ * },
97
+ * },
98
+ * })
99
+ * ```
100
+ *
101
+ * To inline an asset, you can set the value to an object with a `source` property (for the relative
102
+ * path) and an `inline` option set to `true`. Note that this option will not inline dependencies of
103
+ * the entry into the asset manifest, so make sure that the way you load these scripts accounts for
104
+ * the fact that any dependencies will be loaded as external scripts. Because the whole file’s contents
105
+ * will be inlined into the asset manifest and server bundles, you should also be careful to only
106
+ * inline small JavaScript and CSS assets.
107
+ *
108
+ * @example
109
+ * ```js
110
+ * quiltApp({
111
+ * browser: {
112
+ * entry: {
113
+ * '.': './main.tsx',
114
+ * './inline.js': {source: './inline.tsx', inline: true},
115
+ * },
116
+ * },
117
+ * })
118
+ * ```
119
+ */
120
+ entries?: Record<string, string | {
121
+ /**
122
+ * The relative path to the source file that acts as the entrypoint for this asset.
123
+ */
124
+ source: string;
125
+ /**
126
+ * Whether to inline the asset into the asset manifest, so that it can be used as an
127
+ * inline script or style when rendering HTML content on the server.
128
+ *
129
+ * @default false
130
+ */
131
+ inline?: boolean;
132
+ }>;
72
133
  /**
73
134
  * Customizes the magic `quilt:module/entry` module, which can be used as a "magic"
74
135
  * entry for your application.
@@ -271,8 +332,8 @@ export declare function quiltAppBrowser(options?: AppBrowserOptions): Promise<{
271
332
  };
272
333
  preserveEntrySignatures: false;
273
334
  }>;
274
- export declare function quiltAppBrowserPlugins({ root, app, entry, env, assets, module, graphql, }?: AppBrowserOptions): Promise<InputPluginOption[]>;
275
- export declare function quiltAppBrowserInput({ root, entry, }?: Pick<AppBrowserOptions, 'root' | 'entry'>): {
335
+ export declare function quiltAppBrowserPlugins({ root, app, entry, entries, env, assets, module, graphql, }?: AppBrowserOptions): Promise<InputPluginOption[]>;
336
+ export declare function quiltAppBrowserInput({ root, entry, entries, }?: Pick<AppBrowserOptions, 'root' | 'entry' | 'entries'>): {
276
337
  name: string;
277
338
  options(this: import("rollup").MinimalPluginContext, options: import("rollup").InputOptions): Promise<{
278
339
  input: string[] | {
@@ -512,7 +573,8 @@ export declare function sourceEntryForAppBrowser({ entry, root, }: {
512
573
  entry?: string;
513
574
  root?: string | URL;
514
575
  }): Promise<string | undefined>;
515
- export declare function additionalEntriesForAppBrowser({ root, }: {
576
+ export declare function additionalEntriesForAppBrowser({ entries, root, }: {
577
+ entries?: AppBrowserOptions['entries'];
516
578
  root?: string | URL;
517
579
  }): Promise<Record<string, string>>;
518
580
  export declare function sourceEntryForAppServer({ entry,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AC,EAAE,MAAM,GAAG,GAAG,CAAC;CACrB;;;;;;;;;;EAoBA;AAED,wBAAgB,2BAA2B,CAAC,EAC1C,KAAK,EACL,IAAoB,GACrB,GAAE,IAAI,CAAC,gBAAgB,EAAE,OAAO,GAAG,MAAM,CAAM;;;;;;;;;;EAmC/C;AAED,wBAAgB,0BAA0B,CAAC,EACzC,OAAc,EACd,QAAiB,GAClB,GAAE,uBAA4B;;;;;;;;;;EAsB9B;AAED,wBAAgB,4BAA4B;;;;;;;;;;EAqE3C;AAED,wBAAsB,wBAAwB,CAAC,EAC7C,KAAK,EACL,IAAoB,GACrB,EAAE;IACD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;CACrB,+BAiDA;AAeD,wBAAsB,8BAA8B,CAAC,EACnD,OAAO,EACP,IAAoB,GACrB,EAAE;IACD,OAAO,CAAC,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAC;IACvC,IAAI,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;CACrB,mCAyCA;AAsBD,wBAAsB,uBAAuB,CAAC,EAC5C,KAAK,EACL,IAAoB,GACrB,EAAE;IACD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;CACrB,+BA8BA;AAED,wBAAsB,8BAA8B,CAAC,EACnD,KAAK,EACL,IAAoB,GACrB,EAAE;IACD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;CACrB,+BAgBA"}
@@ -4,6 +4,7 @@ export interface AssetManifestOptions {
4
4
  key?: URLSearchParams;
5
5
  base: string;
6
6
  priority?: number;
7
+ inline?: Set<string>;
7
8
  moduleID?(details: {
8
9
  imported: string;
9
10
  }): string;
@@ -1 +1 @@
1
- {"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../../source/features/assets.ts"],"names":[],"mappings":"AAIA,O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,MAAM,CAO3E;AA6ND,wBAAgB,SAAS,IAAI,MAAM,CAmBlC;AAED,wBAAgB,YAAY,CAAC,EAC3B,IAAW,EACX,OAAa,EACb,UAA4C,EAC5C,WAAkC,EAClC,aAAsC,GACvC,GAAE;IACD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;CACnB;;;EA+DL"}
@@ -2,6 +2,7 @@ export declare function systemJS({ minify }?: {
2
2
  minify?: boolean | undefined;
3
3
  }): {
4
4
  name: string;
5
+ buildStart(this: import("rollup").PluginContext): Promise<void>;
5
6
  renderChunk(this: import("rollup").PluginContext, code: string, chunk: import("rollup").RenderedChunk, options: import("rollup").NormalizedOutputOptions): Promise<{
6
7
  code: string;
7
8
  map: import("magic-string").SourceMap;
@@ -1 +1 @@
1
- {"version":3,"file":"system-js.d.ts","sourceRoot":"","sources":["../../../source/features/system-js.ts"],"names":[],"mappings":"AAQA,wBAAgB,QAAQ,CAAC,EAAC,MAAc,EAAC;;CAAK;;;;;;EAkD7C"}
1
+ {"version":3,"file":"system-js.d.ts","sourceRoot":"","sources":["../../../source/features/system-js.ts"],"names":[],"mappings":"AAQA,wBAAgB,QAAQ,CAAC,EAAC,MAAc,EAAC;;CAAK;;;;;;;EAkD7C"}
@@ -122,7 +122,7 @@ export declare function quiltPackage({ root, commonjs, esnext: explicitESNext, e
122
122
  generatedCode: "es2015";
123
123
  };
124
124
  } | {
125
- plugins: (false | void | Plugin<any> | import("rollup").InputPluginOption[] | Promise<false | import("rollup").NullValue | Plugin<any> | import("rollup").InputPluginOption[]> | null)[];
125
+ plugins: (false | void | Plugin<any> | import("rollup").InputPluginOption[] | Promise<false | Plugin<any> | import("rollup").NullValue | import("rollup").InputPluginOption[]> | null)[];
126
126
  output: OutputOptions | OutputOptions[] | {
127
127
  preserveModules: true;
128
128
  preserveModulesRoot: string;
@@ -193,7 +193,7 @@ export declare function quiltPackageESNext({ root, react: useReact, graphql, ent
193
193
  generatedCode: "es2015";
194
194
  };
195
195
  } | {
196
- plugins: (false | void | Plugin<any> | import("rollup").InputPluginOption[] | Promise<false | import("rollup").NullValue | Plugin<any> | import("rollup").InputPluginOption[]> | null)[];
196
+ plugins: (false | void | Plugin<any> | import("rollup").InputPluginOption[] | Promise<false | Plugin<any> | import("rollup").NullValue | import("rollup").InputPluginOption[]> | null)[];
197
197
  output: OutputOptions | OutputOptions[] | {
198
198
  preserveModules: true;
199
199
  preserveModulesRoot: string;
@@ -1 +1 @@
1
- {"version":3,"file":"browserslist.d.ts","sourceRoot":"","sources":["../../../source/shared/browserslist.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,2BAA2B,GACnC,SAAS,MAAM,EAAE,GACjB;IACE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9B,CAAC;AAEN,wBAAsB,4BAA4B,CAChD,eAAe,GAAE,2BAAgC,EACjD,EAAC,IAAI,EAAC,GAAE;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAM;;;GA0B7B;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;CACnC;AAED,wBAAsB,gBAAgB,CAAC,EACrC,IAAoB,GACrB,GAAE;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAwB/C;AAED,wBAAsB,iCAAiC,CACrD,MAAM,CAAC,EAAE,aAAa,GACrB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAuCjC;AAID,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,oBAYrE;AAmBD,wBAAsB,gCAAgC,CACpD,QAAQ,EAAE,SAAS,MAAM,EAAE;;;;;;;GA8C5B;AAED,wBAAsB,8BAA8B,CAClD,QAAQ,EAAE,SAAS,MAAM,EAAE,oBAe5B"}
1
+ {"version":3,"file":"browserslist.d.ts","sourceRoot":"","sources":["../../../source/shared/browserslist.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,2BAA2B,GACnC,SAAS,MAAM,EAAE,GACjB;IACE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9B,CAAC;AAEN,wBAAsB,4BAA4B,CAChD,eAAe,GAAE,2BAAgC,EACjD,EAAC,IAAI,EAAC,GAAE;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAM;;;GA0B7B;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;CACnC;AAED,wBAAsB,gBAAgB,CAAC,EACrC,IAAoB,GACrB,GAAE;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAwB/C;AAED,wBAAsB,iCAAiC,CACrD,MAAM,CAAC,EAAE,aAAa,GACrB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAuCjC;AAID,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,oBAYrE;AAmBD,wBAAsB,gCAAgC,CACpD,QAAQ,EAAE,SAAS,MAAM,EAAE;;;;;;;GA+C5B;AAED,wBAAsB,8BAA8B,CAClD,QAAQ,EAAE,SAAS,MAAM,EAAE,oBAgB5B"}
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "access": "public",
7
7
  "@quilted/registry": "https://registry.npmjs.org"
8
8
  },
9
- "version": "0.2.45",
9
+ "version": "0.2.47",
10
10
  "engines": {
11
11
  "node": ">=14.0.0"
12
12
  },
@@ -143,7 +143,7 @@
143
143
  "@rollup/plugin-commonjs": "^25.0.5",
144
144
  "@rollup/plugin-json": "^6.0.1",
145
145
  "@rollup/plugin-node-resolve": "^15.2.3",
146
- "@quilted/assets": "^0.1.4",
146
+ "@quilted/assets": "^0.1.8",
147
147
  "@quilted/babel": "^0.2.2",
148
148
  "@quilted/graphql": "^3.3.7",
149
149
  "@types/babel__preset-env": "^7.9.0",
package/source/app.ts CHANGED
@@ -112,12 +112,79 @@ export interface AppBrowserOptions extends AppBaseOptions {
112
112
  * The entry module for this browser. This should be an absolute path, or relative
113
113
  * path from the root directory containing your project. This entry should be the
114
114
  * browser entrypoint. If you don’t provide a module, Quilt will automatically pick
115
- *
115
+ * a default entry module for you, based on the conventions [described here](TODO).
116
116
  *
117
117
  * @example './browser.tsx'
118
118
  */
119
119
  entry?: string;
120
120
 
121
+ /**
122
+ * Instead of providing a single `entry` module, you can use this option to list multiple
123
+ * independent entry modules for your browser application. This can be useful if you have
124
+ * parts of the codebase you want to load separately from one another; for example, as an
125
+ * inline script or style, or assets loaded inside an iframe rendered by the “main” part of
126
+ * the application.
127
+ *
128
+ * Entries should be defined similarly to how you would define the `exports` field in a Node.js
129
+ * [`package.json` file](https://nodejs.org/api/packages.html#exports). Keys should be prefixed
130
+ * with a `./`, and the key names can then be passed to Quilt’s `BrowserAssets` object to retrieve
131
+ * the built asset names on your server. The values should be relative paths to the source file
132
+ * that acts as the entrypoint for that asset. Entrypoints can be either JavaScript or CSS files.
133
+ *
134
+ * When using this option, you can override the “main” entrypoint by setting one of the keys
135
+ * of this object to the string: `'.'`. You can do this in addition to providing additional
136
+ * entry modules, but if you don’t provide the main entrypoint, a default will be used.
137
+ *
138
+ * @example
139
+ * ```js
140
+ * quiltApp({
141
+ * browser: {
142
+ * entry: {
143
+ * '.': './main.tsx',
144
+ * './inline.css': './inline.css',
145
+ * },
146
+ * },
147
+ * })
148
+ * ```
149
+ *
150
+ * To inline an asset, you can set the value to an object with a `source` property (for the relative
151
+ * path) and an `inline` option set to `true`. Note that this option will not inline dependencies of
152
+ * the entry into the asset manifest, so make sure that the way you load these scripts accounts for
153
+ * the fact that any dependencies will be loaded as external scripts. Because the whole file’s contents
154
+ * will be inlined into the asset manifest and server bundles, you should also be careful to only
155
+ * inline small JavaScript and CSS assets.
156
+ *
157
+ * @example
158
+ * ```js
159
+ * quiltApp({
160
+ * browser: {
161
+ * entry: {
162
+ * '.': './main.tsx',
163
+ * './inline.js': {source: './inline.tsx', inline: true},
164
+ * },
165
+ * },
166
+ * })
167
+ * ```
168
+ */
169
+ entries?: Record<
170
+ string,
171
+ | string
172
+ | {
173
+ /**
174
+ * The relative path to the source file that acts as the entrypoint for this asset.
175
+ */
176
+ source: string;
177
+
178
+ /**
179
+ * Whether to inline the asset into the asset manifest, so that it can be used as an
180
+ * inline script or style when rendering HTML content on the server.
181
+ *
182
+ * @default false
183
+ */
184
+ inline?: boolean;
185
+ }
186
+ >;
187
+
121
188
  /**
122
189
  * Customizes the magic `quilt:module/entry` module, which can be used as a "magic"
123
190
  * entry for your application.
@@ -462,6 +529,7 @@ export async function quiltAppBrowserPlugins({
462
529
  root = process.cwd(),
463
530
  app,
464
531
  entry,
532
+ entries,
465
533
  env,
466
534
  assets,
467
535
  module,
@@ -496,6 +564,7 @@ export async function quiltAppBrowserPlugins({
496
564
  {workers},
497
565
  {esnext},
498
566
  nodePlugins,
567
+ supportsESM,
499
568
  supportsModuleWorkers,
500
569
  ] = await Promise.all([
501
570
  import('rollup-plugin-visualizer'),
@@ -514,13 +583,13 @@ export async function quiltAppBrowserPlugins({
514
583
  bundle: true,
515
584
  resolve: {exportConditions: ['browser']},
516
585
  }),
586
+ targetsSupportModules(browserGroup.browsers),
517
587
  targetsSupportModuleWebWorkers(browserGroup.browsers),
518
588
  ]);
519
589
 
520
590
  const plugins: InputPluginOption[] = [
521
- quiltAppBrowserInput({root: project.root, entry}),
591
+ quiltAppBrowserInput({root: project.root, entry, entries}),
522
592
  ...nodePlugins,
523
- systemJS({minify}),
524
593
  replaceProcessEnv({mode}),
525
594
  magicModuleEnv({...resolveEnvOption(env), mode, root: project.root}),
526
595
  magicModuleAppComponent({entry: app, root: project.root}),
@@ -577,6 +646,10 @@ export async function quiltAppBrowserPlugins({
577
646
  monorepoPackageAliases({root: project.root}),
578
647
  ];
579
648
 
649
+ if (!supportsESM) {
650
+ plugins.push(systemJS({minify}));
651
+ }
652
+
580
653
  if (assets?.clean ?? true) {
581
654
  plugins.push(
582
655
  removeBuildFiles(
@@ -612,12 +685,27 @@ export async function quiltAppBrowserPlugins({
612
685
  cacheKey.set('browserGroup', browserGroup.name);
613
686
  }
614
687
 
688
+ // Always inline the system.js entry, since we’ll load it as an inline script to avoid
689
+ // an unnecessary JS network waterfall for loading critical, SystemJS-dependent code.
690
+ // We’ll also add any additional entry that was passed via the `entries` option that is
691
+ // marked as being `inline`.
692
+ const inline = new Set(['system.js']);
693
+
694
+ if (entries) {
695
+ for (const [name, entry] of Object.entries(entries)) {
696
+ if (typeof entry === 'object' && entry.inline) {
697
+ inline.add(name.startsWith('./') ? name.slice(2) : name);
698
+ }
699
+ }
700
+ }
701
+
615
702
  plugins.push(
616
703
  assetManifest({
617
704
  key: cacheKey,
618
705
  base: baseURL,
619
706
  file: path.join(manifestsDirectory, `assets${targetFilenamePart}.json`),
620
707
  priority: assets?.priority,
708
+ inline,
621
709
  }),
622
710
  visualizer({
623
711
  template: 'treemap',
@@ -636,7 +724,8 @@ export async function quiltAppBrowserPlugins({
636
724
  export function quiltAppBrowserInput({
637
725
  root,
638
726
  entry,
639
- }: Pick<AppBrowserOptions, 'root' | 'entry'> = {}) {
727
+ entries,
728
+ }: Pick<AppBrowserOptions, 'root' | 'entry' | 'entries'> = {}) {
640
729
  const MODULES_TO_ENTRIES = new Map<string, string>();
641
730
 
642
731
  return {
@@ -644,13 +733,19 @@ export function quiltAppBrowserInput({
644
733
  async options(options) {
645
734
  const finalEntry =
646
735
  normalizeRollupInput(options.input) ??
647
- (await sourceEntryForAppBrowser({entry, root})) ??
736
+ (await sourceEntryForAppBrowser({
737
+ entry: entry ?? getSourceFromCustomEntry(entries?.['.']),
738
+ root,
739
+ })) ??
648
740
  MAGIC_MODULE_ENTRY;
649
741
  const finalEntryName =
650
742
  typeof finalEntry === 'string' && finalEntry !== MAGIC_MODULE_ENTRY
651
743
  ? path.basename(finalEntry).split('.').slice(0, -1).join('.')
652
744
  : 'browser';
653
- const additionalEntries = await additionalEntriesForAppBrowser({root});
745
+ const additionalEntries = await additionalEntriesForAppBrowser({
746
+ root,
747
+ entries,
748
+ });
654
749
 
655
750
  if (typeof finalEntry === 'string') {
656
751
  MODULES_TO_ENTRIES.set(finalEntry, '.');
@@ -1204,7 +1299,7 @@ export function magicModuleAppRequestRouter({
1204
1299
 
1205
1300
  import {jsx} from 'preact/jsx-runtime';
1206
1301
  import {RequestRouter} from '@quilted/quilt/request-router';
1207
- import {renderToResponse} from '@quilted/quilt/server';
1302
+ import {renderAppToHTMLResponse} from '@quilted/quilt/server';
1208
1303
 
1209
1304
  import App from ${JSON.stringify(MAGIC_MODULE_APP_COMPONENT)};
1210
1305
  import {BrowserAssets} from ${JSON.stringify(
@@ -1216,7 +1311,7 @@ export function magicModuleAppRequestRouter({
1216
1311
 
1217
1312
  // For all GET requests, render our React application.
1218
1313
  router.get(async (request) => {
1219
- const response = await renderToResponse(jsx(App), {
1314
+ const response = await renderAppToHTMLResponse(jsx(App), {
1220
1315
  request,
1221
1316
  assets,
1222
1317
  });
@@ -1399,8 +1494,10 @@ const SERVER_EXPORT_CONDITIONS = new Set([
1399
1494
  ]);
1400
1495
 
1401
1496
  export async function additionalEntriesForAppBrowser({
1497
+ entries,
1402
1498
  root = process.cwd(),
1403
1499
  }: {
1500
+ entries?: AppBrowserOptions['entries'];
1404
1501
  root?: string | URL;
1405
1502
  }) {
1406
1503
  const additionalEntries: Record<string, string> = {};
@@ -1428,6 +1525,20 @@ export async function additionalEntriesForAppBrowser({
1428
1525
  }
1429
1526
  }
1430
1527
 
1528
+ if (entries) {
1529
+ for (const [key, value] of Object.entries(entries)) {
1530
+ if (key === '.') continue;
1531
+
1532
+ const name = key.startsWith('./') ? key.slice(2) : key;
1533
+
1534
+ if (typeof value === 'string') {
1535
+ additionalEntries[name] = project.resolve(value);
1536
+ } else {
1537
+ additionalEntries[name] = project.resolve(value.source);
1538
+ }
1539
+ }
1540
+ }
1541
+
1431
1542
  return additionalEntries;
1432
1543
  }
1433
1544
 
@@ -1611,3 +1722,9 @@ function createManualChunksSorter(): GetManualChunk {
1611
1722
  return `${bundleBaseName}-${relativeId.split(path.sep)[0]?.split('.')[0]}`;
1612
1723
  };
1613
1724
  }
1725
+
1726
+ function getSourceFromCustomEntry(
1727
+ entry?: string | {source: string; inline?: boolean},
1728
+ ) {
1729
+ return typeof entry === 'object' ? entry.source : entry;
1730
+ }
@@ -19,6 +19,7 @@ export interface AssetManifestOptions {
19
19
  key?: URLSearchParams;
20
20
  base: string;
21
21
  priority?: number;
22
+ inline?: Set<string>;
22
23
  moduleID?(details: {imported: string}): string;
23
24
  }
24
25
 
@@ -38,6 +39,7 @@ async function writeManifestForBundle(
38
39
  file,
39
40
  base,
40
41
  key,
42
+ inline,
41
43
  priority,
42
44
  moduleID: getModuleID = defaultModuleID,
43
45
  }: AssetManifestOptions,
@@ -68,7 +70,7 @@ async function writeManifestForBundle(
68
70
  let id = assetIdMap.get(file);
69
71
 
70
72
  if (id == null) {
71
- assets.push(loadAsset(file, bundle[file]!));
73
+ assets.push(loadAsset(file, bundle[file]!, inline));
72
74
  id = assets.length - 1;
73
75
  assetIdMap.set(file, id);
74
76
  }
@@ -87,10 +89,20 @@ async function writeManifestForBundle(
87
89
  };
88
90
 
89
91
  for (const output of outputs) {
90
- if (
91
- output.type !== 'chunk' ||
92
- (!output.isDynamicEntry && !output.isEntry)
93
- ) {
92
+ if (output.type === 'asset') {
93
+ if (output.name && output.fileName.endsWith('.js')) {
94
+ manifest.modules[output.name] = createAssetsEntry([output.fileName], {
95
+ dependencyMap,
96
+ getAssetId,
97
+ });
98
+
99
+ manifest.entries[`./${output.name}`] = output.name;
100
+ }
101
+
102
+ continue;
103
+ }
104
+
105
+ if (!output.isDynamicEntry && !output.isEntry) {
94
106
  continue;
95
107
  }
96
108
 
@@ -111,9 +123,18 @@ async function writeManifestForBundle(
111
123
  manifest.entries[entry] = moduleID;
112
124
  }
113
125
 
126
+ const isCSS = moduleID.endsWith('.css');
127
+ const moduleFiles = [output.fileName, ...output.imports];
128
+
114
129
  manifest.modules[moduleID] = createAssetsEntry(
115
- [...output.imports, output.fileName],
116
- {dependencyMap, getAssetId},
130
+ // When an entrypoint is a CSS file, Rollup creates an unnecessary JavaScript file
131
+ // as the entrypoint of the module. We will exclude the JavaScript file, so only
132
+ // the CSS file is included in the final manifest.
133
+ isCSS ? moduleFiles.filter((file) => file.endsWith('.css')) : moduleFiles,
134
+ {
135
+ dependencyMap,
136
+ getAssetId,
137
+ },
117
138
  );
118
139
  }
119
140
 
@@ -128,17 +149,24 @@ const SRI_ALGORITHM = 'sha384';
128
149
  async function loadAsset(
129
150
  file: string,
130
151
  chunk: OutputChunk | OutputAsset,
152
+ inline?: Set<string>,
131
153
  ): Promise<AssetBuildAsset> {
132
154
  const asset: AssetBuildAsset = [file.endsWith('.css') ? 1 : 2, file];
133
155
 
134
- try {
135
- const hash = createHash(SRI_ALGORITHM)
136
- .update('code' in chunk ? chunk.code : chunk.source)
137
- .digest()
138
- .toString('base64');
156
+ const source = 'code' in chunk ? chunk.code : (chunk.source as string);
139
157
 
140
- asset[2] = `${SRI_ALGORITHM}-${hash}`;
141
- } catch {}
158
+ if (inline?.has(chunk.name!)) {
159
+ asset[2] = source;
160
+ } else {
161
+ try {
162
+ const hash = createHash(SRI_ALGORITHM)
163
+ .update('code' in chunk ? chunk.code : chunk.source)
164
+ .digest()
165
+ .toString('base64');
166
+
167
+ asset[2] = `${SRI_ALGORITHM}-${hash}`;
168
+ } catch {}
169
+ }
142
170
 
143
171
  return asset;
144
172
  }
@@ -9,29 +9,29 @@ import {multiline} from '../shared/strings';
9
9
  export function systemJS({minify = false} = {}) {
10
10
  return {
11
11
  name: '@quilted/system-js',
12
- async renderChunk(code, chunk, options) {
13
- if (options.format !== 'system' || !chunk.isEntry) return null;
14
12
 
13
+ async buildStart() {
15
14
  const require = createRequire(import.meta.url);
16
15
  const systemjs = minify
17
16
  ? require.resolve('systemjs/dist/s.min.js')
18
17
  : require.resolve('systemjs/dist/s.js');
19
18
 
20
- // We write the systemjs loader to a dedicated file, and we make it the
21
- // "first import" of the chunk so that it is the first file listed in
22
- // the manifest.
23
- const fileHandle = this.emitFile({
19
+ // We write the systemjs loader to a dedicated file
20
+ this.emitFile({
24
21
  type: 'asset',
25
- name: 'loader.js',
26
- source: (await readFile(systemjs, {encoding: 'utf8'})).replace(
27
- // Remove the source map comment, if it is present, because we don’t upload the
28
- // sourcemap for this file.
29
- /\n?[/][/]# sourceMappingURL=s.*\.map\n?$/,
30
- '',
31
- ),
22
+ name: 'system.js',
23
+ source: (await readFile(systemjs, {encoding: 'utf8'}))
24
+ .replace(
25
+ // Remove the source map comment, if it is present, because we don’t upload the
26
+ // sourcemap for this file.
27
+ /\n?[/][/]# sourceMappingURL=s.*\.map\n?$/m,
28
+ '',
29
+ )
30
+ .trim(),
32
31
  });
33
-
34
- chunk.imports.unshift(this.getFileName(fileHandle));
32
+ },
33
+ async renderChunk(code, chunk, options) {
34
+ if (options.format !== 'system' || !chunk.isEntry) return null;
35
35
 
36
36
  const newCode = new MagicString(code);
37
37
 
@@ -151,6 +151,7 @@ export async function rollupGenerateOptionsForBrowsers(
151
151
  import('semver'),
152
152
  import('@mdn/browser-compat-data', {
153
153
  assert: {type: 'json'},
154
+ with: {type: 'json'},
154
155
  }) as Promise<any>,
155
156
  ]);
156
157
 
@@ -200,6 +201,7 @@ export async function targetsSupportModuleWebWorkers(
200
201
  import('semver'),
201
202
  import('@mdn/browser-compat-data', {
202
203
  assert: {type: 'json'},
204
+ with: {type: 'json'},
203
205
  }) as Promise<any>,
204
206
  ]);
205
207