@quilted/rollup 0.1.19 → 0.2.1

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 (129) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/build/esm/app.mjs +450 -222
  3. package/build/esm/constants.mjs +5 -5
  4. package/build/esm/features/assets.mjs +93 -81
  5. package/build/esm/features/async.mjs +186 -0
  6. package/build/esm/features/css.mjs +26 -39
  7. package/build/esm/features/env.mjs +47 -44
  8. package/build/esm/features/esnext.mjs +57 -0
  9. package/build/esm/features/graphql/transform.mjs +60 -56
  10. package/build/esm/features/graphql.mjs +65 -47
  11. package/build/esm/features/request-router.mjs +6 -4
  12. package/build/esm/features/source-code.mjs +54 -28
  13. package/build/esm/features/system-js.mjs +29 -20
  14. package/build/esm/features/typescript.mjs +13 -10
  15. package/build/esm/features/workers.mjs +173 -0
  16. package/build/esm/index.mjs +3 -2
  17. package/build/esm/module.mjs +69 -62
  18. package/build/esm/package.mjs +275 -84
  19. package/build/esm/server.mjs +118 -0
  20. package/build/esm/shared/browserslist.mjs +141 -16
  21. package/build/esm/shared/magic-module.mjs +9 -7
  22. package/build/esm/shared/package-json.mjs +7 -1
  23. package/build/esm/shared/path.mjs +7 -0
  24. package/build/esm/shared/rollup.mjs +89 -25
  25. package/build/esm/shared/strings.mjs +7 -6
  26. package/build/tsconfig.tsbuildinfo +1 -1
  27. package/build/typescript/app.d.ts +132 -29
  28. package/build/typescript/app.d.ts.map +1 -1
  29. package/build/typescript/features/assets.d.ts +1 -2
  30. package/build/typescript/features/assets.d.ts.map +1 -1
  31. package/build/typescript/features/async.d.ts +10 -0
  32. package/build/typescript/features/async.d.ts.map +1 -0
  33. package/build/typescript/features/css.d.ts +2 -1
  34. package/build/typescript/features/css.d.ts.map +1 -1
  35. package/build/typescript/features/env.d.ts +1 -0
  36. package/build/typescript/features/env.d.ts.map +1 -1
  37. package/build/typescript/features/esnext.d.ts +9 -0
  38. package/build/typescript/features/esnext.d.ts.map +1 -0
  39. package/build/typescript/features/graphql.d.ts +2 -2
  40. package/build/typescript/features/graphql.d.ts.map +1 -1
  41. package/build/typescript/features/source-code.d.ts +9 -3
  42. package/build/typescript/features/source-code.d.ts.map +1 -1
  43. package/build/typescript/features/system-js.d.ts +4 -1
  44. package/build/typescript/features/system-js.d.ts.map +1 -1
  45. package/build/typescript/features/workers.d.ts +52 -0
  46. package/build/typescript/features/workers.d.ts.map +1 -0
  47. package/build/typescript/index.d.ts +3 -2
  48. package/build/typescript/index.d.ts.map +1 -1
  49. package/build/typescript/module.d.ts +24 -6
  50. package/build/typescript/module.d.ts.map +1 -1
  51. package/build/typescript/package.d.ts +196 -4
  52. package/build/typescript/package.d.ts.map +1 -1
  53. package/build/typescript/server.d.ts +98 -0
  54. package/build/typescript/server.d.ts.map +1 -0
  55. package/build/typescript/shared/browserslist.d.ts +20 -3
  56. package/build/typescript/shared/browserslist.d.ts.map +1 -1
  57. package/build/typescript/shared/path.d.ts +2 -0
  58. package/build/typescript/shared/path.d.ts.map +1 -0
  59. package/build/typescript/shared/rollup.d.ts +27 -1
  60. package/build/typescript/shared/rollup.d.ts.map +1 -1
  61. package/configuration/rollup.config.js +40 -0
  62. package/package.json +62 -9
  63. package/source/app.ts +475 -99
  64. package/source/features/assets.ts +5 -7
  65. package/source/features/async.ts +249 -0
  66. package/source/features/css.ts +4 -2
  67. package/source/features/env.ts +6 -0
  68. package/source/features/esnext.ts +70 -0
  69. package/source/features/graphql.ts +4 -2
  70. package/source/features/source-code.ts +27 -9
  71. package/source/features/system-js.ts +25 -2
  72. package/source/features/workers.ts +292 -0
  73. package/source/index.ts +4 -0
  74. package/source/module.ts +45 -19
  75. package/source/package.ts +394 -36
  76. package/source/server.ts +245 -0
  77. package/source/shared/browserslist.ts +208 -18
  78. package/source/shared/path.ts +5 -0
  79. package/source/shared/rollup.ts +102 -4
  80. package/tsconfig.json +6 -2
  81. package/build/cjs/app.cjs +0 -441
  82. package/build/cjs/constants.cjs +0 -13
  83. package/build/cjs/features/assets.cjs +0 -240
  84. package/build/cjs/features/css.cjs +0 -71
  85. package/build/cjs/features/env.cjs +0 -135
  86. package/build/cjs/features/graphql/transform.cjs +0 -186
  87. package/build/cjs/features/graphql.cjs +0 -86
  88. package/build/cjs/features/request-router.cjs +0 -31
  89. package/build/cjs/features/source-code.cjs +0 -54
  90. package/build/cjs/features/system-js.cjs +0 -36
  91. package/build/cjs/features/typescript.cjs +0 -56
  92. package/build/cjs/index.cjs +0 -13
  93. package/build/cjs/module.cjs +0 -121
  94. package/build/cjs/package.cjs +0 -170
  95. package/build/cjs/shared/browserslist.cjs +0 -25
  96. package/build/cjs/shared/magic-module.cjs +0 -32
  97. package/build/cjs/shared/package-json.cjs +0 -31
  98. package/build/cjs/shared/rollup.cjs +0 -72
  99. package/build/cjs/shared/strings.cjs +0 -16
  100. package/build/esnext/app.esnext +0 -414
  101. package/build/esnext/constants.esnext +0 -7
  102. package/build/esnext/features/assets.esnext +0 -215
  103. package/build/esnext/features/css.esnext +0 -69
  104. package/build/esnext/features/env.esnext +0 -112
  105. package/build/esnext/features/graphql/transform.esnext +0 -181
  106. package/build/esnext/features/graphql.esnext +0 -84
  107. package/build/esnext/features/request-router.esnext +0 -29
  108. package/build/esnext/features/source-code.esnext +0 -51
  109. package/build/esnext/features/system-js.esnext +0 -33
  110. package/build/esnext/features/typescript.esnext +0 -34
  111. package/build/esnext/index.esnext +0 -3
  112. package/build/esnext/module.esnext +0 -100
  113. package/build/esnext/package.esnext +0 -148
  114. package/build/esnext/shared/browserslist.esnext +0 -23
  115. package/build/esnext/shared/magic-module.esnext +0 -30
  116. package/build/esnext/shared/package-json.esnext +0 -10
  117. package/build/esnext/shared/rollup.esnext +0 -49
  118. package/build/esnext/shared/strings.esnext +0 -14
  119. package/build/typescript/env.d.ts +0 -55
  120. package/build/typescript/env.d.ts.map +0 -1
  121. package/build/typescript/graphql/transform.d.ts +0 -17
  122. package/build/typescript/graphql/transform.d.ts.map +0 -1
  123. package/build/typescript/graphql.d.ts +0 -6
  124. package/build/typescript/graphql.d.ts.map +0 -1
  125. package/build/typescript/request-router.d.ts +0 -15
  126. package/build/typescript/request-router.d.ts.map +0 -1
  127. package/build/typescript/shared/source-code.d.ts +0 -5
  128. package/build/typescript/shared/source-code.d.ts.map +0 -1
  129. package/quilt.project.ts +0 -5
