@quilted/rollup 0.2.44 → 0.2.46
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 +18 -0
- package/build/esm/app.mjs +44 -9
- package/build/esm/features/assets.mjs +33 -9
- package/build/esm/features/system-js.mjs +8 -7
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/app.d.ts +67 -5
- package/build/typescript/app.d.ts.map +1 -1
- package/build/typescript/features/assets.d.ts +1 -0
- package/build/typescript/features/assets.d.ts.map +1 -1
- package/build/typescript/features/system-js.d.ts +1 -0
- package/build/typescript/features/system-js.d.ts.map +1 -1
- package/package.json +3 -3
- package/source/app.ts +125 -9
- package/source/features/assets.ts +42 -14
- package/source/features/system-js.ts +15 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @quilted/rollup
|
|
2
2
|
|
|
3
|
+
## 0.2.46
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`c421ad9`](https://github.com/lemonmade/quilt/commit/c421ad92ce5554d2b6b9c0b44f24378759dce5ab) Thanks [@lemonmade](https://github.com/lemonmade)! - Allow additional entries to be marked as inlined to include their content in the browser asset manifest
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`c421ad9`](https://github.com/lemonmade/quilt/commit/c421ad92ce5554d2b6b9c0b44f24378759dce5ab)]:
|
|
10
|
+
- @quilted/assets@0.1.8
|
|
11
|
+
|
|
12
|
+
## 0.2.45
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [`3a20ff9`](https://github.com/lemonmade/quilt/commit/3a20ff9101119d07bad8ddfbf414be4d3833c3b1) Thanks [@lemonmade](https://github.com/lemonmade)! - Simplify default async input equality check, and remove `dequal` as a framework dependency
|
|
17
|
+
|
|
18
|
+
- Updated dependencies []:
|
|
19
|
+
- @quilted/graphql@3.3.7
|
|
20
|
+
|
|
3
21
|
## 0.2.44
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/build/esm/app.mjs
CHANGED
|
@@ -122,6 +122,7 @@ async function quiltAppBrowserPlugins({
|
|
|
122
122
|
root = process.cwd(),
|
|
123
123
|
app,
|
|
124
124
|
entry,
|
|
125
|
+
entries,
|
|
125
126
|
env,
|
|
126
127
|
assets,
|
|
127
128
|
module,
|
|
@@ -153,6 +154,7 @@ async function quiltAppBrowserPlugins({
|
|
|
153
154
|
{ workers },
|
|
154
155
|
{ esnext },
|
|
155
156
|
nodePlugins,
|
|
157
|
+
supportsESM,
|
|
156
158
|
supportsModuleWorkers
|
|
157
159
|
] = await Promise.all([
|
|
158
160
|
import('rollup-plugin-visualizer'),
|
|
@@ -171,12 +173,12 @@ async function quiltAppBrowserPlugins({
|
|
|
171
173
|
bundle: true,
|
|
172
174
|
resolve: { exportConditions: ["browser"] }
|
|
173
175
|
}),
|
|
176
|
+
targetsSupportModules(browserGroup.browsers),
|
|
174
177
|
targetsSupportModuleWebWorkers(browserGroup.browsers)
|
|
175
178
|
]);
|
|
176
179
|
const plugins = [
|
|
177
|
-
quiltAppBrowserInput({ root: project.root, entry }),
|
|
180
|
+
quiltAppBrowserInput({ root: project.root, entry, entries }),
|
|
178
181
|
...nodePlugins,
|
|
179
|
-
systemJS({ minify }),
|
|
180
182
|
replaceProcessEnv({ mode }),
|
|
181
183
|
magicModuleEnv({ ...resolveEnvOption(env), mode, root: project.root }),
|
|
182
184
|
magicModuleAppComponent({ entry: app, root: project.root }),
|
|
@@ -228,6 +230,9 @@ async function quiltAppBrowserPlugins({
|
|
|
228
230
|
tsconfigAliases({ root: project.root }),
|
|
229
231
|
monorepoPackageAliases({ root: project.root })
|
|
230
232
|
];
|
|
233
|
+
if (!supportsESM) {
|
|
234
|
+
plugins.push(systemJS({ minify }));
|
|
235
|
+
}
|
|
231
236
|
if (assets?.clean ?? true) {
|
|
232
237
|
plugins.push(
|
|
233
238
|
removeBuildFiles(
|
|
@@ -257,12 +262,21 @@ async function quiltAppBrowserPlugins({
|
|
|
257
262
|
if (browserGroup.name) {
|
|
258
263
|
cacheKey.set("browserGroup", browserGroup.name);
|
|
259
264
|
}
|
|
265
|
+
const inline = /* @__PURE__ */ new Set(["system.js"]);
|
|
266
|
+
if (entries) {
|
|
267
|
+
for (const [name, entry2] of Object.entries(entries)) {
|
|
268
|
+
if (typeof entry2 === "object" && entry2.inline) {
|
|
269
|
+
inline.add(name.startsWith("./") ? name.slice(2) : name);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
260
273
|
plugins.push(
|
|
261
274
|
assetManifest({
|
|
262
275
|
key: cacheKey,
|
|
263
276
|
base: baseURL,
|
|
264
277
|
file: path.join(manifestsDirectory, `assets${targetFilenamePart}.json`),
|
|
265
|
-
priority: assets?.priority
|
|
278
|
+
priority: assets?.priority,
|
|
279
|
+
inline
|
|
266
280
|
}),
|
|
267
281
|
visualizer({
|
|
268
282
|
template: "treemap",
|
|
@@ -278,15 +292,22 @@ async function quiltAppBrowserPlugins({
|
|
|
278
292
|
}
|
|
279
293
|
function quiltAppBrowserInput({
|
|
280
294
|
root,
|
|
281
|
-
entry
|
|
295
|
+
entry,
|
|
296
|
+
entries
|
|
282
297
|
} = {}) {
|
|
283
298
|
const MODULES_TO_ENTRIES = /* @__PURE__ */ new Map();
|
|
284
299
|
return {
|
|
285
300
|
name: "@quilted/app-browser/input",
|
|
286
301
|
async options(options) {
|
|
287
|
-
const finalEntry = normalizeRollupInput(options.input) ?? await sourceEntryForAppBrowser({
|
|
302
|
+
const finalEntry = normalizeRollupInput(options.input) ?? await sourceEntryForAppBrowser({
|
|
303
|
+
entry: entry ?? getSourceFromCustomEntry(entries?.["."]),
|
|
304
|
+
root
|
|
305
|
+
}) ?? MAGIC_MODULE_ENTRY;
|
|
288
306
|
const finalEntryName = typeof finalEntry === "string" && finalEntry !== MAGIC_MODULE_ENTRY ? path.basename(finalEntry).split(".").slice(0, -1).join(".") : "browser";
|
|
289
|
-
const additionalEntries = await additionalEntriesForAppBrowser({
|
|
307
|
+
const additionalEntries = await additionalEntriesForAppBrowser({
|
|
308
|
+
root,
|
|
309
|
+
entries
|
|
310
|
+
});
|
|
290
311
|
if (typeof finalEntry === "string") {
|
|
291
312
|
MODULES_TO_ENTRIES.set(finalEntry, ".");
|
|
292
313
|
}
|
|
@@ -721,7 +742,7 @@ function magicModuleAppRequestRouter({
|
|
|
721
742
|
|
|
722
743
|
import {jsx} from 'preact/jsx-runtime';
|
|
723
744
|
import {RequestRouter} from '@quilted/quilt/request-router';
|
|
724
|
-
import {
|
|
745
|
+
import {renderAppToHTMLResponse} from '@quilted/quilt/server';
|
|
725
746
|
|
|
726
747
|
import App from ${JSON.stringify(MAGIC_MODULE_APP_COMPONENT)};
|
|
727
748
|
import {BrowserAssets} from ${JSON.stringify(
|
|
@@ -733,7 +754,7 @@ function magicModuleAppRequestRouter({
|
|
|
733
754
|
|
|
734
755
|
// For all GET requests, render our React application.
|
|
735
756
|
router.get(async (request) => {
|
|
736
|
-
const response = await
|
|
757
|
+
const response = await renderAppToHTMLResponse(jsx(App), {
|
|
737
758
|
request,
|
|
738
759
|
assets,
|
|
739
760
|
});
|
|
@@ -883,6 +904,7 @@ const SERVER_EXPORT_CONDITIONS = /* @__PURE__ */ new Set([
|
|
|
883
904
|
"default"
|
|
884
905
|
]);
|
|
885
906
|
async function additionalEntriesForAppBrowser({
|
|
907
|
+
entries,
|
|
886
908
|
root = process.cwd()
|
|
887
909
|
}) {
|
|
888
910
|
const additionalEntries = {};
|
|
@@ -902,6 +924,17 @@ async function additionalEntriesForAppBrowser({
|
|
|
902
924
|
}
|
|
903
925
|
}
|
|
904
926
|
}
|
|
927
|
+
if (entries) {
|
|
928
|
+
for (const [key, value] of Object.entries(entries)) {
|
|
929
|
+
if (key === ".") continue;
|
|
930
|
+
const name = key.startsWith("./") ? key.slice(2) : key;
|
|
931
|
+
if (typeof value === "string") {
|
|
932
|
+
additionalEntries[name] = project.resolve(value);
|
|
933
|
+
} else {
|
|
934
|
+
additionalEntries[name] = project.resolve(value.source);
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
}
|
|
905
938
|
return additionalEntries;
|
|
906
939
|
}
|
|
907
940
|
function resolveExportsField(project, entry, conditions) {
|
|
@@ -971,7 +1004,6 @@ const FRAMEWORK_TEST_STRINGS = [
|
|
|
971
1004
|
"/node_modules/preact/",
|
|
972
1005
|
"/node_modules/react/",
|
|
973
1006
|
"/node_modules/js-cookie/",
|
|
974
|
-
"/node_modules/dequal/",
|
|
975
1007
|
"/node_modules/@quilted/quilt/",
|
|
976
1008
|
"/node_modules/@preact/signals/",
|
|
977
1009
|
"/node_modules/@preact/signals-core/",
|
|
@@ -1035,5 +1067,8 @@ function createManualChunksSorter() {
|
|
|
1035
1067
|
return `${bundleBaseName}-${relativeId.split(path.sep)[0]?.split(".")[0]}`;
|
|
1036
1068
|
};
|
|
1037
1069
|
}
|
|
1070
|
+
function getSourceFromCustomEntry(entry) {
|
|
1071
|
+
return typeof entry === "object" ? entry.source : entry;
|
|
1072
|
+
}
|
|
1038
1073
|
|
|
1039
1074
|
export { MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_BROWSER_ASSETS, MAGIC_MODULE_ENTRY, MAGIC_MODULE_REQUEST_ROUTER, additionalEntriesForAppBrowser, magicModuleAppAssetManifests, magicModuleAppBrowserEntry, magicModuleAppComponent, magicModuleAppRequestRouter, nodeAppServerRuntime, quiltApp, quiltAppBrowser, quiltAppBrowserInput, quiltAppBrowserPlugins, quiltAppServer, quiltAppServerInput, quiltAppServerPlugins, quiltAppServiceWorker, quiltAppServiceWorkerInput, quiltAppServiceWorkerPlugins, sourceEntryForAppBrowser, sourceEntryForAppServer, sourceEntryForAppServiceWorker };
|
|
@@ -15,6 +15,7 @@ async function writeManifestForBundle(bundle, {
|
|
|
15
15
|
file,
|
|
16
16
|
base,
|
|
17
17
|
key,
|
|
18
|
+
inline,
|
|
18
19
|
priority,
|
|
19
20
|
moduleID: getModuleID = defaultModuleID
|
|
20
21
|
}, { format }) {
|
|
@@ -35,7 +36,7 @@ async function writeManifestForBundle(bundle, {
|
|
|
35
36
|
function getAssetId(file2) {
|
|
36
37
|
let id = assetIdMap.get(file2);
|
|
37
38
|
if (id == null) {
|
|
38
|
-
assets.push(loadAsset(file2, bundle[file2]));
|
|
39
|
+
assets.push(loadAsset(file2, bundle[file2], inline));
|
|
39
40
|
id = assets.length - 1;
|
|
40
41
|
assetIdMap.set(file2, id);
|
|
41
42
|
}
|
|
@@ -51,7 +52,17 @@ async function writeManifestForBundle(bundle, {
|
|
|
51
52
|
modules: {}
|
|
52
53
|
};
|
|
53
54
|
for (const output of outputs) {
|
|
54
|
-
if (output.type
|
|
55
|
+
if (output.type === "asset") {
|
|
56
|
+
if (output.name && output.fileName.endsWith(".js")) {
|
|
57
|
+
manifest.modules[output.name] = createAssetsEntry([output.fileName], {
|
|
58
|
+
dependencyMap,
|
|
59
|
+
getAssetId
|
|
60
|
+
});
|
|
61
|
+
manifest.entries[`./${output.name}`] = output.name;
|
|
62
|
+
}
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (!output.isDynamicEntry && !output.isEntry) {
|
|
55
66
|
continue;
|
|
56
67
|
}
|
|
57
68
|
const rollupModuleID = output.facadeModuleId ?? output.moduleIds.at(-1);
|
|
@@ -65,9 +76,17 @@ async function writeManifestForBundle(bundle, {
|
|
|
65
76
|
const entry = moduleInfo?.meta?.quilt?.entry ?? moduleID;
|
|
66
77
|
manifest.entries[entry] = moduleID;
|
|
67
78
|
}
|
|
79
|
+
const isCSS = moduleID.endsWith(".css");
|
|
80
|
+
const moduleFiles = [output.fileName, ...output.imports];
|
|
68
81
|
manifest.modules[moduleID] = createAssetsEntry(
|
|
69
|
-
|
|
70
|
-
|
|
82
|
+
// When an entrypoint is a CSS file, Rollup creates an unnecessary JavaScript file
|
|
83
|
+
// as the entrypoint of the module. We will exclude the JavaScript file, so only
|
|
84
|
+
// the CSS file is included in the final manifest.
|
|
85
|
+
isCSS ? moduleFiles.filter((file2) => file2.endsWith(".css")) : moduleFiles,
|
|
86
|
+
{
|
|
87
|
+
dependencyMap,
|
|
88
|
+
getAssetId
|
|
89
|
+
}
|
|
71
90
|
);
|
|
72
91
|
}
|
|
73
92
|
manifest.assets = await Promise.all(assets);
|
|
@@ -75,12 +94,17 @@ async function writeManifestForBundle(bundle, {
|
|
|
75
94
|
await fs.writeFile(file, JSON.stringify(manifest, null, 2));
|
|
76
95
|
}
|
|
77
96
|
const SRI_ALGORITHM = "sha384";
|
|
78
|
-
async function loadAsset(file, chunk) {
|
|
97
|
+
async function loadAsset(file, chunk, inline) {
|
|
79
98
|
const asset = [file.endsWith(".css") ? 1 : 2, file];
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
asset[2] =
|
|
83
|
-
}
|
|
99
|
+
const source = "code" in chunk ? chunk.code : chunk.source;
|
|
100
|
+
if (inline?.has(chunk.name)) {
|
|
101
|
+
asset[2] = source;
|
|
102
|
+
} else {
|
|
103
|
+
try {
|
|
104
|
+
const hash = createHash(SRI_ALGORITHM).update("code" in chunk ? chunk.code : chunk.source).digest().toString("base64");
|
|
105
|
+
asset[2] = `${SRI_ALGORITHM}-${hash}`;
|
|
106
|
+
} catch {
|
|
107
|
+
}
|
|
84
108
|
}
|
|
85
109
|
return asset;
|
|
86
110
|
}
|
|
@@ -6,21 +6,22 @@ import { multiline } from '../shared/strings.mjs';
|
|
|
6
6
|
function systemJS({ minify = false } = {}) {
|
|
7
7
|
return {
|
|
8
8
|
name: "@quilted/system-js",
|
|
9
|
-
async
|
|
10
|
-
if (options.format !== "system" || !chunk.isEntry) return null;
|
|
9
|
+
async buildStart() {
|
|
11
10
|
const require = createRequire(import.meta.url);
|
|
12
11
|
const systemjs = minify ? require.resolve("systemjs/dist/s.min.js") : require.resolve("systemjs/dist/s.js");
|
|
13
|
-
|
|
12
|
+
this.emitFile({
|
|
14
13
|
type: "asset",
|
|
15
|
-
name: "
|
|
14
|
+
name: "system.js",
|
|
16
15
|
source: (await readFile(systemjs, { encoding: "utf8" })).replace(
|
|
17
16
|
// Remove the source map comment, if it is present, because we don’t upload the
|
|
18
17
|
// sourcemap for this file.
|
|
19
|
-
/\n?[/][/]# sourceMappingURL=s.*\.map\n
|
|
18
|
+
/\n?[/][/]# sourceMappingURL=s.*\.map\n?$/m,
|
|
20
19
|
""
|
|
21
|
-
)
|
|
20
|
+
).trim()
|
|
22
21
|
});
|
|
23
|
-
|
|
22
|
+
},
|
|
23
|
+
async renderChunk(code, chunk, options) {
|
|
24
|
+
if (options.format !== "system" || !chunk.isEntry) return null;
|
|
24
25
|
const newCode = new MagicString(code);
|
|
25
26
|
newCode.append(multiline`
|
|
26
27
|
if (document.currentScript) {
|