@quilted/rollup 0.2.18 → 0.2.20
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.
- package/CHANGELOG.md +12 -0
- package/build/esm/app.mjs +51 -27
- package/build/esm/module.mjs +7 -4
- package/build/esm/server.mjs +8 -5
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/app.d.ts +10 -16
- package/build/typescript/app.d.ts.map +1 -1
- package/build/typescript/module.d.ts.map +1 -1
- package/build/typescript/server.d.ts +2 -2
- package/build/typescript/server.d.ts.map +1 -1
- package/package.json +1 -1
- package/source/app.ts +73 -38
- package/source/module.ts +8 -4
- package/source/server.ts +11 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @quilted/rollup
|
|
2
2
|
|
|
3
|
+
## 0.2.20
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`545ec714`](https://github.com/lemonmade/quilt/commit/545ec714275700c550e6586c7a0490b1ee321b6d) Thanks [@lemonmade](https://github.com/lemonmade)! - Fix server output directory
|
|
8
|
+
|
|
9
|
+
## 0.2.19
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#675](https://github.com/lemonmade/quilt/pull/675) [`e7115258`](https://github.com/lemonmade/quilt/commit/e7115258241d9e049280224d205e2c40bb31d3ca) Thanks [@lemonmade](https://github.com/lemonmade)! - Improve output directories and names
|
|
14
|
+
|
|
3
15
|
## 0.2.18
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/build/esm/app.mjs
CHANGED
|
@@ -109,6 +109,9 @@ async function quiltAppBrowserPlugins({
|
|
|
109
109
|
const minify = assets?.minify ?? mode === "production";
|
|
110
110
|
const baseURL = assets?.baseURL ?? "/assets/";
|
|
111
111
|
const assetsInline = assets?.inline ?? true;
|
|
112
|
+
const assetsDirectory = project.resolve("build/assets");
|
|
113
|
+
const reportsDirectory = path.join(assetsDirectory, "../reports");
|
|
114
|
+
const manifestsDirectory = path.join(assetsDirectory, "../manifests");
|
|
112
115
|
const browserGroup = await getBrowserGroupTargetDetails(assets?.targets, {
|
|
113
116
|
root: project.root
|
|
114
117
|
});
|
|
@@ -190,7 +193,7 @@ async function quiltAppBrowserPlugins({
|
|
|
190
193
|
baseURL,
|
|
191
194
|
format: supportsModuleWorkers ? "module" : "classic",
|
|
192
195
|
outputOptions: {
|
|
193
|
-
dir:
|
|
196
|
+
dir: assetsDirectory,
|
|
194
197
|
entryFileNames: `[name]${targetFilenamePart}.[hash].js`,
|
|
195
198
|
assetFileNames: `[name]${targetFilenamePart}.[hash].[ext]`,
|
|
196
199
|
chunkFileNames: `[name]${targetFilenamePart}.[hash].js`
|
|
@@ -201,17 +204,21 @@ async function quiltAppBrowserPlugins({
|
|
|
201
204
|
];
|
|
202
205
|
if (assets?.clean ?? true) {
|
|
203
206
|
plugins.push(
|
|
204
|
-
removeBuildFiles(
|
|
205
|
-
|
|
206
|
-
|
|
207
|
+
removeBuildFiles(
|
|
208
|
+
[assetsDirectory, manifestsDirectory, reportsDirectory],
|
|
209
|
+
{
|
|
210
|
+
root: project.root
|
|
211
|
+
}
|
|
212
|
+
)
|
|
207
213
|
);
|
|
208
214
|
}
|
|
209
215
|
if (graphql) {
|
|
210
216
|
const { graphql: graphql2 } = await import('./features/graphql.mjs');
|
|
211
217
|
plugins.push(
|
|
212
218
|
graphql2({
|
|
213
|
-
manifest:
|
|
214
|
-
|
|
219
|
+
manifest: path.join(
|
|
220
|
+
manifestsDirectory,
|
|
221
|
+
`graphql${targetFilenamePart}.json`
|
|
215
222
|
)
|
|
216
223
|
})
|
|
217
224
|
);
|
|
@@ -228,15 +235,16 @@ async function quiltAppBrowserPlugins({
|
|
|
228
235
|
assetManifest({
|
|
229
236
|
baseURL,
|
|
230
237
|
cacheKey,
|
|
231
|
-
file:
|
|
238
|
+
file: path.join(manifestsDirectory, `assets${targetFilenamePart}.json`),
|
|
232
239
|
priority: assets?.priority
|
|
233
240
|
}),
|
|
234
241
|
visualizer({
|
|
235
242
|
template: "treemap",
|
|
236
243
|
open: false,
|
|
237
244
|
brotliSize: true,
|
|
238
|
-
filename:
|
|
239
|
-
|
|
245
|
+
filename: path.join(
|
|
246
|
+
reportsDirectory,
|
|
247
|
+
`bundle-visualizer${targetFilenamePart}.html`
|
|
240
248
|
)
|
|
241
249
|
})
|
|
242
250
|
);
|
|
@@ -250,11 +258,12 @@ function quiltAppBrowserInput({
|
|
|
250
258
|
name: "@quilted/app-browser/input",
|
|
251
259
|
async options(options) {
|
|
252
260
|
const finalEntry = normalizeRollupInput(options.input) ?? await sourceEntryForAppBrowser({ entry, root }) ?? MAGIC_MODULE_ENTRY;
|
|
261
|
+
const finalEntryName = typeof finalEntry === "string" && finalEntry !== MAGIC_MODULE_ENTRY ? path.basename(finalEntry).split(".").slice(0, -1).join(".") : "browser";
|
|
253
262
|
return {
|
|
254
263
|
...options,
|
|
255
264
|
// If we are using the "magic entry", give it an explicit name of `browser`.
|
|
256
265
|
// Otherwise, Rollup will use the file name as the output name.
|
|
257
|
-
input: finalEntry ===
|
|
266
|
+
input: typeof finalEntry === "string" ? { [finalEntryName]: finalEntry } : finalEntry
|
|
258
267
|
};
|
|
259
268
|
}
|
|
260
269
|
};
|
|
@@ -267,12 +276,13 @@ async function quiltAppServer(options = {}) {
|
|
|
267
276
|
} = options;
|
|
268
277
|
const project = Project.load(root);
|
|
269
278
|
const hash = output?.hash ?? "async-only";
|
|
279
|
+
const format = runtime.output?.format ?? "esm";
|
|
270
280
|
const plugins = await quiltAppServerPlugins({ ...options, root, runtime });
|
|
271
281
|
return {
|
|
272
282
|
plugins,
|
|
273
283
|
output: {
|
|
274
|
-
format: "esm",
|
|
275
|
-
dir: project.resolve(`build/server`),
|
|
284
|
+
format: format === "cjs" || format === "commonjs" ? "commonjs" : "esm",
|
|
285
|
+
dir: project.resolve(runtime.output?.directory ?? `build/server`),
|
|
276
286
|
entryFileNames: `[name]${hash === true ? `.[hash]` : ""}.js`,
|
|
277
287
|
chunkFileNames: `[name]${hash === true || hash === "async-only" ? `.[hash]` : ""}.js`,
|
|
278
288
|
assetFileNames: `[name]${hash === true ? `.[hash]` : ""}.[ext]`,
|
|
@@ -296,6 +306,10 @@ async function quiltAppServerPlugins({
|
|
|
296
306
|
const mode = (typeof env === "object" ? env?.mode : env) ?? "production";
|
|
297
307
|
const baseURL = assets?.baseURL ?? "/assets/";
|
|
298
308
|
const assetsInline = assets?.inline ?? true;
|
|
309
|
+
const outputDirectory = project.resolve(
|
|
310
|
+
runtime.output?.directory ?? "build/server"
|
|
311
|
+
);
|
|
312
|
+
const reportsDirectory = path.resolve(outputDirectory, "../reports");
|
|
299
313
|
const bundle = output?.bundle ?? runtime.output?.bundle;
|
|
300
314
|
const minify = output?.minify ?? false;
|
|
301
315
|
const [
|
|
@@ -378,7 +392,7 @@ async function quiltAppServerPlugins({
|
|
|
378
392
|
preload: false,
|
|
379
393
|
moduleID: ({ imported }) => path.relative(project.root, imported)
|
|
380
394
|
}),
|
|
381
|
-
removeBuildFiles([
|
|
395
|
+
removeBuildFiles([outputDirectory], { root: project.root }),
|
|
382
396
|
tsconfigAliases({ root: project.root }),
|
|
383
397
|
monorepoPackageAliases({ root: project.root })
|
|
384
398
|
];
|
|
@@ -395,7 +409,7 @@ async function quiltAppServerPlugins({
|
|
|
395
409
|
template: "treemap",
|
|
396
410
|
open: false,
|
|
397
411
|
brotliSize: false,
|
|
398
|
-
filename:
|
|
412
|
+
filename: path.join(reportsDirectory, `bundle-visualizer.server.html`)
|
|
399
413
|
})
|
|
400
414
|
);
|
|
401
415
|
return plugins;
|
|
@@ -405,23 +419,15 @@ function quiltAppServerInput({
|
|
|
405
419
|
entry,
|
|
406
420
|
format = "request-router"
|
|
407
421
|
} = {}) {
|
|
408
|
-
const project = Project.load(root);
|
|
409
422
|
return {
|
|
410
423
|
name: "@quilted/app-server/input",
|
|
411
424
|
async options(options) {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
nodir: true,
|
|
416
|
-
absolute: true
|
|
417
|
-
}).then((files) => files[0]);
|
|
418
|
-
finalEntry = format === "request-router" ? MAGIC_MODULE_ENTRY : serverEntry ?? MAGIC_MODULE_ENTRY;
|
|
419
|
-
}
|
|
425
|
+
const serverEntry = normalizeRollupInput(options.input) ?? await sourceEntryForAppServer({ entry, root });
|
|
426
|
+
const finalEntry = format === "request-router" ? MAGIC_MODULE_ENTRY : serverEntry ?? MAGIC_MODULE_ENTRY;
|
|
427
|
+
const finalEntryName = typeof serverEntry === "string" ? path.basename(serverEntry).split(".").slice(0, -1).join(".") : "server";
|
|
420
428
|
return {
|
|
421
429
|
...options,
|
|
422
|
-
|
|
423
|
-
// Otherwise, Rollup will use the file name as the output name.
|
|
424
|
-
input: finalEntry === MAGIC_MODULE_ENTRY ? { server: finalEntry } : finalEntry
|
|
430
|
+
input: typeof finalEntry === "string" ? { [finalEntryName]: finalEntry } : finalEntry
|
|
425
431
|
};
|
|
426
432
|
}
|
|
427
433
|
};
|
|
@@ -655,6 +661,24 @@ async function sourceEntryForAppBrowser({
|
|
|
655
661
|
return files[0];
|
|
656
662
|
}
|
|
657
663
|
}
|
|
664
|
+
async function sourceEntryForAppServer({
|
|
665
|
+
entry,
|
|
666
|
+
root = process.cwd()
|
|
667
|
+
}) {
|
|
668
|
+
const project = Project.load(root);
|
|
669
|
+
if (entry) {
|
|
670
|
+
return project.resolve(entry);
|
|
671
|
+
} else {
|
|
672
|
+
const files = await project.glob(
|
|
673
|
+
"{server,service,backend}.{ts,tsx,mjs,js,jsx}",
|
|
674
|
+
{
|
|
675
|
+
nodir: true,
|
|
676
|
+
absolute: true
|
|
677
|
+
}
|
|
678
|
+
);
|
|
679
|
+
return files[0];
|
|
680
|
+
}
|
|
681
|
+
}
|
|
658
682
|
const FRAMEWORK_CHUNK_NAME = "framework";
|
|
659
683
|
const POLYFILLS_CHUNK_NAME = "polyfills";
|
|
660
684
|
const VENDOR_CHUNK_NAME = "vendor";
|
|
@@ -731,4 +755,4 @@ function createManualChunksSorter() {
|
|
|
731
755
|
};
|
|
732
756
|
}
|
|
733
757
|
|
|
734
|
-
export { MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_BROWSER_ASSETS, MAGIC_MODULE_ENTRY, MAGIC_MODULE_REQUEST_ROUTER, magicModuleAppAssetManifests, magicModuleAppBrowserEntry, magicModuleAppComponent, magicModuleAppRequestRouter, nodeAppServerRuntime, quiltApp, quiltAppBrowser, quiltAppBrowserInput, quiltAppBrowserPlugins, quiltAppServer, quiltAppServerInput, quiltAppServerPlugins, sourceEntryForAppBrowser };
|
|
758
|
+
export { MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_BROWSER_ASSETS, MAGIC_MODULE_ENTRY, MAGIC_MODULE_REQUEST_ROUTER, magicModuleAppAssetManifests, magicModuleAppBrowserEntry, magicModuleAppComponent, magicModuleAppRequestRouter, nodeAppServerRuntime, quiltApp, quiltAppBrowser, quiltAppBrowserInput, quiltAppBrowserPlugins, quiltAppServer, quiltAppServerInput, quiltAppServerPlugins, sourceEntryForAppBrowser, sourceEntryForAppServer };
|
package/build/esm/module.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
1
2
|
import { Project, sourceEntriesForProject } from './shared/project.mjs';
|
|
2
3
|
import { getNodePlugins, removeBuildFiles } from './shared/rollup.mjs';
|
|
3
4
|
import { getBrowserGroupTargetDetails, rollupGenerateOptionsForBrowsers } from './shared/browserslist.mjs';
|
|
@@ -12,7 +13,8 @@ async function quiltModule({
|
|
|
12
13
|
} = {}) {
|
|
13
14
|
const project = Project.load(root);
|
|
14
15
|
const mode = (typeof env === "object" ? env?.mode : env) ?? "production";
|
|
15
|
-
const outputDirectory = project.resolve("build/
|
|
16
|
+
const outputDirectory = project.resolve("build/output");
|
|
17
|
+
const reportDirectory = path.join(outputDirectory, "../reports");
|
|
16
18
|
const minify = assets?.minify ?? true;
|
|
17
19
|
const hash = assets?.hash ?? "async-only";
|
|
18
20
|
const bundle = assets?.bundle ?? true;
|
|
@@ -60,7 +62,7 @@ async function quiltModule({
|
|
|
60
62
|
}
|
|
61
63
|
if (assets?.clean ?? true) {
|
|
62
64
|
plugins.push(
|
|
63
|
-
removeBuildFiles([
|
|
65
|
+
removeBuildFiles([outputDirectory, reportDirectory], {
|
|
64
66
|
root: project.root
|
|
65
67
|
})
|
|
66
68
|
);
|
|
@@ -70,8 +72,9 @@ async function quiltModule({
|
|
|
70
72
|
template: "treemap",
|
|
71
73
|
open: false,
|
|
72
74
|
brotliSize: true,
|
|
73
|
-
filename:
|
|
74
|
-
|
|
75
|
+
filename: path.join(
|
|
76
|
+
reportDirectory,
|
|
77
|
+
`bundle-visualizer${targetFilenamePart}.html`
|
|
75
78
|
)
|
|
76
79
|
})
|
|
77
80
|
);
|
package/build/esm/server.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
1
2
|
import { Project } from './shared/project.mjs';
|
|
2
3
|
import { getNodePlugins, removeBuildFiles } from './shared/rollup.mjs';
|
|
3
4
|
import { multiline } from './shared/strings.mjs';
|
|
4
5
|
import { resolveEnvOption } from './features/env.mjs';
|
|
5
|
-
import {
|
|
6
|
+
import { MAGIC_MODULE_REQUEST_ROUTER, MAGIC_MODULE_ENTRY } from './constants.mjs';
|
|
6
7
|
import { createMagicModulePlugin } from './shared/magic-module.mjs';
|
|
7
8
|
|
|
8
9
|
async function quiltServer({
|
|
@@ -17,8 +18,9 @@ async function quiltServer({
|
|
|
17
18
|
const project = Project.load(rootPath);
|
|
18
19
|
const mode = (typeof env === "object" ? env?.mode : void 0) ?? "production";
|
|
19
20
|
const outputDirectory = project.resolve(
|
|
20
|
-
output?.directory ?? runtime.output?.directory ?? "build/
|
|
21
|
+
output?.directory ?? runtime.output?.directory ?? "build/output"
|
|
21
22
|
);
|
|
23
|
+
const reportDirectory = path.resolve(outputDirectory, "../reports");
|
|
22
24
|
const minify = output?.minify ?? false;
|
|
23
25
|
const bundle = output?.bundle ?? runtime.output?.bundle;
|
|
24
26
|
const hash = output?.hash ?? "async-only";
|
|
@@ -43,6 +45,7 @@ async function quiltServer({
|
|
|
43
45
|
]);
|
|
44
46
|
const serverEntry = entry ? project.resolve(entry) : await sourceForServer(project);
|
|
45
47
|
const finalEntry = format === "request-router" ? MAGIC_MODULE_ENTRY : serverEntry ?? MAGIC_MODULE_ENTRY;
|
|
48
|
+
const finalEntryName = serverEntry ? path.basename(serverEntry).split(".").slice(0, -1).join(".") : "server";
|
|
46
49
|
const plugins = [
|
|
47
50
|
...nodePlugins,
|
|
48
51
|
replaceProcessEnv({ mode }),
|
|
@@ -57,7 +60,7 @@ async function quiltServer({
|
|
|
57
60
|
monorepoPackageAliases({ root: project.root }),
|
|
58
61
|
react(),
|
|
59
62
|
esnext({ mode, targets: ["current node"] }),
|
|
60
|
-
removeBuildFiles([
|
|
63
|
+
removeBuildFiles([outputDirectory, reportDirectory], { root: project.root })
|
|
61
64
|
];
|
|
62
65
|
if (format === "request-router") {
|
|
63
66
|
plugins.push(
|
|
@@ -89,11 +92,11 @@ async function quiltServer({
|
|
|
89
92
|
template: "treemap",
|
|
90
93
|
open: false,
|
|
91
94
|
brotliSize: true,
|
|
92
|
-
filename:
|
|
95
|
+
filename: path.join(reportDirectory, "bundle-visualizer.html")
|
|
93
96
|
})
|
|
94
97
|
);
|
|
95
98
|
return {
|
|
96
|
-
input:
|
|
99
|
+
input: { [finalEntryName]: finalEntry },
|
|
97
100
|
plugins,
|
|
98
101
|
output: {
|
|
99
102
|
format: "esm",
|