@quilted/rollup 0.1.19 → 0.2.1
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 +27 -0
- package/build/esm/app.mjs +450 -222
- 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 +29 -20
- 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 +132 -29
- 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/system-js.d.ts +4 -1
- package/build/typescript/features/system-js.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 +62 -9
- package/source/app.ts +475 -99
- 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 +27 -9
- package/source/features/system-js.ts +25 -2
- 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
|
@@ -1,23 +1,148 @@
|
|
|
1
|
-
async function
|
|
2
|
-
|
|
3
|
-
} = {}) {
|
|
1
|
+
async function getBrowserGroupTargetDetails(targetSelection = {}, { root } = {}) {
|
|
2
|
+
const { default: browserslist } = await import('browserslist');
|
|
4
3
|
const targets = Array.isArray(targetSelection) ? {
|
|
5
4
|
browsers: targetSelection
|
|
6
5
|
} : targetSelection;
|
|
7
|
-
const targetBrowsers = targets.browsers ??
|
|
8
|
-
const {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
const targetBrowsers = targets.browsers ?? await (async () => {
|
|
7
|
+
const config = await getBrowserGroups({ root });
|
|
8
|
+
const targetName = targets.name ?? "default";
|
|
9
|
+
return config[targetName] ?? ["defaults"];
|
|
10
|
+
})();
|
|
11
|
+
return { name: targets.name, browsers: browserslist(targetBrowsers) };
|
|
12
|
+
}
|
|
13
|
+
async function getBrowserGroups({
|
|
14
|
+
root = process.cwd()
|
|
15
|
+
} = {}) {
|
|
16
|
+
const { default: browserslist } = await import('browserslist');
|
|
17
|
+
const config = browserslist.findConfig(root);
|
|
18
|
+
if (config == null)
|
|
19
|
+
return { default: browserslist(["defaults"]) };
|
|
20
|
+
const { defaults, ...rest } = config;
|
|
21
|
+
const browserGroups = {};
|
|
22
|
+
const groupsWithFullList = Object.entries(rest).map(([name, browsers]) => ({
|
|
23
|
+
name,
|
|
24
|
+
browsers: browserslist(browsers)
|
|
25
|
+
})).sort((first, second) => first.browsers.length - second.browsers.length);
|
|
26
|
+
for (const { name, browsers } of groupsWithFullList) {
|
|
27
|
+
browserGroups[name] = browsers;
|
|
28
|
+
}
|
|
29
|
+
browserGroups.default = defaults;
|
|
30
|
+
return browserGroups;
|
|
31
|
+
}
|
|
32
|
+
async function getBrowserGroupRegularExpressions(groups) {
|
|
33
|
+
const [{ default: browserslist }, { getUserAgentRegex }] = await Promise.all([
|
|
34
|
+
import('browserslist'),
|
|
35
|
+
import('browserslist-useragent-regexp')
|
|
36
|
+
]);
|
|
37
|
+
const groupsWithFullList = Object.entries(
|
|
38
|
+
groups ?? await getBrowserGroups()
|
|
39
|
+
).map(([name, browsers]) => ({
|
|
18
40
|
name,
|
|
19
|
-
browsers:
|
|
41
|
+
browsers: browserslist(browsers)
|
|
42
|
+
})).sort((first, second) => first.browsers.length - second.browsers.length);
|
|
43
|
+
if (groupsWithFullList.length === 0)
|
|
44
|
+
return {};
|
|
45
|
+
const lastGroup = groupsWithFullList.pop();
|
|
46
|
+
const regexes = {};
|
|
47
|
+
for (const { name, browsers } of groupsWithFullList) {
|
|
48
|
+
const regex = getUserAgentRegex({
|
|
49
|
+
browsers,
|
|
50
|
+
ignoreMinor: true,
|
|
51
|
+
ignorePatch: true,
|
|
52
|
+
allowHigherVersions: true
|
|
53
|
+
});
|
|
54
|
+
regexes[name] = regex;
|
|
55
|
+
}
|
|
56
|
+
regexes[lastGroup.name] = new RegExp("");
|
|
57
|
+
return regexes;
|
|
58
|
+
}
|
|
59
|
+
let esmBrowserslist;
|
|
60
|
+
async function targetsSupportModules(targets) {
|
|
61
|
+
esmBrowserslist ??= (async () => {
|
|
62
|
+
const { default: browserslist } = await import('browserslist');
|
|
63
|
+
return new Set(
|
|
64
|
+
browserslist(
|
|
65
|
+
"defaults and fully supports es6-module and fully supports es6-module-dynamic-import"
|
|
66
|
+
)
|
|
67
|
+
);
|
|
68
|
+
})();
|
|
69
|
+
const esmBrowsers = await esmBrowserslist;
|
|
70
|
+
return targets.every((target) => esmBrowsers.has(target));
|
|
71
|
+
}
|
|
72
|
+
const BROWSESLIST_BROWSER_TO_MDN_BROWSER = /* @__PURE__ */ new Map([
|
|
73
|
+
["and_chr", "chrome_android"],
|
|
74
|
+
["and_ff", "firefox_android"],
|
|
75
|
+
["and_qq", "qq_android"],
|
|
76
|
+
["and_uc", "uc_android"],
|
|
77
|
+
["android", "webview_android"],
|
|
78
|
+
["chrome", "chrome"],
|
|
79
|
+
["edge", "edge"],
|
|
80
|
+
["edge_mob", "edge_mobile"],
|
|
81
|
+
["firefox", "firefox"],
|
|
82
|
+
["ie", "ie"],
|
|
83
|
+
["ios_saf", "safari_ios"],
|
|
84
|
+
["node", "nodejs"],
|
|
85
|
+
["opera", "opera"],
|
|
86
|
+
["safari", "safari"],
|
|
87
|
+
["samsung", "samsunginternet_android"]
|
|
88
|
+
]);
|
|
89
|
+
async function rollupGenerateOptionsForBrowsers(browsers) {
|
|
90
|
+
const [{ default: semver }, { default: mdn }] = await Promise.all([
|
|
91
|
+
import('semver'),
|
|
92
|
+
import('@mdn/browser-compat-data', { assert: { type: 'json' } })
|
|
93
|
+
]);
|
|
94
|
+
const arrowFunctionsSupport = mdn.javascript.functions.arrow_functions.__compat.support;
|
|
95
|
+
const constBindingsSupport = mdn.javascript.statements.const.__compat.support;
|
|
96
|
+
const objectShorthandSupport = mdn.javascript.grammar.shorthand_object_literals.__compat.support;
|
|
97
|
+
const symbolsSupport = mdn.javascript.builtins.Symbol.__compat.support;
|
|
98
|
+
let arrowFunctions = true;
|
|
99
|
+
let constBindings = true;
|
|
100
|
+
let objectShorthand = true;
|
|
101
|
+
let symbols = true;
|
|
102
|
+
const isSupported = (browser, version, supportList) => {
|
|
103
|
+
const supportedVersionDetails = supportList[browser];
|
|
104
|
+
if (supportedVersionDetails == null)
|
|
105
|
+
return false;
|
|
106
|
+
const supportedVersion = semver.coerce(
|
|
107
|
+
supportedVersionDetails.version_added
|
|
108
|
+
);
|
|
109
|
+
if (supportedVersion == null)
|
|
110
|
+
return false;
|
|
111
|
+
return semver.gte(version, supportedVersion);
|
|
112
|
+
};
|
|
113
|
+
for (const browser of browsers) {
|
|
114
|
+
const [name, version] = browser.split(" ");
|
|
115
|
+
const semverVersion = semver.coerce(version);
|
|
116
|
+
if (semverVersion == null)
|
|
117
|
+
continue;
|
|
118
|
+
const mdnBrowser = BROWSESLIST_BROWSER_TO_MDN_BROWSER.get(name);
|
|
119
|
+
if (mdnBrowser == null)
|
|
120
|
+
continue;
|
|
121
|
+
arrowFunctions &&= isSupported(
|
|
122
|
+
mdnBrowser,
|
|
123
|
+
semverVersion,
|
|
124
|
+
arrowFunctionsSupport
|
|
125
|
+
);
|
|
126
|
+
constBindings &&= isSupported(
|
|
127
|
+
mdnBrowser,
|
|
128
|
+
semverVersion,
|
|
129
|
+
constBindingsSupport
|
|
130
|
+
);
|
|
131
|
+
objectShorthand &&= isSupported(
|
|
132
|
+
mdnBrowser,
|
|
133
|
+
semverVersion,
|
|
134
|
+
objectShorthandSupport
|
|
135
|
+
);
|
|
136
|
+
symbols &&= isSupported(mdnBrowser, semverVersion, symbolsSupport);
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
preset: "es2015",
|
|
140
|
+
arrowFunctions,
|
|
141
|
+
constBindings,
|
|
142
|
+
objectShorthand,
|
|
143
|
+
reservedNamesAsProps: objectShorthand,
|
|
144
|
+
symbols
|
|
20
145
|
};
|
|
21
146
|
}
|
|
22
147
|
|
|
23
|
-
export {
|
|
148
|
+
export { getBrowserGroupRegularExpressions, getBrowserGroupTargetDetails, getBrowserGroups, rollupGenerateOptionsForBrowsers, targetsSupportModules };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const VIRTUAL_MODULE_PREFIX =
|
|
2
|
-
const VIRTUAL_MODULE_POSTFIX =
|
|
1
|
+
const VIRTUAL_MODULE_PREFIX = "\0";
|
|
2
|
+
const VIRTUAL_MODULE_POSTFIX = "/module.js";
|
|
3
3
|
function createMagicModulePlugin({
|
|
4
4
|
name,
|
|
5
5
|
module,
|
|
@@ -10,20 +10,22 @@ function createMagicModulePlugin({
|
|
|
10
10
|
return {
|
|
11
11
|
name,
|
|
12
12
|
resolveId(id) {
|
|
13
|
-
if (id !== module)
|
|
13
|
+
if (id !== module)
|
|
14
|
+
return null;
|
|
14
15
|
return {
|
|
15
16
|
id: alias,
|
|
16
|
-
moduleSideEffects: sideEffects ?
|
|
17
|
+
moduleSideEffects: sideEffects ? "no-treeshake" : void 0
|
|
17
18
|
};
|
|
18
19
|
},
|
|
19
20
|
load: getSource ? async function load(source) {
|
|
20
|
-
if (source !== alias)
|
|
21
|
+
if (source !== alias)
|
|
22
|
+
return null;
|
|
21
23
|
const code = await getSource.call(this);
|
|
22
24
|
return {
|
|
23
25
|
code,
|
|
24
|
-
moduleSideEffects: sideEffects ?
|
|
26
|
+
moduleSideEffects: sideEffects ? "no-treeshake" : void 0
|
|
25
27
|
};
|
|
26
|
-
} :
|
|
28
|
+
} : void 0
|
|
27
29
|
};
|
|
28
30
|
}
|
|
29
31
|
|
|
@@ -3,7 +3,13 @@ import { fileURLToPath } from 'node:url';
|
|
|
3
3
|
import { readFile } from 'node:fs/promises';
|
|
4
4
|
|
|
5
5
|
async function loadPackageJSON(root) {
|
|
6
|
-
const file = await readFile(
|
|
6
|
+
const file = await readFile(
|
|
7
|
+
path.join(
|
|
8
|
+
typeof root === "string" ? root : fileURLToPath(root),
|
|
9
|
+
"package.json"
|
|
10
|
+
),
|
|
11
|
+
"utf8"
|
|
12
|
+
);
|
|
7
13
|
return JSON.parse(file);
|
|
8
14
|
}
|
|
9
15
|
|
|
@@ -5,45 +5,109 @@ import replace from '@rollup/plugin-replace';
|
|
|
5
5
|
function smartReplace(values, options) {
|
|
6
6
|
return replace({
|
|
7
7
|
// @see https://github.com/vitejs/vite/blob/2b1ffe86328f9d06ef9528ee117b61889893ddcc/packages/vite/src/node/plugins/define.ts#L108-L119
|
|
8
|
-
delimiters: [
|
|
8
|
+
delimiters: [
|
|
9
|
+
"(?<![\\p{L}\\p{N}_$]|(?<!\\.\\.)\\.)(",
|
|
10
|
+
")(?:(?<=\\.)|(?![\\p{L}\\p{N}_$]|\\s*?=[^=]))"
|
|
11
|
+
],
|
|
9
12
|
preventAssignment: true,
|
|
10
13
|
...options,
|
|
11
14
|
values
|
|
12
15
|
});
|
|
13
16
|
}
|
|
14
|
-
function removeBuildFiles(patterns, {
|
|
15
|
-
root = process.cwd()
|
|
16
|
-
} = {}) {
|
|
17
|
+
function removeBuildFiles(patterns, { root = process.cwd() } = {}) {
|
|
17
18
|
return {
|
|
18
|
-
name:
|
|
19
|
+
name: "@quilt/remove-build-files",
|
|
19
20
|
async buildStart() {
|
|
20
21
|
const matches = await glob(patterns, {
|
|
21
22
|
cwd: root,
|
|
22
23
|
absolute: true
|
|
23
24
|
});
|
|
24
|
-
await Promise.all(
|
|
25
|
-
recursive: true,
|
|
26
|
-
|
|
27
|
-
})));
|
|
25
|
+
await Promise.all(
|
|
26
|
+
matches.map((file) => fs.rm(file, { recursive: true, force: true }))
|
|
27
|
+
);
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
async function getNodePlugins(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
default:
|
|
36
|
-
|
|
37
|
-
default: nodeResolve
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
31
|
+
async function getNodePlugins({
|
|
32
|
+
bundle = {}
|
|
33
|
+
} = {}) {
|
|
34
|
+
const [
|
|
35
|
+
{ default: commonjs },
|
|
36
|
+
{ default: json },
|
|
37
|
+
{ default: nodeResolve },
|
|
38
|
+
{ default: nodeExternals }
|
|
39
|
+
] = await Promise.all([
|
|
40
|
+
import('@rollup/plugin-commonjs'),
|
|
41
|
+
import('@rollup/plugin-json'),
|
|
42
|
+
import('@rollup/plugin-node-resolve'),
|
|
43
|
+
import('rollup-plugin-node-externals')
|
|
44
|
+
]);
|
|
45
|
+
let nodeExternalsOptions;
|
|
46
|
+
if (bundle === true) {
|
|
47
|
+
nodeExternalsOptions = {
|
|
48
|
+
builtins: true,
|
|
49
|
+
builtinsPrefix: "strip",
|
|
50
|
+
deps: false,
|
|
51
|
+
devDeps: false,
|
|
52
|
+
peerDeps: false,
|
|
53
|
+
optDeps: false
|
|
54
|
+
};
|
|
55
|
+
} else if (bundle === false) {
|
|
56
|
+
nodeExternalsOptions = {
|
|
57
|
+
builtins: true,
|
|
58
|
+
builtinsPrefix: "add",
|
|
59
|
+
deps: true,
|
|
60
|
+
devDeps: true,
|
|
61
|
+
peerDeps: true,
|
|
62
|
+
optDeps: true
|
|
63
|
+
};
|
|
64
|
+
} else {
|
|
65
|
+
const {
|
|
66
|
+
builtins: bundleBuiltins = false,
|
|
67
|
+
dependencies: bundleDependencies = false,
|
|
68
|
+
devDependencies: bundleDevDependencies = true,
|
|
69
|
+
peerDependencies: bundlePeerDependencies = false,
|
|
70
|
+
include: alwaysBundleDependencies,
|
|
71
|
+
exclude: neverBundleDependencies
|
|
72
|
+
} = bundle;
|
|
73
|
+
nodeExternalsOptions = {
|
|
74
|
+
builtins: !bundleBuiltins,
|
|
75
|
+
builtinsPrefix: bundleBuiltins ? "strip" : "add",
|
|
76
|
+
deps: !bundleDependencies,
|
|
77
|
+
devDeps: !bundleDevDependencies,
|
|
78
|
+
peerDeps: !bundlePeerDependencies,
|
|
79
|
+
optDeps: !bundlePeerDependencies,
|
|
80
|
+
include: neverBundleDependencies,
|
|
81
|
+
exclude: alwaysBundleDependencies
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
return [
|
|
85
|
+
nodeExternals(nodeExternalsOptions),
|
|
86
|
+
nodeResolve({
|
|
87
|
+
preferBuiltins: true,
|
|
88
|
+
dedupe: [],
|
|
89
|
+
extensions: [
|
|
90
|
+
".ts",
|
|
91
|
+
".tsx",
|
|
92
|
+
".mts",
|
|
93
|
+
".mtsx",
|
|
94
|
+
".js",
|
|
95
|
+
".jsx",
|
|
96
|
+
".es6",
|
|
97
|
+
".es",
|
|
98
|
+
".mjs"
|
|
99
|
+
],
|
|
100
|
+
exportConditions: [
|
|
101
|
+
"esnext",
|
|
102
|
+
"quilt:esnext",
|
|
103
|
+
"default",
|
|
104
|
+
"module",
|
|
105
|
+
"import"
|
|
106
|
+
]
|
|
107
|
+
}),
|
|
108
|
+
commonjs(),
|
|
109
|
+
json()
|
|
110
|
+
];
|
|
47
111
|
}
|
|
48
112
|
|
|
49
113
|
export { getNodePlugins, removeBuildFiles, smartReplace };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
function multiline(strings, ...values) {
|
|
2
|
-
let result = strings.reduce(
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
let result = strings.reduce(
|
|
3
|
+
(combined, string, index) => `${combined}${string}${values[index] ?? ""}`,
|
|
4
|
+
""
|
|
5
|
+
);
|
|
5
6
|
const match = result.match(/^[^\S\n]*(?=\S)/gm);
|
|
6
|
-
const indent = match && Math.min(...match.map(
|
|
7
|
+
const indent = match && Math.min(...match.map((indent2) => indent2.length));
|
|
7
8
|
if (indent) {
|
|
8
|
-
const regexp = new RegExp(`^.{${indent}}`,
|
|
9
|
-
result = result.replace(regexp,
|
|
9
|
+
const regexp = new RegExp(`^.{${indent}}`, "gm");
|
|
10
|
+
result = result.replace(regexp, "");
|
|
10
11
|
}
|
|
11
12
|
return result.trim();
|
|
12
13
|
}
|