@quilted/rollup 0.1.19 → 0.2.0
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 +19 -0
- package/build/esm/app.mjs +443 -219
- package/build/esm/constants.mjs +5 -5
- package/build/esm/features/assets.mjs +93 -81
- package/build/esm/features/async.mjs +186 -0
- package/build/esm/features/css.mjs +26 -39
- package/build/esm/features/env.mjs +47 -44
- package/build/esm/features/esnext.mjs +57 -0
- package/build/esm/features/graphql/transform.mjs +60 -56
- package/build/esm/features/graphql.mjs +65 -47
- package/build/esm/features/request-router.mjs +6 -4
- package/build/esm/features/source-code.mjs +54 -28
- package/build/esm/features/system-js.mjs +13 -18
- package/build/esm/features/typescript.mjs +13 -10
- package/build/esm/features/workers.mjs +173 -0
- package/build/esm/index.mjs +3 -2
- package/build/esm/module.mjs +69 -62
- package/build/esm/package.mjs +275 -84
- package/build/esm/server.mjs +118 -0
- package/build/esm/shared/browserslist.mjs +141 -16
- package/build/esm/shared/magic-module.mjs +9 -7
- package/build/esm/shared/package-json.mjs +7 -1
- package/build/esm/shared/path.mjs +7 -0
- package/build/esm/shared/rollup.mjs +89 -25
- package/build/esm/shared/strings.mjs +7 -6
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/app.d.ts +126 -27
- package/build/typescript/app.d.ts.map +1 -1
- package/build/typescript/features/assets.d.ts +1 -2
- package/build/typescript/features/assets.d.ts.map +1 -1
- package/build/typescript/features/async.d.ts +10 -0
- package/build/typescript/features/async.d.ts.map +1 -0
- package/build/typescript/features/css.d.ts +2 -1
- package/build/typescript/features/css.d.ts.map +1 -1
- package/build/typescript/features/env.d.ts +1 -0
- package/build/typescript/features/env.d.ts.map +1 -1
- package/build/typescript/features/esnext.d.ts +9 -0
- package/build/typescript/features/esnext.d.ts.map +1 -0
- package/build/typescript/features/graphql.d.ts +2 -2
- package/build/typescript/features/graphql.d.ts.map +1 -1
- package/build/typescript/features/source-code.d.ts +9 -3
- package/build/typescript/features/source-code.d.ts.map +1 -1
- package/build/typescript/features/workers.d.ts +52 -0
- package/build/typescript/features/workers.d.ts.map +1 -0
- package/build/typescript/index.d.ts +3 -2
- package/build/typescript/index.d.ts.map +1 -1
- package/build/typescript/module.d.ts +24 -6
- package/build/typescript/module.d.ts.map +1 -1
- package/build/typescript/package.d.ts +196 -4
- package/build/typescript/package.d.ts.map +1 -1
- package/build/typescript/server.d.ts +98 -0
- package/build/typescript/server.d.ts.map +1 -0
- package/build/typescript/shared/browserslist.d.ts +20 -3
- package/build/typescript/shared/browserslist.d.ts.map +1 -1
- package/build/typescript/shared/path.d.ts +2 -0
- package/build/typescript/shared/path.d.ts.map +1 -0
- package/build/typescript/shared/rollup.d.ts +27 -1
- package/build/typescript/shared/rollup.d.ts.map +1 -1
- package/configuration/rollup.config.js +40 -0
- package/package.json +61 -8
- package/source/app.ts +466 -96
- package/source/features/assets.ts +5 -7
- package/source/features/async.ts +249 -0
- package/source/features/css.ts +4 -2
- package/source/features/env.ts +6 -0
- package/source/features/esnext.ts +70 -0
- package/source/features/graphql.ts +4 -2
- package/source/features/source-code.ts +26 -8
- package/source/features/workers.ts +292 -0
- package/source/index.ts +4 -0
- package/source/module.ts +45 -19
- package/source/package.ts +394 -36
- package/source/server.ts +245 -0
- package/source/shared/browserslist.ts +208 -18
- package/source/shared/path.ts +5 -0
- package/source/shared/rollup.ts +102 -4
- package/tsconfig.json +6 -2
- package/build/cjs/app.cjs +0 -441
- package/build/cjs/constants.cjs +0 -13
- package/build/cjs/features/assets.cjs +0 -240
- package/build/cjs/features/css.cjs +0 -71
- package/build/cjs/features/env.cjs +0 -135
- package/build/cjs/features/graphql/transform.cjs +0 -186
- package/build/cjs/features/graphql.cjs +0 -86
- package/build/cjs/features/request-router.cjs +0 -31
- package/build/cjs/features/source-code.cjs +0 -54
- package/build/cjs/features/system-js.cjs +0 -36
- package/build/cjs/features/typescript.cjs +0 -56
- package/build/cjs/index.cjs +0 -13
- package/build/cjs/module.cjs +0 -121
- package/build/cjs/package.cjs +0 -170
- package/build/cjs/shared/browserslist.cjs +0 -25
- package/build/cjs/shared/magic-module.cjs +0 -32
- package/build/cjs/shared/package-json.cjs +0 -31
- package/build/cjs/shared/rollup.cjs +0 -72
- package/build/cjs/shared/strings.cjs +0 -16
- package/build/esnext/app.esnext +0 -414
- package/build/esnext/constants.esnext +0 -7
- package/build/esnext/features/assets.esnext +0 -215
- package/build/esnext/features/css.esnext +0 -69
- package/build/esnext/features/env.esnext +0 -112
- package/build/esnext/features/graphql/transform.esnext +0 -181
- package/build/esnext/features/graphql.esnext +0 -84
- package/build/esnext/features/request-router.esnext +0 -29
- package/build/esnext/features/source-code.esnext +0 -51
- package/build/esnext/features/system-js.esnext +0 -33
- package/build/esnext/features/typescript.esnext +0 -34
- package/build/esnext/index.esnext +0 -3
- package/build/esnext/module.esnext +0 -100
- package/build/esnext/package.esnext +0 -148
- package/build/esnext/shared/browserslist.esnext +0 -23
- package/build/esnext/shared/magic-module.esnext +0 -30
- package/build/esnext/shared/package-json.esnext +0 -10
- package/build/esnext/shared/rollup.esnext +0 -49
- package/build/esnext/shared/strings.esnext +0 -14
- package/build/typescript/env.d.ts +0 -55
- package/build/typescript/env.d.ts.map +0 -1
- package/build/typescript/graphql/transform.d.ts +0 -17
- package/build/typescript/graphql/transform.d.ts.map +0 -1
- package/build/typescript/graphql.d.ts +0 -6
- package/build/typescript/graphql.d.ts.map +0 -1
- package/build/typescript/request-router.d.ts +0 -15
- package/build/typescript/request-router.d.ts.map +0 -1
- package/build/typescript/shared/source-code.d.ts +0 -5
- package/build/typescript/shared/source-code.d.ts.map +0 -1
- package/quilt.project.ts +0 -5
package/build/cjs/module.cjs
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var path = require('node:path');
|
|
4
|
-
var glob = require('glob');
|
|
5
|
-
var node_url = require('node:url');
|
|
6
|
-
var rollup = require('./shared/rollup.cjs');
|
|
7
|
-
var packageJson = require('./shared/package-json.cjs');
|
|
8
|
-
var browserslist = require('./shared/browserslist.cjs');
|
|
9
|
-
|
|
10
|
-
function _interopNamespaceDefault(e) {
|
|
11
|
-
var n = Object.create(null);
|
|
12
|
-
if (e) {
|
|
13
|
-
Object.keys(e).forEach(function (k) {
|
|
14
|
-
if (k !== 'default') {
|
|
15
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function () { return e[k]; }
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
n["default"] = e;
|
|
24
|
-
return Object.freeze(n);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
28
|
-
|
|
29
|
-
async function quiltModule({
|
|
30
|
-
root: rootPath = process.cwd(),
|
|
31
|
-
env,
|
|
32
|
-
assets,
|
|
33
|
-
graphql = true
|
|
34
|
-
} = {}) {
|
|
35
|
-
const root = typeof rootPath === 'string' ? rootPath : node_url.fileURLToPath(rootPath);
|
|
36
|
-
const mode = (typeof env === 'object' ? env?.mode : undefined) ?? 'production';
|
|
37
|
-
const outputDirectory = path__namespace.join(root, 'build/assets');
|
|
38
|
-
const minify = assets?.minify ?? true;
|
|
39
|
-
const hash = assets?.hash ?? 'async-only';
|
|
40
|
-
const browserTarget = await browserslist.getBrowserTargetDetails(assets?.targets, {
|
|
41
|
-
root
|
|
42
|
-
});
|
|
43
|
-
const targetFilenamePart = browserTarget.name ? `.${browserTarget.name}` : '';
|
|
44
|
-
const [{
|
|
45
|
-
visualizer
|
|
46
|
-
}, {
|
|
47
|
-
magicModuleEnv,
|
|
48
|
-
replaceProcessEnv
|
|
49
|
-
}, {
|
|
50
|
-
sourceCode
|
|
51
|
-
}, nodePlugins, packageJSON] = await Promise.all([import('rollup-plugin-visualizer'), Promise.resolve().then(function () { return require('./features/env.cjs'); }), Promise.resolve().then(function () { return require('./features/source-code.cjs'); }), rollup.getNodePlugins(), packageJson.loadPackageJSON(root)]);
|
|
52
|
-
const source = await sourceForModule(root, packageJSON);
|
|
53
|
-
const plugins = [...nodePlugins, replaceProcessEnv({
|
|
54
|
-
mode
|
|
55
|
-
}), magicModuleEnv({
|
|
56
|
-
...env,
|
|
57
|
-
mode
|
|
58
|
-
}), sourceCode({
|
|
59
|
-
mode: 'production',
|
|
60
|
-
targets: browserTarget.browsers
|
|
61
|
-
}), rollup.removeBuildFiles(['build/assets', 'build/reports'], {
|
|
62
|
-
root
|
|
63
|
-
})];
|
|
64
|
-
if (graphql) {
|
|
65
|
-
const {
|
|
66
|
-
graphql
|
|
67
|
-
} = await Promise.resolve().then(function () { return require('./features/graphql.cjs'); });
|
|
68
|
-
plugins.push(graphql({
|
|
69
|
-
manifest: false
|
|
70
|
-
}));
|
|
71
|
-
}
|
|
72
|
-
if (minify) {
|
|
73
|
-
const {
|
|
74
|
-
minify
|
|
75
|
-
} = await import('rollup-plugin-esbuild');
|
|
76
|
-
plugins.push(minify());
|
|
77
|
-
}
|
|
78
|
-
plugins.push(visualizer({
|
|
79
|
-
template: 'treemap',
|
|
80
|
-
open: false,
|
|
81
|
-
brotliSize: true,
|
|
82
|
-
filename: path__namespace.resolve(root, `build/reports/bundle-visualizer${targetFilenamePart}.html`)
|
|
83
|
-
}));
|
|
84
|
-
return {
|
|
85
|
-
input: source,
|
|
86
|
-
plugins,
|
|
87
|
-
onwarn(warning, defaultWarn) {
|
|
88
|
-
// Removes annoying warnings for React-focused libraries that
|
|
89
|
-
// include 'use client' directives.
|
|
90
|
-
if (warning.code === 'MODULE_LEVEL_DIRECTIVE' && /['"]use client['"]/.test(warning.message)) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
defaultWarn(warning);
|
|
94
|
-
},
|
|
95
|
-
output: {
|
|
96
|
-
format: 'esm',
|
|
97
|
-
dir: outputDirectory,
|
|
98
|
-
entryFileNames: `[name]${targetFilenamePart}${hash === true ? `.[hash]` : ''}.js`,
|
|
99
|
-
chunkFileNames: `[name]${targetFilenamePart}${hash === true || hash === 'async-only' ? `.[hash]` : ''}.js`,
|
|
100
|
-
assetFileNames: `[name]${targetFilenamePart}${hash === true ? `.[hash]` : ''}.[ext]`
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
async function sourceForModule(root, packageJSON) {
|
|
105
|
-
const {
|
|
106
|
-
main,
|
|
107
|
-
exports
|
|
108
|
-
} = packageJSON;
|
|
109
|
-
const entryFromPackageJSON = main ?? exports?.['.'];
|
|
110
|
-
if (entryFromPackageJSON) {
|
|
111
|
-
return path__namespace.resolve(root, entryFromPackageJSON);
|
|
112
|
-
}
|
|
113
|
-
const possibleSourceFiles = await glob.glob('{index,module,entry,input}.{ts,tsx,mjs,js,jsx}', {
|
|
114
|
-
cwd: root,
|
|
115
|
-
nodir: true,
|
|
116
|
-
absolute: true
|
|
117
|
-
});
|
|
118
|
-
return possibleSourceFiles[0];
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
exports.quiltModule = quiltModule;
|
package/build/cjs/package.cjs
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var path = require('node:path');
|
|
4
|
-
var glob = require('glob');
|
|
5
|
-
var node_url = require('node:url');
|
|
6
|
-
var rollup = require('./shared/rollup.cjs');
|
|
7
|
-
var packageJson = require('./shared/package-json.cjs');
|
|
8
|
-
|
|
9
|
-
function _interopNamespaceDefault(e) {
|
|
10
|
-
var n = Object.create(null);
|
|
11
|
-
if (e) {
|
|
12
|
-
Object.keys(e).forEach(function (k) {
|
|
13
|
-
if (k !== 'default') {
|
|
14
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
get: function () { return e[k]; }
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
n["default"] = e;
|
|
23
|
-
return Object.freeze(n);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
27
|
-
|
|
28
|
-
async function quiltPackageESModules({
|
|
29
|
-
root: rootPath = process.cwd(),
|
|
30
|
-
graphql = true
|
|
31
|
-
} = {}) {
|
|
32
|
-
const root = typeof rootPath === 'string' ? rootPath : node_url.fileURLToPath(rootPath);
|
|
33
|
-
const outputDirectory = path__namespace.join(root, 'build/esm');
|
|
34
|
-
const [{
|
|
35
|
-
sourceCode
|
|
36
|
-
}, nodePlugins, packageJSON] = await Promise.all([Promise.resolve().then(function () { return require('./features/source-code.cjs'); }), rollup.getNodePlugins(), packageJson.loadPackageJSON(root)]);
|
|
37
|
-
const source = await sourceForPackage(root, packageJSON);
|
|
38
|
-
const plugins = [...nodePlugins, sourceCode({
|
|
39
|
-
mode: 'production'
|
|
40
|
-
}), rollup.removeBuildFiles(['build/esm'], {
|
|
41
|
-
root
|
|
42
|
-
})];
|
|
43
|
-
if (graphql) {
|
|
44
|
-
const {
|
|
45
|
-
graphql
|
|
46
|
-
} = await Promise.resolve().then(function () { return require('./features/graphql.cjs'); });
|
|
47
|
-
plugins.push(graphql({
|
|
48
|
-
manifest: false
|
|
49
|
-
}));
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
input: source.files,
|
|
53
|
-
plugins,
|
|
54
|
-
onwarn(warning, defaultWarn) {
|
|
55
|
-
// Removes annoying warnings for React-focused libraries that
|
|
56
|
-
// include 'use client' directives.
|
|
57
|
-
if (warning.code === 'MODULE_LEVEL_DIRECTIVE' && /['"]use client['"]/.test(warning.message)) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
defaultWarn(warning);
|
|
61
|
-
},
|
|
62
|
-
output: {
|
|
63
|
-
preserveModules: true,
|
|
64
|
-
preserveModulesRoot: source.root,
|
|
65
|
-
format: 'esm',
|
|
66
|
-
dir: outputDirectory,
|
|
67
|
-
entryFileNames: `[name].mjs`,
|
|
68
|
-
assetFileNames: `[name].[ext]`
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
async function quiltPackageESNext({
|
|
73
|
-
root: rootPath = process.cwd(),
|
|
74
|
-
graphql = true
|
|
75
|
-
} = {}) {
|
|
76
|
-
const root = typeof rootPath === 'string' ? rootPath : node_url.fileURLToPath(rootPath);
|
|
77
|
-
const outputDirectory = path__namespace.join(root, 'build/esnext');
|
|
78
|
-
const [{
|
|
79
|
-
sourceCode
|
|
80
|
-
}, nodePlugins, packageJSON] = await Promise.all([Promise.resolve().then(function () { return require('./features/source-code.cjs'); }), rollup.getNodePlugins(), packageJson.loadPackageJSON(root)]);
|
|
81
|
-
const source = await sourceForPackage(root, packageJSON);
|
|
82
|
-
const plugins = [...nodePlugins, sourceCode({
|
|
83
|
-
mode: 'production',
|
|
84
|
-
babel: false
|
|
85
|
-
}), rollup.removeBuildFiles(['build/esnext'], {
|
|
86
|
-
root
|
|
87
|
-
})];
|
|
88
|
-
if (graphql) {
|
|
89
|
-
const {
|
|
90
|
-
graphql
|
|
91
|
-
} = await Promise.resolve().then(function () { return require('./features/graphql.cjs'); });
|
|
92
|
-
plugins.push(graphql({
|
|
93
|
-
manifest: false
|
|
94
|
-
}));
|
|
95
|
-
}
|
|
96
|
-
return {
|
|
97
|
-
input: source.files,
|
|
98
|
-
plugins,
|
|
99
|
-
onwarn(warning, defaultWarn) {
|
|
100
|
-
// Removes annoying warnings for React-focused libraries that
|
|
101
|
-
// include 'use client' directives.
|
|
102
|
-
if (warning.code === 'MODULE_LEVEL_DIRECTIVE' && /['"]use client['"]/.test(warning.message)) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
defaultWarn(warning);
|
|
106
|
-
},
|
|
107
|
-
output: {
|
|
108
|
-
preserveModules: true,
|
|
109
|
-
preserveModulesRoot: source.root,
|
|
110
|
-
format: 'esm',
|
|
111
|
-
dir: outputDirectory,
|
|
112
|
-
entryFileNames: `[name].esnext`,
|
|
113
|
-
assetFileNames: `[name].[ext]`
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
async function sourceForPackage(root, packageJSON) {
|
|
118
|
-
const [entries] = await Promise.all([sourceEntriesForPackage(root, packageJSON)]);
|
|
119
|
-
let sourceRoot = root;
|
|
120
|
-
const sourceEntryFiles = Object.values(entries);
|
|
121
|
-
for (const entry of sourceEntryFiles) {
|
|
122
|
-
if (!entry.startsWith(root)) continue;
|
|
123
|
-
sourceRoot = path__namespace.resolve(root, path__namespace.relative(root, entry).split(path__namespace.sep)[0] ?? '.');
|
|
124
|
-
break;
|
|
125
|
-
}
|
|
126
|
-
return {
|
|
127
|
-
root: sourceRoot,
|
|
128
|
-
files: sourceEntryFiles
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
async function sourceEntriesForPackage(root, packageJSON) {
|
|
132
|
-
const {
|
|
133
|
-
main,
|
|
134
|
-
exports
|
|
135
|
-
} = packageJSON;
|
|
136
|
-
const entries = {};
|
|
137
|
-
if (typeof main === 'string') {
|
|
138
|
-
entries['.'] = await resolveTargetFileAsSource(main, root);
|
|
139
|
-
}
|
|
140
|
-
if (typeof exports === 'string') {
|
|
141
|
-
entries['.'] = await resolveTargetFileAsSource(exports, root);
|
|
142
|
-
return entries;
|
|
143
|
-
} else if (exports == null || typeof exports !== 'object') {
|
|
144
|
-
return entries;
|
|
145
|
-
}
|
|
146
|
-
for (const [exportPath, exportCondition] of Object.entries(exports)) {
|
|
147
|
-
let targetFile = null;
|
|
148
|
-
if (exportCondition == null) continue;
|
|
149
|
-
if (typeof exportCondition === 'string') {
|
|
150
|
-
targetFile = exportCondition;
|
|
151
|
-
} else {
|
|
152
|
-
targetFile ?? (targetFile = exportCondition['source'] ?? exportCondition['quilt:source'] ?? exportCondition['quilt:esnext'] ?? Object.values(exportCondition).find(condition => typeof condition === 'string' && condition.startsWith('./build/')));
|
|
153
|
-
}
|
|
154
|
-
if (targetFile == null) continue;
|
|
155
|
-
const sourceFile = await resolveTargetFileAsSource(targetFile, root);
|
|
156
|
-
entries[exportPath] = sourceFile;
|
|
157
|
-
}
|
|
158
|
-
return entries;
|
|
159
|
-
}
|
|
160
|
-
async function resolveTargetFileAsSource(file, root) {
|
|
161
|
-
const sourceFile = file.includes('/build/') ? (await glob.glob(file.replace(/[/]build[/][^/]+[/]/, '/*/').replace(/(\.d\.ts|\.[\w]+)$/, '.*'), {
|
|
162
|
-
cwd: root,
|
|
163
|
-
absolute: true,
|
|
164
|
-
ignore: [path__namespace.resolve(root, file)]
|
|
165
|
-
}))[0] : path__namespace.resolve(root, file);
|
|
166
|
-
return sourceFile;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
exports.quiltPackageESModules = quiltPackageESModules;
|
|
170
|
-
exports.quiltPackageESNext = quiltPackageESNext;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
async function getBrowserTargetDetails(targetSelection = {}, {
|
|
4
|
-
root
|
|
5
|
-
} = {}) {
|
|
6
|
-
const targets = Array.isArray(targetSelection) ? {
|
|
7
|
-
browsers: targetSelection
|
|
8
|
-
} : targetSelection;
|
|
9
|
-
const targetBrowsers = targets.browsers ?? (await (async () => {
|
|
10
|
-
const {
|
|
11
|
-
default: browserslist
|
|
12
|
-
} = await import('browserslist');
|
|
13
|
-
const config = browserslist.findConfig(root);
|
|
14
|
-
if (config == null) return ['defaults'];
|
|
15
|
-
const targetName = targets.name ?? 'defaults';
|
|
16
|
-
return config[targetName] ?? ['defaults'];
|
|
17
|
-
})());
|
|
18
|
-
const name = targets.name === 'defaults' ? 'default' : targets.name;
|
|
19
|
-
return {
|
|
20
|
-
name,
|
|
21
|
-
browsers: targetBrowsers
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
exports.getBrowserTargetDetails = getBrowserTargetDetails;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const VIRTUAL_MODULE_PREFIX = '\0';
|
|
4
|
-
const VIRTUAL_MODULE_POSTFIX = '/module.js';
|
|
5
|
-
function createMagicModulePlugin({
|
|
6
|
-
name,
|
|
7
|
-
module,
|
|
8
|
-
alias = `${VIRTUAL_MODULE_PREFIX}${module}${VIRTUAL_MODULE_POSTFIX}`,
|
|
9
|
-
source: getSource,
|
|
10
|
-
sideEffects = false
|
|
11
|
-
}) {
|
|
12
|
-
return {
|
|
13
|
-
name,
|
|
14
|
-
resolveId(id) {
|
|
15
|
-
if (id !== module) return null;
|
|
16
|
-
return {
|
|
17
|
-
id: alias,
|
|
18
|
-
moduleSideEffects: sideEffects ? 'no-treeshake' : undefined
|
|
19
|
-
};
|
|
20
|
-
},
|
|
21
|
-
load: getSource ? async function load(source) {
|
|
22
|
-
if (source !== alias) return null;
|
|
23
|
-
const code = await getSource.call(this);
|
|
24
|
-
return {
|
|
25
|
-
code,
|
|
26
|
-
moduleSideEffects: sideEffects ? 'no-treeshake' : undefined
|
|
27
|
-
};
|
|
28
|
-
} : undefined
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
exports.createMagicModulePlugin = createMagicModulePlugin;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var path = require('node:path');
|
|
4
|
-
var node_url = require('node:url');
|
|
5
|
-
var fs = require('node:fs/promises');
|
|
6
|
-
|
|
7
|
-
function _interopNamespaceDefault(e) {
|
|
8
|
-
var n = Object.create(null);
|
|
9
|
-
if (e) {
|
|
10
|
-
Object.keys(e).forEach(function (k) {
|
|
11
|
-
if (k !== 'default') {
|
|
12
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () { return e[k]; }
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
n["default"] = e;
|
|
21
|
-
return Object.freeze(n);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
25
|
-
|
|
26
|
-
async function loadPackageJSON(root) {
|
|
27
|
-
const file = await fs.readFile(path__namespace.join(typeof root === 'string' ? root : node_url.fileURLToPath(root), 'package.json'), 'utf8');
|
|
28
|
-
return JSON.parse(file);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
exports.loadPackageJSON = loadPackageJSON;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var fs = require('node:fs/promises');
|
|
4
|
-
var glob = require('glob');
|
|
5
|
-
var replace = require('@rollup/plugin-replace');
|
|
6
|
-
|
|
7
|
-
function _interopNamespaceDefault(e) {
|
|
8
|
-
var n = Object.create(null);
|
|
9
|
-
if (e) {
|
|
10
|
-
Object.keys(e).forEach(function (k) {
|
|
11
|
-
if (k !== 'default') {
|
|
12
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () { return e[k]; }
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
n["default"] = e;
|
|
21
|
-
return Object.freeze(n);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
|
|
25
|
-
|
|
26
|
-
function smartReplace(values, options) {
|
|
27
|
-
return replace({
|
|
28
|
-
// @see https://github.com/vitejs/vite/blob/2b1ffe86328f9d06ef9528ee117b61889893ddcc/packages/vite/src/node/plugins/define.ts#L108-L119
|
|
29
|
-
delimiters: ['(?<![\\p{L}\\p{N}_$]|(?<!\\.\\.)\\.)(', ')(?:(?<=\\.)|(?![\\p{L}\\p{N}_$]|\\s*?=[^=]))'],
|
|
30
|
-
preventAssignment: true,
|
|
31
|
-
...options,
|
|
32
|
-
values
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
function removeBuildFiles(patterns, {
|
|
36
|
-
root = process.cwd()
|
|
37
|
-
} = {}) {
|
|
38
|
-
return {
|
|
39
|
-
name: '@quilt/remove-build-files',
|
|
40
|
-
async buildStart() {
|
|
41
|
-
const matches = await glob.glob(patterns, {
|
|
42
|
-
cwd: root,
|
|
43
|
-
absolute: true
|
|
44
|
-
});
|
|
45
|
-
await Promise.all(matches.map(file => fs__namespace.rm(file, {
|
|
46
|
-
recursive: true,
|
|
47
|
-
force: true
|
|
48
|
-
})));
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
async function getNodePlugins() {
|
|
53
|
-
const [{
|
|
54
|
-
default: commonjs
|
|
55
|
-
}, {
|
|
56
|
-
default: json
|
|
57
|
-
}, {
|
|
58
|
-
default: nodeResolve
|
|
59
|
-
}, {
|
|
60
|
-
default: nodeExternals
|
|
61
|
-
}] = await Promise.all([import('@rollup/plugin-commonjs'), import('@rollup/plugin-json'), import('@rollup/plugin-node-resolve'), import('rollup-plugin-node-externals')]);
|
|
62
|
-
return [nodeExternals({}), nodeResolve({
|
|
63
|
-
preferBuiltins: true,
|
|
64
|
-
dedupe: []
|
|
65
|
-
// extensions,
|
|
66
|
-
// exportConditions,
|
|
67
|
-
}), commonjs(), json()];
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
exports.getNodePlugins = getNodePlugins;
|
|
71
|
-
exports.removeBuildFiles = removeBuildFiles;
|
|
72
|
-
exports.smartReplace = smartReplace;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function multiline(strings, ...values) {
|
|
4
|
-
let result = strings.reduce((combined, string, index) => `${combined}${string}${values[index] ?? ''}`, '');
|
|
5
|
-
|
|
6
|
-
// Inspired by https://github.com/zspecza/common-tags/blob/master/src/stripIndentTransformer/stripIndentTransformer.js#L8
|
|
7
|
-
const match = result.match(/^[^\S\n]*(?=\S)/gm);
|
|
8
|
-
const indent = match && Math.min(...match.map(indent => indent.length));
|
|
9
|
-
if (indent) {
|
|
10
|
-
const regexp = new RegExp(`^.{${indent}}`, 'gm');
|
|
11
|
-
result = result.replace(regexp, '');
|
|
12
|
-
}
|
|
13
|
-
return result.trim();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
exports.multiline = multiline;
|