@@ -0,0 +1,292 @@
1
+ import {posix} from 'path';
2
+ import {URLSearchParams} from 'url';
3
+
4
+ import {rollup} from 'rollup';
5
+ import type {
6
+ Plugin,
7
+ InputOptions,
8
+ OutputOptions,
9
+ OutputChunk,
10
+ NormalizedInputOptions,
11
+ } from 'rollup';
12
+
13
+ import {multiline} from '../shared/strings.ts';
14
+
15
+ const PREFIX = '\0quilt-worker:';
16
+ const ENTRY_PREFIX = '\0quilt-worker-entry:';
17
+ const MAGIC_MODULE_WORKER = 'quilt:module/worker.js';
18
+
19
+ export interface WorkerWrapper {
20
+ readonly module: string;
21
+ readonly function: string;
22
+ }
23
+
24
+ export interface WorkerContext {
25
+ readonly module: string;
26
+ readonly wrapper: WorkerWrapper;
27
+ }
28
+
29
+ export interface BaseURLContext extends WorkerContext {
30
+ readonly filename: string;
31
+ readonly chunk: OutputChunk;
32
+ readonly outputOptions: OutputOptions;
33
+ }
34
+
35
+ export type ValueOrGetter<T, Context extends WorkerContext = WorkerContext> =
36
+ | T
37
+ | ((context: Context) => T | Promise<T>);
38
+
39
+ export type ValueOrUpdateGetter<
40
+ T,
41
+ Context extends WorkerContext = WorkerContext,
42
+ > = T | ((current: T, context: Context) => T | Promise<T>);
43
+
44
+ export interface Options {
45
+ /**
46
+ * By default, this plugin uses `rollup().generate()` and attaches the
47
+ * resulting in-memory chunk to your main rollup build. When rolling rollup
48
+ * normally, this will output your asset to the file system when the main
49
+ * rollup build calls `write()`. Some tools that wrap rollup, like Vite, do
50
+ * don’t really call `write()`, so I can’t figure out how to make this approach
51
+ * work with them. In those instances, you can instead pass `write: true` here,
52
+ * which will then run `rollup().write()` on the worker bundle to actually output
53
+ * it to the filesystem (you can customize the output with the `outputOptions`
54
+ * option). You can then use the `baseURL()` option to control the URL that is
55
+ * generated for each worker module such that the tool is able to route that request
56
+ * to the written file. For example, in Vite, you can use the special `/@fs` prefix
57
+ * for a URL:
58
+ *
59
+ * ```ts
60
+ * import * as path from 'path';
61
+ *
62
+ * workers({
63
+ * write: true,
64
+ * baseURL({filename, outputOptions}) {
65
+ * return `/@fs${path.join(outputOptions.dir, filename)}`;
66
+ * },
67
+ * })
68
+ * ```
69
+ */
70
+ write?: ValueOrGetter<boolean>;
71
+ plugins?: ValueOrUpdateGetter<Plugin[]>;
72
+ inputOptions?: ValueOrUpdateGetter<InputOptions>;
73
+ outputOptions?: ValueOrUpdateGetter<OutputOptions>;
74
+ contentForWorker?: ValueOrGetter<string | undefined>;
75
+ baseURL?: ValueOrGetter<string | undefined, BaseURLContext>;
76
+ onIncludeFile?(file: string, worker: string): void;
77
+ }
78
+
79
+ export function workers({
80
+ write = false,
81
+ baseURL,
82
+ contentForWorker = defaultContentForWorker,
83
+ plugins = defaultPlugins,
84
+ inputOptions = {},
85
+ outputOptions = {},
86
+ onIncludeFile,
87
+ }: Options = {}): Plugin {
88
+ let parentInputOptions: NormalizedInputOptions;
89
+ const workerMap = new Map<string, OutputChunk>();
90
+
91
+ return {
92
+ name: '@quilted/workers',
93
+ buildStart(inputOptions) {
94
+ parentInputOptions = inputOptions;
95
+ },
96
+ async resolveId(source, importer) {
97
+ if (!source.startsWith(PREFIX)) return null;
98
+
99
+ const {workerId, wrapper} = getWorkerRequest(source.replace(PREFIX, ''));
100
+ const resolvedWorker = await this.resolve(workerId, importer, {
101
+ skipSelf: true,
102
+ });
103
+
104
+ if (resolvedWorker == null) return null;
105
+
106
+ return `${PREFIX}${resolvedWorker.id}${wrapperToSearchString(wrapper)}`;
107
+ },
108
+ async load(id) {
109
+ if (!id.startsWith(PREFIX)) return null;
110
+
111
+ const {workerId, wrapper} = getWorkerRequest(id.replace(PREFIX, ''));
112
+
113
+ const workerContext: WorkerContext = {module: workerId, wrapper};
114
+
115
+ const workerPlugins: Plugin[] = [
116
+ {
117
+ name: '@quilted/workers/magic-modules',
118
+ resolveId(source) {
119
+ if (source.startsWith(ENTRY_PREFIX)) {
120
+ return {id: source};
121
+ }
122
+
123
+ if (source === MAGIC_MODULE_WORKER) {
124
+ return {id: workerId};
125
+ }
126
+
127
+ return null;
128
+ },
129
+ async load(id) {
130
+ if (!id.startsWith(ENTRY_PREFIX)) return null;
131
+
132
+ const {wrapper, workerId} = getWorkerRequest(
133
+ id.replace(ENTRY_PREFIX, ''),
134
+ );
135
+
136
+ const context: WorkerContext = {module: workerId, wrapper};
137
+
138
+ const content =
139
+ typeof contentForWorker === 'function'
140
+ ? await contentForWorker(context)
141
+ : contentForWorker;
142
+ return content ?? defaultContentForWorker(context);
143
+ },
144
+ },
145
+ ...(typeof plugins === 'function'
146
+ ? await plugins(
147
+ [
148
+ ...(parentInputOptions.plugins?.filter(
149
+ (plugin): plugin is Plugin => Boolean(plugin),
150
+ ) ?? []),
151
+ ],
152
+ workerContext,
153
+ )
154
+ : plugins),
155
+ ];
156
+
157
+ const workerInput = `${ENTRY_PREFIX}${workerId}${wrapperToSearchString(
158
+ wrapper,
159
+ )}`;
160
+
161
+ const baseInputOptions: InputOptions = {
162
+ ...parentInputOptions,
163
+ input: workerInput,
164
+ plugins: workerPlugins,
165
+ };
166
+
167
+ const workerInputOptions =
168
+ typeof inputOptions === 'function'
169
+ ? await inputOptions(baseInputOptions, workerContext)
170
+ : baseInputOptions;
171
+
172
+ const baseOutputOptions: OutputOptions = {
173
+ format: 'iife',
174
+ inlineDynamicImports: true,
175
+ };
176
+
177
+ const workerOutputOptions =
178
+ typeof outputOptions === 'function'
179
+ ? await outputOptions(baseOutputOptions, workerContext)
180
+ : {...baseOutputOptions, ...outputOptions};
181
+
182
+ const shouldWrite =
183
+ typeof write === 'function' ? await write(workerContext) : write;
184
+
185
+ const bundle = await rollup(workerInputOptions);
186
+
187
+ const result = await (shouldWrite
188
+ ? bundle.write(workerOutputOptions)
189
+ : bundle.generate(workerOutputOptions));
190
+
191
+ const firstChunk = result.output.find(
192
+ (output): output is OutputChunk => output.type === 'chunk',
193
+ );
194
+
195
+ if (firstChunk == null) {
196
+ workerMap.delete(workerId);
197
+ return null;
198
+ }
199
+
200
+ workerMap.set(workerId, firstChunk);
201
+
202
+ for (const module of Object.keys(firstChunk.modules)) {
203
+ onIncludeFile?.(module, id);
204
+ this.addWatchFile(module);
205
+ }
206
+
207
+ const filename = firstChunk.fileName;
208
+ let resolvedBaseURL = filename;
209
+
210
+ if (typeof baseURL === 'string') {
211
+ resolvedBaseURL = posix.join(baseURL, filename);
212
+ } else if (typeof baseURL === 'function') {
213
+ const returnedBaseURL = await baseURL({
214
+ ...workerContext,
215
+ filename,
216
+ chunk: firstChunk,
217
+ outputOptions: workerOutputOptions,
218
+ });
219
+
220
+ if (returnedBaseURL) {
221
+ resolvedBaseURL = posix.join(returnedBaseURL, filename);
222
+ }
223
+ }
224
+
225
+ return `export default ${JSON.stringify(resolvedBaseURL)};`;
226
+ },
227
+ generateBundle(_, bundle) {
228
+ // We already wrote the chunks, no need to do it again I think?
229
+ if (write) return;
230
+
231
+ for (const chunk of workerMap.values()) {
232
+ if (chunk.fileName in bundle) continue;
233
+ bundle[chunk.fileName] = chunk;
234
+ }
235
+ },
236
+ };
237
+ }
238
+
239
+ function getWorkerRequest(id: string): {
240
+ workerId: string;
241
+ wrapper: WorkerWrapper;
242
+ } {
243
+ const [workerId, searchString] = id.split('?');
244
+ const searchParams = new URLSearchParams(searchString);
245
+ const wrapperModule = searchParams.get('module')!;
246
+ const wrapperFunction = searchParams.get('function')!;
247
+
248
+ return {
249
+ workerId: workerId!,
250
+ wrapper: {module: wrapperModule, function: wrapperFunction},
251
+ };
252
+ }
253
+
254
+ const workerFunctionContent = (pkg: string) =>
255
+ new Map([
256
+ ['createWorker', `import ${JSON.stringify(MAGIC_MODULE_WORKER)};`],
257
+ [
258
+ 'createThreadWorker',
259
+ multiline`
260
+ import {createThreadFromWebWorker} from ${JSON.stringify(pkg)};
261
+ import * as expose from ${JSON.stringify(MAGIC_MODULE_WORKER)};
262
+
263
+ createThreadFromWebWorker(self, {expose});
264
+ `,
265
+ ],
266
+ ]);
267
+
268
+ const KNOWN_WRAPPER_MODULES = new Map<string, Map<string, string>>([
269
+ ['@quilted/workers', workerFunctionContent('@quilted/workers')],
270
+ ['@quilted/react-workers', workerFunctionContent('@quilted/react-workers')],
271
+ ['@quilted/quilt/threads', workerFunctionContent('@quilted/quilt/threads')],
272
+ ]);
273
+
274
+ function defaultContentForWorker({wrapper}: WorkerContext) {
275
+ const content = KNOWN_WRAPPER_MODULES.get(wrapper.module)?.get(
276
+ wrapper.function,
277
+ );
278
+
279
+ if (content == null) {
280
+ throw new Error(`Unknown worker wrapper: ${JSON.stringify(wrapper)}`);
281
+ }
282
+
283
+ return content;
284
+ }
285
+
286
+ function defaultPlugins(mainBuildPlugins: Plugin[]) {
287
+ return mainBuildPlugins.filter((plugin) => plugin.name !== 'serve');
288
+ }
289
+
290
+ function wrapperToSearchString(wrapper: WorkerWrapper) {
291
+ return `?${new URLSearchParams(Object.entries(wrapper)).toString()}`;
292
+ }
package/source/index.ts CHANGED
@@ -1,13 +1,17 @@
1
1
  export {
2
+ quiltApp,
2
3
  quiltAppBrowser,
3
4
  quiltAppServer,
4
5
  type AppOptions,
6
+ type AppBaseOptions,
5
7
  type AppBrowserOptions,
6
8
  type AppServerOptions,
7
9
  } from './app.ts';
