@quilted/rollup 0.1.18 → 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 +25 -0
- package/build/esm/app.mjs +442 -233
- 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 +472 -109
- 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 -456
- 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 -429
- 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
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import * as path from 'node:path';
|
|
2
|
-
import { glob } from 'glob';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { getNodePlugins, removeBuildFiles } from './shared/rollup.esnext';
|
|
5
|
-
import { loadPackageJSON } from './shared/package-json.esnext';
|
|
6
|
-
import { getBrowserTargetDetails } from './shared/browserslist.esnext';
|
|
7
|
-
|
|
8
|
-
async function quiltModule({
|
|
9
|
-
root: rootPath = process.cwd(),
|
|
10
|
-
env,
|
|
11
|
-
assets,
|
|
12
|
-
graphql = true
|
|
13
|
-
} = {}) {
|
|
14
|
-
const root = typeof rootPath === 'string' ? rootPath : fileURLToPath(rootPath);
|
|
15
|
-
const mode = (typeof env === 'object' ? env?.mode : undefined) ?? 'production';
|
|
16
|
-
const outputDirectory = path.join(root, 'build/assets');
|
|
17
|
-
const minify = assets?.minify ?? true;
|
|
18
|
-
const hash = assets?.hash ?? 'async-only';
|
|
19
|
-
const browserTarget = await getBrowserTargetDetails(assets?.targets, {
|
|
20
|
-
root
|
|
21
|
-
});
|
|
22
|
-
const targetFilenamePart = browserTarget.name ? `.${browserTarget.name}` : '';
|
|
23
|
-
const [{
|
|
24
|
-
visualizer
|
|
25
|
-
}, {
|
|
26
|
-
magicModuleEnv,
|
|
27
|
-
replaceProcessEnv
|
|
28
|
-
}, {
|
|
29
|
-
sourceCode
|
|
30
|
-
}, nodePlugins, packageJSON] = await Promise.all([import('rollup-plugin-visualizer'), import('./features/env.esnext'), import('./features/source-code.esnext'), getNodePlugins(), loadPackageJSON(root)]);
|
|
31
|
-
const source = await sourceForModule(root, packageJSON);
|
|
32
|
-
const plugins = [...nodePlugins, replaceProcessEnv({
|
|
33
|
-
mode
|
|
34
|
-
}), magicModuleEnv({
|
|
35
|
-
...env,
|
|
36
|
-
mode
|
|
37
|
-
}), sourceCode({
|
|
38
|
-
mode: 'production',
|
|
39
|
-
targets: browserTarget.browsers
|
|
40
|
-
}), removeBuildFiles(['build/assets', 'build/reports'], {
|
|
41
|
-
root
|
|
42
|
-
})];
|
|
43
|
-
if (graphql) {
|
|
44
|
-
const {
|
|
45
|
-
graphql
|
|
46
|
-
} = await import('./features/graphql.esnext');
|
|
47
|
-
plugins.push(graphql({
|
|
48
|
-
manifest: false
|
|
49
|
-
}));
|
|
50
|
-
}
|
|
51
|
-
if (minify) {
|
|
52
|
-
const {
|
|
53
|
-
minify
|
|
54
|
-
} = await import('rollup-plugin-esbuild');
|
|
55
|
-
plugins.push(minify());
|
|
56
|
-
}
|
|
57
|
-
plugins.push(visualizer({
|
|
58
|
-
template: 'treemap',
|
|
59
|
-
open: false,
|
|
60
|
-
brotliSize: true,
|
|
61
|
-
filename: path.resolve(root, `build/reports/bundle-visualizer${targetFilenamePart}.html`)
|
|
62
|
-
}));
|
|
63
|
-
return {
|
|
64
|
-
input: source,
|
|
65
|
-
plugins,
|
|
66
|
-
onwarn(warning, defaultWarn) {
|
|
67
|
-
// Removes annoying warnings for React-focused libraries that
|
|
68
|
-
// include 'use client' directives.
|
|
69
|
-
if (warning.code === 'MODULE_LEVEL_DIRECTIVE' && /['"]use client['"]/.test(warning.message)) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
defaultWarn(warning);
|
|
73
|
-
},
|
|
74
|
-
output: {
|
|
75
|
-
format: 'esm',
|
|
76
|
-
dir: outputDirectory,
|
|
77
|
-
entryFileNames: `[name]${targetFilenamePart}${hash === true ? `.[hash]` : ''}.js`,
|
|
78
|
-
chunkFileNames: `[name]${targetFilenamePart}${hash === true || hash === 'async-only' ? `.[hash]` : ''}.js`,
|
|
79
|
-
assetFileNames: `[name]${targetFilenamePart}${hash === true ? `.[hash]` : ''}.[ext]`
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
async function sourceForModule(root, packageJSON) {
|
|
84
|
-
const {
|
|
85
|
-
main,
|
|
86
|
-
exports
|
|
87
|
-
} = packageJSON;
|
|
88
|
-
const entryFromPackageJSON = main ?? exports?.['.'];
|
|
89
|
-
if (entryFromPackageJSON) {
|
|
90
|
-
return path.resolve(root, entryFromPackageJSON);
|
|
91
|
-
}
|
|
92
|
-
const possibleSourceFiles = await glob('{index,module,entry,input}.{ts,tsx,mjs,js,jsx}', {
|
|
93
|
-
cwd: root,
|
|
94
|
-
nodir: true,
|
|
95
|
-
absolute: true
|
|
96
|
-
});
|
|
97
|
-
return possibleSourceFiles[0];
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export { quiltModule };
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import * as path from 'node:path';
|
|
2
|
-
import { glob } from 'glob';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { getNodePlugins, removeBuildFiles } from './shared/rollup.esnext';
|
|
5
|
-
import { loadPackageJSON } from './shared/package-json.esnext';
|
|
6
|
-
|
|
7
|
-
async function quiltPackageESModules({
|
|
8
|
-
root: rootPath = process.cwd(),
|
|
9
|
-
graphql = true
|
|
10
|
-
} = {}) {
|
|
11
|
-
const root = typeof rootPath === 'string' ? rootPath : fileURLToPath(rootPath);
|
|
12
|
-
const outputDirectory = path.join(root, 'build/esm');
|
|
13
|
-
const [{
|
|
14
|
-
sourceCode
|
|
15
|
-
}, nodePlugins, packageJSON] = await Promise.all([import('./features/source-code.esnext'), getNodePlugins(), loadPackageJSON(root)]);
|
|
16
|
-
const source = await sourceForPackage(root, packageJSON);
|
|
17
|
-
const plugins = [...nodePlugins, sourceCode({
|
|
18
|
-
mode: 'production'
|
|
19
|
-
}), removeBuildFiles(['build/esm'], {
|
|
20
|
-
root
|
|
21
|
-
})];
|
|
22
|
-
if (graphql) {
|
|
23
|
-
const {
|
|
24
|
-
graphql
|
|
25
|
-
} = await import('./features/graphql.esnext');
|
|
26
|
-
plugins.push(graphql({
|
|
27
|
-
manifest: false
|
|
28
|
-
}));
|
|
29
|
-
}
|
|
30
|
-
return {
|
|
31
|
-
input: source.files,
|
|
32
|
-
plugins,
|
|
33
|
-
onwarn(warning, defaultWarn) {
|
|
34
|
-
// Removes annoying warnings for React-focused libraries that
|
|
35
|
-
// include 'use client' directives.
|
|
36
|
-
if (warning.code === 'MODULE_LEVEL_DIRECTIVE' && /['"]use client['"]/.test(warning.message)) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
defaultWarn(warning);
|
|
40
|
-
},
|
|
41
|
-
output: {
|
|
42
|
-
preserveModules: true,
|
|
43
|
-
preserveModulesRoot: source.root,
|
|
44
|
-
format: 'esm',
|
|
45
|
-
dir: outputDirectory,
|
|
46
|
-
entryFileNames: `[name].mjs`,
|
|
47
|
-
assetFileNames: `[name].[ext]`
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
async function quiltPackageESNext({
|
|
52
|
-
root: rootPath = process.cwd(),
|
|
53
|
-
graphql = true
|
|
54
|
-
} = {}) {
|
|
55
|
-
const root = typeof rootPath === 'string' ? rootPath : fileURLToPath(rootPath);
|
|
56
|
-
const outputDirectory = path.join(root, 'build/esnext');
|
|
57
|
-
const [{
|
|
58
|
-
sourceCode
|
|
59
|
-
}, nodePlugins, packageJSON] = await Promise.all([import('./features/source-code.esnext'), getNodePlugins(), loadPackageJSON(root)]);
|
|
60
|
-
const source = await sourceForPackage(root, packageJSON);
|
|
61
|
-
const plugins = [...nodePlugins, sourceCode({
|
|
62
|
-
mode: 'production',
|
|
63
|
-
babel: false
|
|
64
|
-
}), removeBuildFiles(['build/esnext'], {
|
|
65
|
-
root
|
|
66
|
-
})];
|
|
67
|
-
if (graphql) {
|
|
68
|
-
const {
|
|
69
|
-
graphql
|
|
70
|
-
} = await import('./features/graphql.esnext');
|
|
71
|
-
plugins.push(graphql({
|
|
72
|
-
manifest: false
|
|
73
|
-
}));
|
|
74
|
-
}
|
|
75
|
-
return {
|
|
76
|
-
input: source.files,
|
|
77
|
-
plugins,
|
|
78
|
-
onwarn(warning, defaultWarn) {
|
|
79
|
-
// Removes annoying warnings for React-focused libraries that
|
|
80
|
-
// include 'use client' directives.
|
|
81
|
-
if (warning.code === 'MODULE_LEVEL_DIRECTIVE' && /['"]use client['"]/.test(warning.message)) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
defaultWarn(warning);
|
|
85
|
-
},
|
|
86
|
-
output: {
|
|
87
|
-
preserveModules: true,
|
|
88
|
-
preserveModulesRoot: source.root,
|
|
89
|
-
format: 'esm',
|
|
90
|
-
dir: outputDirectory,
|
|
91
|
-
entryFileNames: `[name].esnext`,
|
|
92
|
-
assetFileNames: `[name].[ext]`
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
async function sourceForPackage(root, packageJSON) {
|
|
97
|
-
const [entries] = await Promise.all([sourceEntriesForPackage(root, packageJSON)]);
|
|
98
|
-
let sourceRoot = root;
|
|
99
|
-
const sourceEntryFiles = Object.values(entries);
|
|
100
|
-
for (const entry of sourceEntryFiles) {
|
|
101
|
-
if (!entry.startsWith(root)) continue;
|
|
102
|
-
sourceRoot = path.resolve(root, path.relative(root, entry).split(path.sep)[0] ?? '.');
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
return {
|
|
106
|
-
root: sourceRoot,
|
|
107
|
-
files: sourceEntryFiles
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
async function sourceEntriesForPackage(root, packageJSON) {
|
|
111
|
-
const {
|
|
112
|
-
main,
|
|
113
|
-
exports
|
|
114
|
-
} = packageJSON;
|
|
115
|
-
const entries = {};
|
|
116
|
-
if (typeof main === 'string') {
|
|
117
|
-
entries['.'] = await resolveTargetFileAsSource(main, root);
|
|
118
|
-
}
|
|
119
|
-
if (typeof exports === 'string') {
|
|
120
|
-
entries['.'] = await resolveTargetFileAsSource(exports, root);
|
|
121
|
-
return entries;
|
|
122
|
-
} else if (exports == null || typeof exports !== 'object') {
|
|
123
|
-
return entries;
|
|
124
|
-
}
|
|
125
|
-
for (const [exportPath, exportCondition] of Object.entries(exports)) {
|
|
126
|
-
let targetFile = null;
|
|
127
|
-
if (exportCondition == null) continue;
|
|
128
|
-
if (typeof exportCondition === 'string') {
|
|
129
|
-
targetFile = exportCondition;
|
|
130
|
-
} else {
|
|
131
|
-
targetFile ??= exportCondition['source'] ?? exportCondition['quilt:source'] ?? exportCondition['quilt:esnext'] ?? Object.values(exportCondition).find(condition => typeof condition === 'string' && condition.startsWith('./build/'));
|
|
132
|
-
}
|
|
133
|
-
if (targetFile == null) continue;
|
|
134
|
-
const sourceFile = await resolveTargetFileAsSource(targetFile, root);
|
|
135
|
-
entries[exportPath] = sourceFile;
|
|
136
|
-
}
|
|
137
|
-
return entries;
|
|
138
|
-
}
|
|
139
|
-
async function resolveTargetFileAsSource(file, root) {
|
|
140
|
-
const sourceFile = file.includes('/build/') ? (await glob(file.replace(/[/]build[/][^/]+[/]/, '/*/').replace(/(\.d\.ts|\.[\w]+)$/, '.*'), {
|
|
141
|
-
cwd: root,
|
|
142
|
-
absolute: true,
|
|
143
|
-
ignore: [path.resolve(root, file)]
|
|
144
|
-
}))[0] : path.resolve(root, file);
|
|
145
|
-
return sourceFile;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export { quiltPackageESModules, quiltPackageESNext };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
async function getBrowserTargetDetails(targetSelection = {}, {
|
|
2
|
-
root
|
|
3
|
-
} = {}) {
|
|
4
|
-
const targets = Array.isArray(targetSelection) ? {
|
|
5
|
-
browsers: targetSelection
|
|
6
|
-
} : targetSelection;
|
|
7
|
-
const targetBrowsers = targets.browsers ?? (await (async () => {
|
|
8
|
-
const {
|
|
9
|
-
default: browserslist
|
|
10
|
-
} = await import('browserslist');
|
|
11
|
-
const config = browserslist.findConfig(root);
|
|
12
|
-
if (config == null) return ['defaults'];
|
|
13
|
-
const targetName = targets.name ?? 'defaults';
|
|
14
|
-
return config[targetName] ?? ['defaults'];
|
|
15
|
-
})());
|
|
16
|
-
const name = targets.name === 'defaults' ? 'default' : targets.name;
|
|
17
|
-
return {
|
|
18
|
-
name,
|
|
19
|
-
browsers: targetBrowsers
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export { getBrowserTargetDetails };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const VIRTUAL_MODULE_PREFIX = '\0';
|
|
2
|
-
const VIRTUAL_MODULE_POSTFIX = '/module.js';
|
|
3
|
-
function createMagicModulePlugin({
|
|
4
|
-
name,
|
|
5
|
-
module,
|
|
6
|
-
alias = `${VIRTUAL_MODULE_PREFIX}${module}${VIRTUAL_MODULE_POSTFIX}`,
|
|
7
|
-
source: getSource,
|
|
8
|
-
sideEffects = false
|
|
9
|
-
}) {
|
|
10
|
-
return {
|
|
11
|
-
name,
|
|
12
|
-
resolveId(id) {
|
|
13
|
-
if (id !== module) return null;
|
|
14
|
-
return {
|
|
15
|
-
id: alias,
|
|
16
|
-
moduleSideEffects: sideEffects ? 'no-treeshake' : undefined
|
|
17
|
-
};
|
|
18
|
-
},
|
|
19
|
-
load: getSource ? async function load(source) {
|
|
20
|
-
if (source !== alias) return null;
|
|
21
|
-
const code = await getSource.call(this);
|
|
22
|
-
return {
|
|
23
|
-
code,
|
|
24
|
-
moduleSideEffects: sideEffects ? 'no-treeshake' : undefined
|
|
25
|
-
};
|
|
26
|
-
} : undefined
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { createMagicModulePlugin };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as path from 'node:path';
|
|
2
|
-
import { fileURLToPath } from 'node:url';
|
|
3
|
-
import { readFile } from 'node:fs/promises';
|
|
4
|
-
|
|
5
|
-
async function loadPackageJSON(root) {
|
|
6
|
-
const file = await readFile(path.join(typeof root === 'string' ? root : fileURLToPath(root), 'package.json'), 'utf8');
|
|
7
|
-
return JSON.parse(file);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export { loadPackageJSON };
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import * as fs from 'node:fs/promises';
|
|
2
|
-
import { glob } from 'glob';
|
|
3
|
-
import replace from '@rollup/plugin-replace';
|
|
4
|
-
|
|
5
|
-
function smartReplace(values, options) {
|
|
6
|
-
return replace({
|
|
7
|
-
// @see https://github.com/vitejs/vite/blob/2b1ffe86328f9d06ef9528ee117b61889893ddcc/packages/vite/src/node/plugins/define.ts#L108-L119
|
|
8
|
-
delimiters: ['(?<![\\p{L}\\p{N}_$]|(?<!\\.\\.)\\.)(', ')(?:(?<=\\.)|(?![\\p{L}\\p{N}_$]|\\s*?=[^=]))'],
|
|
9
|
-
preventAssignment: true,
|
|
10
|
-
...options,
|
|
11
|
-
values
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
function removeBuildFiles(patterns, {
|
|
15
|
-
root = process.cwd()
|
|
16
|
-
} = {}) {
|
|
17
|
-
return {
|
|
18
|
-
name: '@quilt/remove-build-files',
|
|
19
|
-
async buildStart() {
|
|
20
|
-
const matches = await glob(patterns, {
|
|
21
|
-
cwd: root,
|
|
22
|
-
absolute: true
|
|
23
|
-
});
|
|
24
|
-
await Promise.all(matches.map(file => fs.rm(file, {
|
|
25
|
-
recursive: true,
|
|
26
|
-
force: true
|
|
27
|
-
})));
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
async function getNodePlugins() {
|
|
32
|
-
const [{
|
|
33
|
-
default: commonjs
|
|
34
|
-
}, {
|
|
35
|
-
default: json
|
|
36
|
-
}, {
|
|
37
|
-
default: nodeResolve
|
|
38
|
-
}, {
|
|
39
|
-
default: nodeExternals
|
|
40
|
-
}] = await Promise.all([import('@rollup/plugin-commonjs'), import('@rollup/plugin-json'), import('@rollup/plugin-node-resolve'), import('rollup-plugin-node-externals')]);
|
|
41
|
-
return [nodeExternals({}), nodeResolve({
|
|
42
|
-
preferBuiltins: true,
|
|
43
|
-
dedupe: []
|
|
44
|
-
// extensions,
|
|
45
|
-
// exportConditions,
|
|
46
|
-
}), commonjs(), json()];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export { getNodePlugins, removeBuildFiles, smartReplace };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
function multiline(strings, ...values) {
|
|
2
|
-
let result = strings.reduce((combined, string, index) => `${combined}${string}${values[index] ?? ''}`, '');
|
|
3
|
-
|
|
4
|
-
// Inspired by https://github.com/zspecza/common-tags/blob/master/src/stripIndentTransformer/stripIndentTransformer.js#L8
|
|
5
|
-
const match = result.match(/^[^\S\n]*(?=\S)/gm);
|
|
6
|
-
const indent = match && Math.min(...match.map(indent => indent.length));
|
|
7
|
-
if (indent) {
|
|
8
|
-
const regexp = new RegExp(`^.{${indent}}`, 'gm');
|
|
9
|
-
result = result.replace(regexp, '');
|
|
10
|
-
}
|
|
11
|
-
return result.trim();
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { multiline };
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { PluginContext } from 'rollup';
|
|
2
|
-
export declare function replaceProcessEnv({ mode, preserve, }: {
|
|
3
|
-
mode: string;
|
|
4
|
-
preserve?: boolean;
|
|
5
|
-
}): import("rollup").Plugin<any>;
|
|
6
|
-
export interface MagicModuleEnvOptions {
|
|
7
|
-
/**
|
|
8
|
-
* The runtime mode for your target environment.
|
|
9
|
-
*/
|
|
10
|
-
mode?: 'production' | 'development';
|
|
11
|
-
/**
|
|
12
|
-
* Environment variables from the build environment to inline into the magic
|
|
13
|
-
* module. Be careful when using this option! Inlining environment variables
|
|
14
|
-
* into your application always comes with the risk of exposing sensitive information
|
|
15
|
-
* to your users. Only use this option for environment variables that are safe
|
|
16
|
-
* for a human to see if they open their browser developer tools.
|
|
17
|
-
*/
|
|
18
|
-
inline?: string[];
|
|
19
|
-
/**
|
|
20
|
-
* A string that will be inlined directly as code to reference a runtime variable
|
|
21
|
-
* that contains environment variables.
|
|
22
|
-
*/
|
|
23
|
-
runtime?: string;
|
|
24
|
-
/**
|
|
25
|
-
* Whether to load environment variables from a `.env` file. The option can
|
|
26
|
-
* be one of the following types:
|
|
27
|
-
*
|
|
28
|
-
* - `false`, which disables loading environment variables from a `.env` file.
|
|
29
|
-
* - An object containing a `roots` field, specifying the directories to search
|
|
30
|
-
* for `.env` files in.
|
|
31
|
-
* - An object containing a `files` field, specifying the directories to search
|
|
32
|
-
* for `.env` files in.
|
|
33
|
-
*
|
|
34
|
-
* @default {roots: ['.', 'configuration']}
|
|
35
|
-
*/
|
|
36
|
-
dotenv?: false | {
|
|
37
|
-
roots?: string[];
|
|
38
|
-
files?: never;
|
|
39
|
-
} | {
|
|
40
|
-
roots?: never;
|
|
41
|
-
files?: string[];
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
export declare function magicModuleEnv({ mode, dotenv, inline, runtime, }?: MagicModuleEnvOptions): {
|
|
45
|
-
name: string;
|
|
46
|
-
resolveId(this: PluginContext, id: string): {
|
|
47
|
-
id: string;
|
|
48
|
-
moduleSideEffects: "no-treeshake" | undefined;
|
|
49
|
-
} | null;
|
|
50
|
-
load: ((this: PluginContext, source: string) => Promise<{
|
|
51
|
-
code: string;
|
|
52
|
-
moduleSideEffects: "no-treeshake" | undefined;
|
|
53
|
-
} | null>) | undefined;
|
|
54
|
-
};
|
|
55
|
-
//# sourceMappingURL=env.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../source/env.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,QAAQ,CAAC;AAa1C,wBAAgB,iBAAiB,CAAC,EAChC,IAAI,EACJ,QAAe,GAChB,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,gCAQA;AAED,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,IAAI,CAAC,EAAE,YAAY,GAAG,aAAa,CAAC;IAEpC;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAElB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,EACH,KAAK,GACL;QAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,CAAC,EAAE,KAAK,CAAA;KAAC,GACjC;QAAC,KAAK,CAAC,EAAE,KAAK,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;KAAC,CAAC;CACvC;AAED,wBAAgB,cAAc,CAAC,EAC7B,IAAI,EACJ,MAAwC,EACxC,MAAW,EACX,OAAc,GACf,GAAE,qBAA0B;;;;;;;;;;EA0C5B"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { DocumentNode, TypedQueryDocumentNode } from 'graphql';
|
|
2
|
-
import type { GraphQLOperation } from '@quilted/graphql';
|
|
3
|
-
export interface EnhancedDocumentNode<Data = Record<string, any>, Variables = Record<string, any>> extends TypedQueryDocumentNode<Data, Variables> {
|
|
4
|
-
readonly id: string;
|
|
5
|
-
}
|
|
6
|
-
export declare function cleanGraphQLDocument<Data = Record<string, any>, Variables = Record<string, any>>(document: DocumentNode | TypedQueryDocumentNode<Data, Variables>, { removeUnused }?: {
|
|
7
|
-
removeUnused?: boolean | {
|
|
8
|
-
exclude: Set<string>;
|
|
9
|
-
};
|
|
10
|
-
}): EnhancedDocumentNode<Data, Variables>;
|
|
11
|
-
export declare function extractGraphQLImports(rawSource: string): {
|
|
12
|
-
imports: string[];
|
|
13
|
-
source: string;
|
|
14
|
-
};
|
|
15
|
-
export declare function toGraphQLOperation<Data = unknown, Variables = unknown>(documentOrSource: EnhancedDocumentNode<Data, Variables> | string): GraphQLOperation<Data, Variables>;
|
|
16
|
-
export declare function minifyGraphQLSource(source: string): string;
|
|
17
|
-
//# sourceMappingURL=transform.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../source/graphql/transform.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,YAAY,EACZ,sBAAsB,EAOvB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAKvD,MAAM,WAAW,oBAAoB,CACnC,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1B,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAC/B,SAAQ,sBAAsB,CAAC,IAAI,EAAE,SAAS,CAAC;IAC/C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,oBAAoB,CAClC,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1B,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAE/B,QAAQ,EAAE,YAAY,GAAG,sBAAsB,CAAC,IAAI,EAAE,SAAS,CAAC,EAChE,EAAC,YAAmB,EAAC,GAAE;IAAC,YAAY,CAAC,EAAE,OAAO,GAAG;QAAC,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;KAAC,CAAA;CAAM,GAC5E,oBAAoB,CAAC,IAAI,EAAE,SAAS,CAAC,CAsCvC;AAED,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM;;;EAStD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,GAAG,OAAO,EAAE,SAAS,GAAG,OAAO,EACpE,gBAAgB,EAAE,oBAAoB,CAAC,IAAI,EAAE,SAAS,CAAC,GAAG,MAAM,GAC/D,gBAAgB,CAAC,IAAI,EAAE,SAAS,CAAC,CAWnC;AAqLD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,UAMjD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../source/graphql.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAyB,MAAM,QAAQ,CAAC;AAQ3D,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC7B;AAED,wBAAgB,OAAO,CAAC,EAAC,QAAQ,EAAC,GAAE,OAAY,GAAG,MAAM,CAiExD"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare function magicModuleRequestRouterEntry({ host, port, }?: {
|
|
2
|
-
host?: string;
|
|
3
|
-
port?: number;
|
|
4
|
-
}): {
|
|
5
|
-
name: string;
|
|
6
|
-
resolveId(this: import("rollup").PluginContext, id: string): {
|
|
7
|
-
id: string;
|
|
8
|
-
moduleSideEffects: "no-treeshake" | undefined;
|
|
9
|
-
} | null;
|
|
10
|
-
load: ((this: import("rollup").PluginContext, source: string) => Promise<{
|
|
11
|
-
code: string;
|
|
12
|
-
moduleSideEffects: "no-treeshake" | undefined;
|
|
13
|
-
} | null>) | undefined;
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=request-router.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"request-router.d.ts","sourceRoot":"","sources":["../../source/request-router.ts"],"names":[],"mappings":"AAKA,wBAAgB,6BAA6B,CAAC,EAC5C,IAAI,EACJ,IAAI,GACL,GAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACV;;;;;;;;;;EAsBL"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"source-code.d.ts","sourceRoot":"","sources":["../../../source/shared/source-code.ts"],"names":[],"mappings":"AAMA,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,OAAO,GACR,EAAE;IACD,IAAI,CAAC,EAAE,aAAa,GAAG,YAAY,CAAC;IACpC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,gCAmDA"}
|