@quilted/rollup 0.1.4 → 0.1.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.
- package/CHANGELOG.md +8 -0
- package/build/cjs/app.cjs +144 -142
- package/build/cjs/features/assets.cjs +130 -0
- package/build/cjs/{env.cjs → features/env.cjs} +4 -4
- package/build/cjs/{request-router.cjs → features/request-router.cjs} +3 -3
- package/build/cjs/{shared → features}/source-code.cjs +1 -1
- package/build/cjs/features/system-js.cjs +35 -0
- package/build/cjs/index.cjs +0 -7
- package/build/cjs/shared/rollup.cjs +0 -4
- package/build/esm/app.mjs +146 -144
- package/build/esm/features/assets.mjs +107 -0
- package/build/esm/{env.mjs → features/env.mjs} +4 -4
- package/build/esm/{request-router.mjs → features/request-router.mjs} +3 -3
- package/build/esm/features/system-js.mjs +33 -0
- package/build/esm/index.mjs +1 -3
- package/build/esm/shared/rollup.mjs +1 -4
- package/build/esnext/app.esnext +146 -144
- package/build/esnext/features/assets.esnext +107 -0
- package/build/esnext/{env.esnext → features/env.esnext} +4 -4
- package/build/esnext/{request-router.esnext → features/request-router.esnext} +3 -3
- package/build/esnext/features/system-js.esnext +33 -0
- package/build/esnext/index.esnext +1 -3
- package/build/esnext/shared/rollup.esnext +1 -4
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/app.d.ts +32 -144
- package/build/typescript/app.d.ts.map +1 -1
- package/build/typescript/features/assets.d.ts +13 -0
- package/build/typescript/features/assets.d.ts.map +1 -0
- package/build/typescript/features/css.d.ts +16 -0
- package/build/typescript/features/css.d.ts.map +1 -0
- package/build/typescript/features/env.d.ts +57 -0
- package/build/typescript/features/env.d.ts.map +1 -0
- package/build/typescript/features/graphql/transform.d.ts +17 -0
- package/build/typescript/features/graphql/transform.d.ts.map +1 -0
- package/build/typescript/features/graphql.d.ts +6 -0
- package/build/typescript/features/graphql.d.ts.map +1 -0
- package/build/typescript/features/request-router.d.ts +15 -0
- package/build/typescript/features/request-router.d.ts.map +1 -0
- package/build/typescript/features/source-code.d.ts +5 -0
- package/build/typescript/features/source-code.d.ts.map +1 -0
- package/build/typescript/features/system-js.d.ts +7 -0
- package/build/typescript/features/system-js.d.ts.map +1 -0
- package/build/typescript/index.d.ts +1 -3
- package/build/typescript/index.d.ts.map +1 -1
- package/package.json +5 -2
- package/source/app.ts +168 -124
- package/source/features/assets.ts +183 -0
- package/source/features/css.ts +91 -0
- package/source/{env.ts → features/env.ts} +4 -4
- package/source/{request-router.ts → features/request-router.ts} +3 -3
- package/source/features/system-js.ts +36 -0
- package/source/index.ts +0 -5
- /package/build/cjs/{graphql → features/graphql}/transform.cjs +0 -0
- /package/build/cjs/{graphql.cjs → features/graphql.cjs} +0 -0
- /package/build/esm/{graphql → features/graphql}/transform.mjs +0 -0
- /package/build/esm/{graphql.mjs → features/graphql.mjs} +0 -0
- /package/build/esm/{shared → features}/source-code.mjs +0 -0
- /package/build/esnext/{graphql → features/graphql}/transform.esnext +0 -0
- /package/build/esnext/{graphql.esnext → features/graphql.esnext} +0 -0
- /package/build/esnext/{shared → features}/source-code.esnext +0 -0
- /package/source/{graphql → features/graphql}/transform.ts +0 -0
- /package/source/{graphql.ts → features/graphql.ts} +0 -0
- /package/source/{shared → features}/source-code.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @quilted/rollup
|
|
2
2
|
|
|
3
|
+
## 0.1.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`3b3db683`](https://github.com/lemonmade/quilt/commit/3b3db6833608df10274f6335182164856c19cbdc) Thanks [@lemonmade](https://github.com/lemonmade)! - Switch to a config generator function
|
|
8
|
+
|
|
9
|
+
- [`97583dc1`](https://github.com/lemonmade/quilt/commit/97583dc12973cc7e378ffcd9815ecc098f3ecbeb) Thanks [@lemonmade](https://github.com/lemonmade)! - Add CSS plugin
|
|
10
|
+
|
|
3
11
|
## 0.1.4
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/build/cjs/app.cjs
CHANGED
|
@@ -25,169 +25,171 @@ function _interopNamespaceDefault(e) {
|
|
|
25
25
|
|
|
26
26
|
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
27
27
|
|
|
28
|
-
function quiltAppBrowser({
|
|
28
|
+
async function quiltAppBrowser({
|
|
29
29
|
app,
|
|
30
|
+
entry = constants.MAGIC_MODULE_ENTRY,
|
|
30
31
|
env,
|
|
31
32
|
assets,
|
|
32
33
|
module,
|
|
33
34
|
graphql = true
|
|
34
35
|
} = {}) {
|
|
35
36
|
const mode = (typeof env === 'object' ? env?.mode : undefined) ?? 'production';
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
37
|
+
const minify = assets?.minify ?? true;
|
|
38
|
+
const [{
|
|
39
|
+
visualizer
|
|
40
|
+
}, {
|
|
41
|
+
sourceCode
|
|
42
|
+
}, {
|
|
43
|
+
rawAssets,
|
|
44
|
+
staticAssets
|
|
45
|
+
}, {
|
|
46
|
+
systemJS
|
|
47
|
+
}, nodePlugins] = await Promise.all([import('rollup-plugin-visualizer'), Promise.resolve().then(function () { return require('./features/source-code.cjs'); }), Promise.resolve().then(function () { return require('./features/assets.cjs'); }), Promise.resolve().then(function () { return require('./features/system-js.cjs'); }), rollup.getNodePlugins()]);
|
|
48
|
+
const plugins = [...nodePlugins, systemJS(), sourceCode({
|
|
49
|
+
mode
|
|
50
|
+
}), rawAssets(), staticAssets()];
|
|
51
|
+
if (env) {
|
|
52
|
+
const {
|
|
53
|
+
magicModuleEnv,
|
|
54
|
+
replaceProcessEnv
|
|
55
|
+
} = await Promise.resolve().then(function () { return require('./features/env.cjs'); });
|
|
56
|
+
if (typeof env === 'boolean') {
|
|
57
|
+
plugins.push(replaceProcessEnv({
|
|
51
58
|
mode
|
|
52
59
|
}));
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
newPlugins.push(replaceProcessEnv({
|
|
60
|
-
mode: 'production'
|
|
61
|
-
}));
|
|
62
|
-
newPlugins.push(magicModuleEnv({
|
|
63
|
-
mode: 'production'
|
|
64
|
-
}));
|
|
65
|
-
} else {
|
|
66
|
-
newPlugins.push(replaceProcessEnv({
|
|
67
|
-
mode: env.mode ?? 'production'
|
|
68
|
-
}));
|
|
69
|
-
newPlugins.push(magicModuleEnv({
|
|
70
|
-
mode: 'production',
|
|
71
|
-
...env
|
|
72
|
-
}));
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (app) {
|
|
76
|
-
newPlugins.push(magicModuleAppComponent({
|
|
77
|
-
entry: app
|
|
78
|
-
}));
|
|
79
|
-
}
|
|
80
|
-
newPlugins.push(magicModuleAppBrowserEntry(module));
|
|
81
|
-
if (graphql) {
|
|
82
|
-
const {
|
|
83
|
-
graphql
|
|
84
|
-
} = await Promise.resolve().then(function () { return require('./graphql.cjs'); });
|
|
85
|
-
newPlugins.push(graphql({
|
|
86
|
-
manifest: path__namespace.resolve(`manifests/graphql.json`)
|
|
87
|
-
}));
|
|
88
|
-
}
|
|
89
|
-
const minify = assets?.minify ?? true;
|
|
90
|
-
if (minify) {
|
|
91
|
-
const {
|
|
92
|
-
minify
|
|
93
|
-
} = await import('rollup-plugin-esbuild');
|
|
94
|
-
newPlugins.push(minify());
|
|
95
|
-
}
|
|
96
|
-
newPlugins.push(visualizer({
|
|
97
|
-
template: 'treemap',
|
|
98
|
-
open: false,
|
|
99
|
-
brotliSize: true,
|
|
100
|
-
filename: path__namespace.resolve(`reports/bundle-visualizer.html`)
|
|
60
|
+
plugins.push(magicModuleEnv({
|
|
61
|
+
mode
|
|
62
|
+
}));
|
|
63
|
+
} else {
|
|
64
|
+
plugins.push(replaceProcessEnv({
|
|
65
|
+
mode
|
|
101
66
|
}));
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
67
|
+
plugins.push(magicModuleEnv({
|
|
68
|
+
mode
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (app) {
|
|
73
|
+
plugins.push(magicModuleAppComponent({
|
|
74
|
+
entry: app
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
plugins.push(magicModuleAppBrowserEntry(module));
|
|
78
|
+
if (graphql) {
|
|
79
|
+
const {
|
|
80
|
+
graphql
|
|
81
|
+
} = await Promise.resolve().then(function () { return require('./features/graphql.cjs'); });
|
|
82
|
+
plugins.push(graphql({
|
|
83
|
+
manifest: path__namespace.resolve(`manifests/graphql.json`)
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
if (minify) {
|
|
87
|
+
const {
|
|
88
|
+
minify
|
|
89
|
+
} = await import('rollup-plugin-esbuild');
|
|
90
|
+
plugins.push(minify());
|
|
91
|
+
}
|
|
92
|
+
plugins.push(visualizer({
|
|
93
|
+
template: 'treemap',
|
|
94
|
+
open: false,
|
|
95
|
+
brotliSize: true,
|
|
96
|
+
filename: path__namespace.resolve(`reports/bundle-visualizer.html`)
|
|
97
|
+
}));
|
|
98
|
+
return {
|
|
99
|
+
input: entry,
|
|
100
|
+
plugins,
|
|
101
|
+
output: {
|
|
102
|
+
// format: isESM ? 'esm' : 'systemjs',
|
|
103
|
+
format: 'esm',
|
|
104
|
+
dir: path__namespace.resolve(`build/assets`),
|
|
105
|
+
entryFileNames: `app.[hash].js`,
|
|
106
|
+
assetFileNames: `[name].[hash].[ext]`,
|
|
107
|
+
chunkFileNames: `[name].[hash].js`,
|
|
108
|
+
manualChunks: createManualChunksSorter()
|
|
115
109
|
}
|
|
116
110
|
};
|
|
117
111
|
}
|
|
118
|
-
function quiltAppServer({
|
|
112
|
+
async function quiltAppServer({
|
|
119
113
|
app,
|
|
120
114
|
env,
|
|
121
115
|
graphql,
|
|
122
|
-
entry
|
|
116
|
+
entry = constants.MAGIC_MODULE_ENTRY,
|
|
117
|
+
minify = false
|
|
123
118
|
} = {}) {
|
|
124
119
|
const mode = (typeof env === 'object' ? env?.mode : undefined) ?? 'production';
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
120
|
+
const [{
|
|
121
|
+
visualizer
|
|
122
|
+
}, {
|
|
123
|
+
sourceCode
|
|
124
|
+
}, {
|
|
125
|
+
rawAssets,
|
|
126
|
+
staticAssets
|
|
127
|
+
}, {
|
|
128
|
+
magicModuleRequestRouterEntry
|
|
129
|
+
}, nodePlugins] = await Promise.all([import('rollup-plugin-visualizer'), Promise.resolve().then(function () { return require('./features/source-code.cjs'); }), Promise.resolve().then(function () { return require('./features/assets.cjs'); }), Promise.resolve().then(function () { return require('./features/request-router.cjs'); }), rollup.getNodePlugins()]);
|
|
130
|
+
const plugins = [...nodePlugins, sourceCode({
|
|
131
|
+
mode
|
|
132
|
+
}), rawAssets(), staticAssets({
|
|
133
|
+
emit: false
|
|
134
|
+
})];
|
|
135
|
+
if (env) {
|
|
136
|
+
const {
|
|
137
|
+
magicModuleEnv,
|
|
138
|
+
replaceProcessEnv
|
|
139
|
+
} = await Promise.resolve().then(function () { return require('./features/env.cjs'); });
|
|
140
|
+
if (typeof env === 'boolean') {
|
|
141
|
+
plugins.push(replaceProcessEnv({
|
|
140
142
|
mode
|
|
141
143
|
}));
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
magicModuleEnv,
|
|
145
|
-
replaceProcessEnv
|
|
146
|
-
} = await Promise.resolve().then(function () { return require('./env.cjs'); });
|
|
147
|
-
if (typeof env === 'boolean') {
|
|
148
|
-
newPlugins.push(replaceProcessEnv({
|
|
149
|
-
mode
|
|
150
|
-
}));
|
|
151
|
-
newPlugins.push(magicModuleEnv({
|
|
152
|
-
mode
|
|
153
|
-
}));
|
|
154
|
-
} else {
|
|
155
|
-
newPlugins.push(replaceProcessEnv({
|
|
156
|
-
mode
|
|
157
|
-
}));
|
|
158
|
-
newPlugins.push(magicModuleEnv({
|
|
159
|
-
mode,
|
|
160
|
-
...env
|
|
161
|
-
}));
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
if (app) {
|
|
165
|
-
newPlugins.push(magicModuleAppComponent({
|
|
166
|
-
entry: app
|
|
167
|
-
}));
|
|
168
|
-
}
|
|
169
|
-
newPlugins.push(magicModuleRequestRouterEntry());
|
|
170
|
-
newPlugins.push(magicModuleAppRequestRouter({
|
|
171
|
-
entry
|
|
144
|
+
plugins.push(magicModuleEnv({
|
|
145
|
+
mode
|
|
172
146
|
}));
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
147
|
+
} else {
|
|
148
|
+
plugins.push(replaceProcessEnv({
|
|
149
|
+
mode
|
|
150
|
+
}));
|
|
151
|
+
plugins.push(magicModuleEnv({
|
|
152
|
+
mode
|
|
153
|
+
}));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (app) {
|
|
157
|
+
plugins.push(magicModuleAppComponent({
|
|
158
|
+
entry: app
|
|
159
|
+
}));
|
|
160
|
+
}
|
|
161
|
+
plugins.push(magicModuleRequestRouterEntry());
|
|
162
|
+
plugins.push(magicModuleAppRequestRouter({
|
|
163
|
+
entry
|
|
164
|
+
}));
|
|
165
|
+
if (graphql) {
|
|
166
|
+
const {
|
|
167
|
+
graphql
|
|
168
|
+
} = await Promise.resolve().then(function () { return require('./features/graphql.cjs'); });
|
|
169
|
+
plugins.push(graphql({
|
|
170
|
+
manifest: false
|
|
171
|
+
}));
|
|
172
|
+
}
|
|
173
|
+
if (minify) {
|
|
174
|
+
const {
|
|
175
|
+
minify
|
|
176
|
+
} = await import('rollup-plugin-esbuild');
|
|
177
|
+
plugins.push(minify());
|
|
178
|
+
}
|
|
179
|
+
plugins.push(visualizer({
|
|
180
|
+
template: 'treemap',
|
|
181
|
+
open: false,
|
|
182
|
+
brotliSize: true,
|
|
183
|
+
filename: path__namespace.resolve(`reports/bundle-visualizer.html`)
|
|
184
|
+
}));
|
|
185
|
+
return {
|
|
186
|
+
input: entry,
|
|
187
|
+
plugins,
|
|
188
|
+
output: {
|
|
189
|
+
// format: isESM ? 'esm' : 'systemjs',
|
|
190
|
+
format: 'esm',
|
|
191
|
+
dir: path__namespace.resolve(`build/server`),
|
|
192
|
+
entryFileNames: 'server.js'
|
|
191
193
|
}
|
|
192
194
|
};
|
|
193
195
|
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var path = require('node:path');
|
|
4
|
+
var promises = require('node:fs/promises');
|
|
5
|
+
var node_crypto = require('node:crypto');
|
|
6
|
+
var mime = require('mrmime');
|
|
7
|
+
|
|
8
|
+
function _interopNamespaceDefault(e) {
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n["default"] = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
26
|
+
var mime__namespace = /*#__PURE__*/_interopNamespaceDefault(mime);
|
|
27
|
+
|
|
28
|
+
const QUERY_PATTERN = /\?.*$/s;
|
|
29
|
+
const HASH_PATTERN = /#.*$/s;
|
|
30
|
+
const RAW_PATTERN = /(\?|&)raw(?:&|$)/;
|
|
31
|
+
const DEFAULT_INLINE_LIMIT = 4096;
|
|
32
|
+
const DEFAULT_OUTPUT_PATTERN = '[name].[hash].[ext]';
|
|
33
|
+
const DEFAULT_STATIC_ASSET_EXTENSIONS = [
|
|
34
|
+
// images
|
|
35
|
+
'.png', '.jpg', '.jpeg', '.gif', '.svg', '.ico', '.webp', '.avif',
|
|
36
|
+
// media
|
|
37
|
+
'.mp4', '.webm', '.ogg', '.mp3', '.wav', '.flac', '.aac',
|
|
38
|
+
// fonts
|
|
39
|
+
'.woff', '.woff2', '.eot', '.ttf', '.otf',
|
|
40
|
+
// other
|
|
41
|
+
'.webmanifest', '.pdf', '.txt'];
|
|
42
|
+
function rawAssets() {
|
|
43
|
+
return {
|
|
44
|
+
name: '@quilted/raw-assets',
|
|
45
|
+
async load(id) {
|
|
46
|
+
if (id.startsWith('\0') || !RAW_PATTERN.test(id)) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const moduleId = cleanModuleIdentifier(id);
|
|
50
|
+
this.addWatchFile(moduleId);
|
|
51
|
+
const file = await promises.readFile(moduleId, {
|
|
52
|
+
encoding: 'utf-8'
|
|
53
|
+
});
|
|
54
|
+
return `export default ${JSON.stringify(file)}`;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function staticAssets({
|
|
59
|
+
emit = true,
|
|
60
|
+
baseURL = '/',
|
|
61
|
+
extensions = DEFAULT_STATIC_ASSET_EXTENSIONS,
|
|
62
|
+
inlineLimit = DEFAULT_INLINE_LIMIT,
|
|
63
|
+
outputPattern = DEFAULT_OUTPUT_PATTERN
|
|
64
|
+
} = {}) {
|
|
65
|
+
const assetCache = new Map();
|
|
66
|
+
const assetMatcher = new RegExp(`\\.(` + extensions.map(extension => extension.startsWith('.') ? extension.slice(1) : extension).join('|') + `)(\\?.*)?$`);
|
|
67
|
+
return {
|
|
68
|
+
name: '@quilted/static-assets',
|
|
69
|
+
async load(id) {
|
|
70
|
+
if (id.startsWith('\0') || !assetMatcher.test(id)) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
const cached = assetCache.get(id);
|
|
74
|
+
if (cached) {
|
|
75
|
+
return cached;
|
|
76
|
+
}
|
|
77
|
+
const file = cleanModuleIdentifier(id);
|
|
78
|
+
const content = await promises.readFile(file);
|
|
79
|
+
let url;
|
|
80
|
+
if (!file.endsWith('.svg') && content.length < inlineLimit) {
|
|
81
|
+
// base64 inlined as a string
|
|
82
|
+
url = `data:${mime__namespace.lookup(file)};base64,${content.toString('base64')}`;
|
|
83
|
+
} else {
|
|
84
|
+
const contentHash = getHash(content);
|
|
85
|
+
const filename = assetFileNamesToFileName(outputPattern, file, contentHash);
|
|
86
|
+
url = `${baseURL.endsWith('/') ? baseURL.slice(0, -1) : baseURL}/${filename}`;
|
|
87
|
+
if (emit) {
|
|
88
|
+
this.emitFile({
|
|
89
|
+
name: file,
|
|
90
|
+
type: 'asset',
|
|
91
|
+
fileName: filename,
|
|
92
|
+
source: content
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const source = `export default ${JSON.stringify(url)};`;
|
|
97
|
+
assetCache.set(id, source);
|
|
98
|
+
return source;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function assetFileNamesToFileName(pattern, file, contentHash) {
|
|
103
|
+
const basename = path__namespace.basename(file);
|
|
104
|
+
const extname = path__namespace.extname(basename);
|
|
105
|
+
const ext = extname.substring(1);
|
|
106
|
+
const name = basename.slice(0, -extname.length);
|
|
107
|
+
const hash = contentHash;
|
|
108
|
+
return pattern.replace(/\[\w+\]/g, placeholder => {
|
|
109
|
+
switch (placeholder) {
|
|
110
|
+
case '[ext]':
|
|
111
|
+
return ext;
|
|
112
|
+
case '[extname]':
|
|
113
|
+
return extname;
|
|
114
|
+
case '[hash]':
|
|
115
|
+
return hash;
|
|
116
|
+
case '[name]':
|
|
117
|
+
return name;
|
|
118
|
+
}
|
|
119
|
+
throw new Error(`invalid placeholder ${placeholder} in assetFileNames "${pattern}"`);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
function getHash(text) {
|
|
123
|
+
return node_crypto.createHash('sha256').update(text).digest('hex').substring(0, 8);
|
|
124
|
+
}
|
|
125
|
+
function cleanModuleIdentifier(url) {
|
|
126
|
+
return url.replace(HASH_PATTERN, '').replace(QUERY_PATTERN, '');
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
exports.rawAssets = rawAssets;
|
|
130
|
+
exports.staticAssets = staticAssets;
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
var path = require('node:path');
|
|
4
4
|
var fs = require('node:fs');
|
|
5
|
-
var constants = require('
|
|
6
|
-
var strings = require('
|
|
7
|
-
var rollup = require('
|
|
8
|
-
var magicModule = require('
|
|
5
|
+
var constants = require('../constants.cjs');
|
|
6
|
+
var strings = require('../shared/strings.cjs');
|
|
7
|
+
var rollup = require('../shared/rollup.cjs');
|
|
8
|
+
var magicModule = require('../shared/magic-module.cjs');
|
|
9
9
|
|
|
10
10
|
function _interopNamespaceDefault(e) {
|
|
11
11
|
var n = Object.create(null);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var constants = require('
|
|
4
|
-
var magicModule = require('
|
|
5
|
-
var strings = require('
|
|
3
|
+
var constants = require('../constants.cjs');
|
|
4
|
+
var magicModule = require('../shared/magic-module.cjs');
|
|
5
|
+
var strings = require('../shared/strings.cjs');
|
|
6
6
|
|
|
7
7
|
function magicModuleRequestRouterEntry({
|
|
8
8
|
host,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var node_module = require('node:module');
|
|
4
4
|
var babel = require('@rollup/plugin-babel');
|
|
5
5
|
|
|
6
|
-
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('
|
|
6
|
+
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('features/source-code.cjs', document.baseURI).href)));
|
|
7
7
|
function sourceCode({
|
|
8
8
|
mode,
|
|
9
9
|
targets
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var promises = require('node:fs/promises');
|
|
4
|
+
var node_module = require('node:module');
|
|
5
|
+
|
|
6
|
+
function systemJS({
|
|
7
|
+
minify = false
|
|
8
|
+
} = {}) {
|
|
9
|
+
return {
|
|
10
|
+
name: '@quilted/system-js',
|
|
11
|
+
async renderChunk(_, chunk, options) {
|
|
12
|
+
if (options.format !== 'system' || !chunk.isEntry) return null;
|
|
13
|
+
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('features/system-js.cjs', document.baseURI).href)));
|
|
14
|
+
const systemjs = minify ? require$1.resolve('systemjs/dist/s.min.js') : require$1.resolve('systemjs/dist/s.js');
|
|
15
|
+
|
|
16
|
+
// We write the systemjs loader to a dedicated file, and we make it the
|
|
17
|
+
// "first import" of the chunk so that it is the first file listed in
|
|
18
|
+
// the manifest.
|
|
19
|
+
const fileHandle = this.emitFile({
|
|
20
|
+
type: 'asset',
|
|
21
|
+
name: 'loader.js',
|
|
22
|
+
source: (await promises.readFile(systemjs, {
|
|
23
|
+
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?$/, '')
|
|
28
|
+
});
|
|
29
|
+
chunk.imports.unshift(this.getFileName(fileHandle));
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
exports.systemJS = systemJS;
|
package/build/cjs/index.cjs
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var env = require('./env.cjs');
|
|
4
3
|
var app = require('./app.cjs');
|
|
5
|
-
var requestRouter = require('./request-router.cjs');
|
|
6
4
|
|
|
7
5
|
|
|
8
6
|
|
|
9
|
-
exports.magicModuleEnv = env.magicModuleEnv;
|
|
10
|
-
exports.magicModuleAppBrowserEntry = app.magicModuleAppBrowserEntry;
|
|
11
|
-
exports.magicModuleAppComponent = app.magicModuleAppComponent;
|
|
12
|
-
exports.magicModuleAppRequestRouter = app.magicModuleAppRequestRouter;
|
|
13
7
|
exports.quiltAppBrowser = app.quiltAppBrowser;
|
|
14
8
|
exports.quiltAppServer = app.quiltAppServer;
|
|
15
|
-
exports.magicModuleRequestRouterEntry = requestRouter.magicModuleRequestRouterEntry;
|
|
@@ -28,10 +28,6 @@ async function getNodePlugins() {
|
|
|
28
28
|
// exportConditions,
|
|
29
29
|
}), commonjs(), json()];
|
|
30
30
|
}
|
|
31
|
-
function rollupPluginsToArray(plugins) {
|
|
32
|
-
return Array.isArray(plugins) ? [...plugins] : plugins ? [plugins] : [];
|
|
33
|
-
}
|
|
34
31
|
|
|
35
32
|
exports.getNodePlugins = getNodePlugins;
|
|
36
|
-
exports.rollupPluginsToArray = rollupPluginsToArray;
|
|
37
33
|
exports.smartReplace = smartReplace;
|