8
10
  export {quiltModule, type ModuleOptions} from './module.ts';
9
11
  export {
12
+ quiltPackage,
10
13
  quiltPackageESModules,
11
14
  quiltPackageESNext,
12
15
  type PackageOptions,
13
16
  } from './package.ts';
17
+ export {quiltServer, type ServerOptions} from './server.ts';
package/source/module.ts CHANGED
@@ -1,15 +1,20 @@
1
1
  import * as path from 'path';
2
2
  import {Plugin, type RollupOptions} from 'rollup';
3
3
  import {glob} from 'glob';
4
- import {fileURLToPath} from 'url';
5
4
 
6
- import {getNodePlugins, removeBuildFiles} from './shared/rollup.ts';
5
+ import {resolveRoot} from './shared/path.ts';
6
+ import {
7
+ RollupNodePluginOptions,
8
+ getNodePlugins,
9
+ removeBuildFiles,
10
+ } from './shared/rollup.ts';
7
11
  import {loadPackageJSON, type PackageJSON} from './shared/package-json.ts';
8
12
  import {
9
- getBrowserTargetDetails,
10
- type BrowserTargetSelection,
13
+ getBrowserGroupTargetDetails,
14
+ rollupGenerateOptionsForBrowsers,
15
+ type BrowserGroupTargetSelection,
11
16
  } from './shared/browserslist.ts';
12
- import type {MagicModuleEnvOptions} from './features/env.ts';
17
+ import {resolveEnvOption, type MagicModuleEnvOptions} from './features/env.ts';
13
18
 
14
19
  export interface ModuleOptions {
15
20
  /**
@@ -17,6 +22,16 @@ export interface ModuleOptions {
17
22
  */
18
23
  root?: string | URL;
19
24
 
25
+ /**
26
+ * The entry module for this module. This should be an absolute path, or relative
27
+ * path from the root directory containing your project. If not provided, this
28
+ * defaults the `main` or `exports['.']` field in your package.json, or a file named
29
+ * `index`, `module`, `entry`, or `input` in your project root.
30
+ *
31
+ * @example './my-module.tsx'
32
+ */
33
+ entry?: string;
34
+
20
35
  /**
21
36
  * Whether to include GraphQL-related code transformations.
22
37
  *
@@ -27,7 +42,7 @@ export interface ModuleOptions {
27
42
  /**
28
43
  * Customizes the behavior of environment variables for your module.
29
44
  */
30
- env?: MagicModuleEnvOptions;
45
+ env?: MagicModuleEnvOptions | MagicModuleEnvOptions['mode'];
31
46
 
32
47
  /**
33
48
  * Customizes the assets created for your module.
@@ -35,7 +50,8 @@ export interface ModuleOptions {
35
50
  assets?: ModuleAssetsOptions;
36
51
  }
37
52
 
38
- export interface ModuleAssetsOptions {
53
+ export interface ModuleAssetsOptions
54
+ extends Pick<RollupNodePluginOptions, 'bundle'> {
39
55
  /**
40
56
  * Whether to minify assets created for this module.
41
57
  *
@@ -43,48 +59,55 @@ export interface ModuleAssetsOptions {
43
59
  */
44
60
  minify?: boolean;
45
61
  hash?: boolean | 'async-only';
46
- targets?: BrowserTargetSelection;
62
+ targets?: BrowserGroupTargetSelection;
47
63
  }
48
64
 
49
65
  export async function quiltModule({
50
66
  root: rootPath = process.cwd(),
67
+ entry,
51
68
  env,
52
69
  assets,
53
70
  graphql = true,
54
71
  }: ModuleOptions = {}) {
55
- const root =
56
- typeof rootPath === 'string' ? rootPath : fileURLToPath(rootPath);
57
- const mode =
58
- (typeof env === 'object' ? env?.mode : undefined) ?? 'production';
72
+ const root = resolveRoot(rootPath);
73
+ const mode = (typeof env === 'object' ? env?.mode : env) ?? 'production';
59
74
  const outputDirectory = path.join(root, 'build/assets');
60
75
 
61
76
  const minify = assets?.minify ?? true;
62
77
  const hash = assets?.hash ?? 'async-only';
78
+ const bundle = assets?.bundle ?? true;
63
79
 
64
- const browserTarget = await getBrowserTargetDetails(assets?.targets, {root});
65
- const targetFilenamePart = browserTarget.name ? `.${browserTarget.name}` : '';
80
+ const browserGroup = await getBrowserGroupTargetDetails(assets?.targets, {
81
+ root,
82
+ });
83
+ const targetFilenamePart = browserGroup.name ? `.${browserGroup.name}` : '';
66
84
 
67
85
  const [
68
86
  {visualizer},
69
87
  {magicModuleEnv, replaceProcessEnv},
70
88
  {sourceCode},
89
+ {esnext},
71
90
  nodePlugins,
72
91
  packageJSON,
73
92
  ] = await Promise.all([
74
93
  import('rollup-plugin-visualizer'),
75
94
  import('./features/env.ts'),
76
95
  import('./features/source-code.ts'),
77
- getNodePlugins(),
96
+ import('./features/esnext.ts'),
97
+ getNodePlugins({bundle}),
78
98
  loadPackageJSON(root),
79
99
  ]);
80
100
 
81
- const source = await sourceForModule(root, packageJSON);
101
+ const finalEntry = entry
102
+ ? path.resolve(root, entry)
103
+ : await sourceForModule(root, packageJSON);
82
104
 
83
105
  const plugins: Plugin[] = [
84
106
  ...nodePlugins,
85
107
  replaceProcessEnv({mode}),
86
- magicModuleEnv({...env, mode}),
87
- sourceCode({mode: 'production', targets: browserTarget.browsers}),
108
+ magicModuleEnv({...resolveEnvOption(env), mode}),
109
+ sourceCode({mode, targets: browserGroup.browsers}),
110
+ esnext({mode, targets: browserGroup.browsers}),
88
111
  removeBuildFiles(['build/assets', 'build/reports'], {root}),
89
112
  ];
90
113
 
@@ -111,7 +134,7 @@ export async function quiltModule({
111
134
  );
112
135
 
113
136
  return {
114
- input: source,
137
+ input: finalEntry,
115
138
  plugins,
116
139
  onwarn(warning, defaultWarn) {
117
140
  // Removes annoying warnings for React-focused libraries that
@@ -137,6 +160,9 @@ export async function quiltModule({
137
160
  assetFileNames: `[name]${targetFilenamePart}${
138
161
  hash === true ? `.[hash]` : ''
139
162
  }.[ext]`,
163
+ generatedCode: await rollupGenerateOptionsForBrowsers(
164
+ browserGroup.browsers,
165
+ ),
140
166
  },
141
167
  } satisfies RollupOptions;
142
168
  }