@tachybase/module-pdf 0.23.8
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/.turbo/turbo-build.log +15 -0
- package/README.md +1 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/PdfInstruction.d.ts +107 -0
- package/dist/client/index.d.ts +10 -0
- package/dist/client/index.js +239 -0
- package/dist/externalVersion.js +11 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +39 -0
- package/dist/node_modules/@babel/core/LICENSE +22 -0
- package/dist/node_modules/@babel/core/cjs-proxy.cjs +68 -0
- package/dist/node_modules/@babel/core/lib/config/cache-contexts.js +3 -0
- package/dist/node_modules/@babel/core/lib/config/caching.js +261 -0
- package/dist/node_modules/@babel/core/lib/config/config-chain.js +469 -0
- package/dist/node_modules/@babel/core/lib/config/config-descriptors.js +190 -0
- package/dist/node_modules/@babel/core/lib/config/files/configuration.js +287 -0
- package/dist/node_modules/@babel/core/lib/config/files/import.cjs +6 -0
- package/dist/node_modules/@babel/core/lib/config/files/index-browser.js +58 -0
- package/dist/node_modules/@babel/core/lib/config/files/index.js +78 -0
- package/dist/node_modules/@babel/core/lib/config/files/module-types.js +195 -0
- package/dist/node_modules/@babel/core/lib/config/files/package.js +61 -0
- package/dist/node_modules/@babel/core/lib/config/files/plugins.js +229 -0
- package/dist/node_modules/@babel/core/lib/config/files/types.js +3 -0
- package/dist/node_modules/@babel/core/lib/config/files/utils.js +36 -0
- package/dist/node_modules/@babel/core/lib/config/full.js +312 -0
- package/dist/node_modules/@babel/core/lib/config/helpers/config-api.js +84 -0
- package/dist/node_modules/@babel/core/lib/config/helpers/deep-array.js +23 -0
- package/dist/node_modules/@babel/core/lib/config/helpers/environment.js +12 -0
- package/dist/node_modules/@babel/core/lib/config/index.js +93 -0
- package/dist/node_modules/@babel/core/lib/config/item.js +67 -0
- package/dist/node_modules/@babel/core/lib/config/partial.js +158 -0
- package/dist/node_modules/@babel/core/lib/config/pattern-to-regex.js +38 -0
- package/dist/node_modules/@babel/core/lib/config/plugin.js +33 -0
- package/dist/node_modules/@babel/core/lib/config/printer.js +113 -0
- package/dist/node_modules/@babel/core/lib/config/resolve-targets-browser.js +41 -0
- package/dist/node_modules/@babel/core/lib/config/resolve-targets.js +61 -0
- package/dist/node_modules/@babel/core/lib/config/util.js +31 -0
- package/dist/node_modules/@babel/core/lib/config/validation/option-assertions.js +277 -0
- package/dist/node_modules/@babel/core/lib/config/validation/options.js +189 -0
- package/dist/node_modules/@babel/core/lib/config/validation/plugins.js +67 -0
- package/dist/node_modules/@babel/core/lib/config/validation/removed.js +68 -0
- package/dist/node_modules/@babel/core/lib/errors/config-error.js +18 -0
- package/dist/node_modules/@babel/core/lib/errors/rewrite-stack-trace.js +98 -0
- package/dist/node_modules/@babel/core/lib/gensync-utils/async.js +90 -0
- package/dist/node_modules/@babel/core/lib/gensync-utils/fs.js +31 -0
- package/dist/node_modules/@babel/core/lib/gensync-utils/functional.js +58 -0
- package/dist/node_modules/@babel/core/lib/index.js +227 -0
- package/dist/node_modules/@babel/core/lib/parse.js +47 -0
- package/dist/node_modules/@babel/core/lib/parser/index.js +79 -0
- package/dist/node_modules/@babel/core/lib/parser/util/missing-plugin-helper.js +339 -0
- package/dist/node_modules/@babel/core/lib/tools/build-external-helpers.js +144 -0
- package/dist/node_modules/@babel/core/lib/transform-ast.js +50 -0
- package/dist/node_modules/@babel/core/lib/transform-file-browser.js +23 -0
- package/dist/node_modules/@babel/core/lib/transform-file.js +40 -0
- package/dist/node_modules/@babel/core/lib/transform.js +49 -0
- package/dist/node_modules/@babel/core/lib/transformation/block-hoist-plugin.js +84 -0
- package/dist/node_modules/@babel/core/lib/transformation/file/babel-7-helpers.cjs +4 -0
- package/dist/node_modules/@babel/core/lib/transformation/file/file.js +214 -0
- package/dist/node_modules/@babel/core/lib/transformation/file/generate.js +84 -0
- package/dist/node_modules/@babel/core/lib/transformation/file/merge-map.js +37 -0
- package/dist/node_modules/@babel/core/lib/transformation/index.js +92 -0
- package/dist/node_modules/@babel/core/lib/transformation/normalize-file.js +129 -0
- package/dist/node_modules/@babel/core/lib/transformation/normalize-opts.js +59 -0
- package/dist/node_modules/@babel/core/lib/transformation/plugin-pass.js +50 -0
- package/dist/node_modules/@babel/core/lib/transformation/util/clone-deep.js +36 -0
- package/dist/node_modules/@babel/core/lib/vendor/import-meta-resolve.js +1043 -0
- package/dist/node_modules/@babel/core/node_modules/.bin/json5 +17 -0
- package/dist/node_modules/@babel/core/node_modules/.bin/parser +17 -0
- package/dist/node_modules/@babel/core/node_modules/.bin/semver +17 -0
- package/dist/node_modules/@babel/core/package.json +1 -0
- package/dist/node_modules/@babel/core/src/config/files/index-browser.ts +113 -0
- package/dist/node_modules/@babel/core/src/config/files/index.ts +29 -0
- package/dist/node_modules/@babel/core/src/config/resolve-targets-browser.ts +40 -0
- package/dist/node_modules/@babel/core/src/config/resolve-targets.ts +56 -0
- package/dist/node_modules/@babel/core/src/transform-file-browser.ts +31 -0
- package/dist/node_modules/@babel/core/src/transform-file.ts +55 -0
- package/dist/node_modules/@react-pdf/renderer/index.d.ts +590 -0
- package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.browser.cjs +4558 -0
- package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.browser.d.cts +590 -0
- package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.browser.d.ts +590 -0
- package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.browser.js +4505 -0
- package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.browser.min.cjs +10 -0
- package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.browser.min.d.cts +590 -0
- package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.browser.min.d.ts +590 -0
- package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.browser.min.js +10 -0
- package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.cjs +40 -0
- package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.d.cts +590 -0
- package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.d.ts +590 -0
- package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.js +4393 -0
- package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.min.cjs +10 -0
- package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.min.d.cts +590 -0
- package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.min.d.ts +590 -0
- package/dist/node_modules/@react-pdf/renderer/lib/react-pdf.min.js +10 -0
- package/dist/node_modules/@react-pdf/renderer/package.json +1 -0
- package/dist/node_modules/fs-extra/LICENSE +15 -0
- package/dist/node_modules/fs-extra/lib/copy/copy-sync.js +161 -0
- package/dist/node_modules/fs-extra/lib/copy/copy.js +177 -0
- package/dist/node_modules/fs-extra/lib/copy/index.js +7 -0
- package/dist/node_modules/fs-extra/lib/empty/index.js +39 -0
- package/dist/node_modules/fs-extra/lib/ensure/file.js +66 -0
- package/dist/node_modules/fs-extra/lib/ensure/index.js +23 -0
- package/dist/node_modules/fs-extra/lib/ensure/link.js +64 -0
- package/dist/node_modules/fs-extra/lib/ensure/symlink-paths.js +101 -0
- package/dist/node_modules/fs-extra/lib/ensure/symlink-type.js +34 -0
- package/dist/node_modules/fs-extra/lib/ensure/symlink.js +67 -0
- package/dist/node_modules/fs-extra/lib/fs/index.js +140 -0
- package/dist/node_modules/fs-extra/lib/index.js +1 -0
- package/dist/node_modules/fs-extra/lib/json/index.js +16 -0
- package/dist/node_modules/fs-extra/lib/json/jsonfile.js +11 -0
- package/dist/node_modules/fs-extra/lib/json/output-json-sync.js +12 -0
- package/dist/node_modules/fs-extra/lib/json/output-json.js +12 -0
- package/dist/node_modules/fs-extra/lib/mkdirs/index.js +14 -0
- package/dist/node_modules/fs-extra/lib/mkdirs/make-dir.js +27 -0
- package/dist/node_modules/fs-extra/lib/mkdirs/utils.js +21 -0
- package/dist/node_modules/fs-extra/lib/move/index.js +7 -0
- package/dist/node_modules/fs-extra/lib/move/move-sync.js +55 -0
- package/dist/node_modules/fs-extra/lib/move/move.js +59 -0
- package/dist/node_modules/fs-extra/lib/output-file/index.js +31 -0
- package/dist/node_modules/fs-extra/lib/path-exists/index.js +12 -0
- package/dist/node_modules/fs-extra/lib/remove/index.js +17 -0
- package/dist/node_modules/fs-extra/lib/util/stat.js +158 -0
- package/dist/node_modules/fs-extra/lib/util/utimes.js +36 -0
- package/dist/node_modules/fs-extra/package.json +1 -0
- package/dist/server/PdfInstruction.d.ts +10 -0
- package/dist/server/PdfInstruction.js +108 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +53 -0
- package/dist/server/plugin.d.ts +11 -0
- package/dist/server/plugin.js +102 -0
- package/dist/server/services/font-manager.d.ts +6 -0
- package/dist/server/services/font-manager.js +199 -0
- package/package.json +32 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.buildPresetChain = buildPresetChain;
|
|
7
|
+
exports.buildPresetChainWalker = void 0;
|
|
8
|
+
exports.buildRootChain = buildRootChain;
|
|
9
|
+
function _path() {
|
|
10
|
+
const data = require("path");
|
|
11
|
+
_path = function () {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
return data;
|
|
15
|
+
}
|
|
16
|
+
function _debug() {
|
|
17
|
+
const data = require("debug");
|
|
18
|
+
_debug = function () {
|
|
19
|
+
return data;
|
|
20
|
+
};
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
var _options = require("./validation/options.js");
|
|
24
|
+
var _patternToRegex = require("./pattern-to-regex.js");
|
|
25
|
+
var _printer = require("./printer.js");
|
|
26
|
+
var _rewriteStackTrace = require("../errors/rewrite-stack-trace.js");
|
|
27
|
+
var _configError = require("../errors/config-error.js");
|
|
28
|
+
var _index = require("./files/index.js");
|
|
29
|
+
var _caching = require("./caching.js");
|
|
30
|
+
var _configDescriptors = require("./config-descriptors.js");
|
|
31
|
+
const debug = _debug()("babel:config:config-chain");
|
|
32
|
+
function* buildPresetChain(arg, context) {
|
|
33
|
+
const chain = yield* buildPresetChainWalker(arg, context);
|
|
34
|
+
if (!chain) return null;
|
|
35
|
+
return {
|
|
36
|
+
plugins: dedupDescriptors(chain.plugins),
|
|
37
|
+
presets: dedupDescriptors(chain.presets),
|
|
38
|
+
options: chain.options.map(o => normalizeOptions(o)),
|
|
39
|
+
files: new Set()
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const buildPresetChainWalker = exports.buildPresetChainWalker = makeChainWalker({
|
|
43
|
+
root: preset => loadPresetDescriptors(preset),
|
|
44
|
+
env: (preset, envName) => loadPresetEnvDescriptors(preset)(envName),
|
|
45
|
+
overrides: (preset, index) => loadPresetOverridesDescriptors(preset)(index),
|
|
46
|
+
overridesEnv: (preset, index, envName) => loadPresetOverridesEnvDescriptors(preset)(index)(envName),
|
|
47
|
+
createLogger: () => () => {}
|
|
48
|
+
});
|
|
49
|
+
const loadPresetDescriptors = (0, _caching.makeWeakCacheSync)(preset => buildRootDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors));
|
|
50
|
+
const loadPresetEnvDescriptors = (0, _caching.makeWeakCacheSync)(preset => (0, _caching.makeStrongCacheSync)(envName => buildEnvDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors, envName)));
|
|
51
|
+
const loadPresetOverridesDescriptors = (0, _caching.makeWeakCacheSync)(preset => (0, _caching.makeStrongCacheSync)(index => buildOverrideDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors, index)));
|
|
52
|
+
const loadPresetOverridesEnvDescriptors = (0, _caching.makeWeakCacheSync)(preset => (0, _caching.makeStrongCacheSync)(index => (0, _caching.makeStrongCacheSync)(envName => buildOverrideEnvDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors, index, envName))));
|
|
53
|
+
function* buildRootChain(opts, context) {
|
|
54
|
+
let configReport, babelRcReport;
|
|
55
|
+
const programmaticLogger = new _printer.ConfigPrinter();
|
|
56
|
+
const programmaticChain = yield* loadProgrammaticChain({
|
|
57
|
+
options: opts,
|
|
58
|
+
dirname: context.cwd
|
|
59
|
+
}, context, undefined, programmaticLogger);
|
|
60
|
+
if (!programmaticChain) return null;
|
|
61
|
+
const programmaticReport = yield* programmaticLogger.output();
|
|
62
|
+
let configFile;
|
|
63
|
+
if (typeof opts.configFile === "string") {
|
|
64
|
+
configFile = yield* (0, _index.loadConfig)(opts.configFile, context.cwd, context.envName, context.caller);
|
|
65
|
+
} else if (opts.configFile !== false) {
|
|
66
|
+
configFile = yield* (0, _index.findRootConfig)(context.root, context.envName, context.caller);
|
|
67
|
+
}
|
|
68
|
+
let {
|
|
69
|
+
babelrc,
|
|
70
|
+
babelrcRoots
|
|
71
|
+
} = opts;
|
|
72
|
+
let babelrcRootsDirectory = context.cwd;
|
|
73
|
+
const configFileChain = emptyChain();
|
|
74
|
+
const configFileLogger = new _printer.ConfigPrinter();
|
|
75
|
+
if (configFile) {
|
|
76
|
+
const validatedFile = validateConfigFile(configFile);
|
|
77
|
+
const result = yield* loadFileChain(validatedFile, context, undefined, configFileLogger);
|
|
78
|
+
if (!result) return null;
|
|
79
|
+
configReport = yield* configFileLogger.output();
|
|
80
|
+
if (babelrc === undefined) {
|
|
81
|
+
babelrc = validatedFile.options.babelrc;
|
|
82
|
+
}
|
|
83
|
+
if (babelrcRoots === undefined) {
|
|
84
|
+
babelrcRootsDirectory = validatedFile.dirname;
|
|
85
|
+
babelrcRoots = validatedFile.options.babelrcRoots;
|
|
86
|
+
}
|
|
87
|
+
mergeChain(configFileChain, result);
|
|
88
|
+
}
|
|
89
|
+
let ignoreFile, babelrcFile;
|
|
90
|
+
let isIgnored = false;
|
|
91
|
+
const fileChain = emptyChain();
|
|
92
|
+
if ((babelrc === true || babelrc === undefined) && typeof context.filename === "string") {
|
|
93
|
+
const pkgData = yield* (0, _index.findPackageData)(context.filename);
|
|
94
|
+
if (pkgData && babelrcLoadEnabled(context, pkgData, babelrcRoots, babelrcRootsDirectory)) {
|
|
95
|
+
({
|
|
96
|
+
ignore: ignoreFile,
|
|
97
|
+
config: babelrcFile
|
|
98
|
+
} = yield* (0, _index.findRelativeConfig)(pkgData, context.envName, context.caller));
|
|
99
|
+
if (ignoreFile) {
|
|
100
|
+
fileChain.files.add(ignoreFile.filepath);
|
|
101
|
+
}
|
|
102
|
+
if (ignoreFile && shouldIgnore(context, ignoreFile.ignore, null, ignoreFile.dirname)) {
|
|
103
|
+
isIgnored = true;
|
|
104
|
+
}
|
|
105
|
+
if (babelrcFile && !isIgnored) {
|
|
106
|
+
const validatedFile = validateBabelrcFile(babelrcFile);
|
|
107
|
+
const babelrcLogger = new _printer.ConfigPrinter();
|
|
108
|
+
const result = yield* loadFileChain(validatedFile, context, undefined, babelrcLogger);
|
|
109
|
+
if (!result) {
|
|
110
|
+
isIgnored = true;
|
|
111
|
+
} else {
|
|
112
|
+
babelRcReport = yield* babelrcLogger.output();
|
|
113
|
+
mergeChain(fileChain, result);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (babelrcFile && isIgnored) {
|
|
117
|
+
fileChain.files.add(babelrcFile.filepath);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (context.showConfig) {
|
|
122
|
+
console.log(`Babel configs on "${context.filename}" (ascending priority):\n` + [configReport, babelRcReport, programmaticReport].filter(x => !!x).join("\n\n") + "\n-----End Babel configs-----");
|
|
123
|
+
}
|
|
124
|
+
const chain = mergeChain(mergeChain(mergeChain(emptyChain(), configFileChain), fileChain), programmaticChain);
|
|
125
|
+
return {
|
|
126
|
+
plugins: isIgnored ? [] : dedupDescriptors(chain.plugins),
|
|
127
|
+
presets: isIgnored ? [] : dedupDescriptors(chain.presets),
|
|
128
|
+
options: isIgnored ? [] : chain.options.map(o => normalizeOptions(o)),
|
|
129
|
+
fileHandling: isIgnored ? "ignored" : "transpile",
|
|
130
|
+
ignore: ignoreFile || undefined,
|
|
131
|
+
babelrc: babelrcFile || undefined,
|
|
132
|
+
config: configFile || undefined,
|
|
133
|
+
files: chain.files
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function babelrcLoadEnabled(context, pkgData, babelrcRoots, babelrcRootsDirectory) {
|
|
137
|
+
if (typeof babelrcRoots === "boolean") return babelrcRoots;
|
|
138
|
+
const absoluteRoot = context.root;
|
|
139
|
+
if (babelrcRoots === undefined) {
|
|
140
|
+
return pkgData.directories.includes(absoluteRoot);
|
|
141
|
+
}
|
|
142
|
+
let babelrcPatterns = babelrcRoots;
|
|
143
|
+
if (!Array.isArray(babelrcPatterns)) {
|
|
144
|
+
babelrcPatterns = [babelrcPatterns];
|
|
145
|
+
}
|
|
146
|
+
babelrcPatterns = babelrcPatterns.map(pat => {
|
|
147
|
+
return typeof pat === "string" ? _path().resolve(babelrcRootsDirectory, pat) : pat;
|
|
148
|
+
});
|
|
149
|
+
if (babelrcPatterns.length === 1 && babelrcPatterns[0] === absoluteRoot) {
|
|
150
|
+
return pkgData.directories.includes(absoluteRoot);
|
|
151
|
+
}
|
|
152
|
+
return babelrcPatterns.some(pat => {
|
|
153
|
+
if (typeof pat === "string") {
|
|
154
|
+
pat = (0, _patternToRegex.default)(pat, babelrcRootsDirectory);
|
|
155
|
+
}
|
|
156
|
+
return pkgData.directories.some(directory => {
|
|
157
|
+
return matchPattern(pat, babelrcRootsDirectory, directory, context);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
const validateConfigFile = (0, _caching.makeWeakCacheSync)(file => ({
|
|
162
|
+
filepath: file.filepath,
|
|
163
|
+
dirname: file.dirname,
|
|
164
|
+
options: (0, _options.validate)("configfile", file.options, file.filepath)
|
|
165
|
+
}));
|
|
166
|
+
const validateBabelrcFile = (0, _caching.makeWeakCacheSync)(file => ({
|
|
167
|
+
filepath: file.filepath,
|
|
168
|
+
dirname: file.dirname,
|
|
169
|
+
options: (0, _options.validate)("babelrcfile", file.options, file.filepath)
|
|
170
|
+
}));
|
|
171
|
+
const validateExtendFile = (0, _caching.makeWeakCacheSync)(file => ({
|
|
172
|
+
filepath: file.filepath,
|
|
173
|
+
dirname: file.dirname,
|
|
174
|
+
options: (0, _options.validate)("extendsfile", file.options, file.filepath)
|
|
175
|
+
}));
|
|
176
|
+
const loadProgrammaticChain = makeChainWalker({
|
|
177
|
+
root: input => buildRootDescriptors(input, "base", _configDescriptors.createCachedDescriptors),
|
|
178
|
+
env: (input, envName) => buildEnvDescriptors(input, "base", _configDescriptors.createCachedDescriptors, envName),
|
|
179
|
+
overrides: (input, index) => buildOverrideDescriptors(input, "base", _configDescriptors.createCachedDescriptors, index),
|
|
180
|
+
overridesEnv: (input, index, envName) => buildOverrideEnvDescriptors(input, "base", _configDescriptors.createCachedDescriptors, index, envName),
|
|
181
|
+
createLogger: (input, context, baseLogger) => buildProgrammaticLogger(input, context, baseLogger)
|
|
182
|
+
});
|
|
183
|
+
const loadFileChainWalker = makeChainWalker({
|
|
184
|
+
root: file => loadFileDescriptors(file),
|
|
185
|
+
env: (file, envName) => loadFileEnvDescriptors(file)(envName),
|
|
186
|
+
overrides: (file, index) => loadFileOverridesDescriptors(file)(index),
|
|
187
|
+
overridesEnv: (file, index, envName) => loadFileOverridesEnvDescriptors(file)(index)(envName),
|
|
188
|
+
createLogger: (file, context, baseLogger) => buildFileLogger(file.filepath, context, baseLogger)
|
|
189
|
+
});
|
|
190
|
+
function* loadFileChain(input, context, files, baseLogger) {
|
|
191
|
+
const chain = yield* loadFileChainWalker(input, context, files, baseLogger);
|
|
192
|
+
chain == null || chain.files.add(input.filepath);
|
|
193
|
+
return chain;
|
|
194
|
+
}
|
|
195
|
+
const loadFileDescriptors = (0, _caching.makeWeakCacheSync)(file => buildRootDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors));
|
|
196
|
+
const loadFileEnvDescriptors = (0, _caching.makeWeakCacheSync)(file => (0, _caching.makeStrongCacheSync)(envName => buildEnvDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors, envName)));
|
|
197
|
+
const loadFileOverridesDescriptors = (0, _caching.makeWeakCacheSync)(file => (0, _caching.makeStrongCacheSync)(index => buildOverrideDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors, index)));
|
|
198
|
+
const loadFileOverridesEnvDescriptors = (0, _caching.makeWeakCacheSync)(file => (0, _caching.makeStrongCacheSync)(index => (0, _caching.makeStrongCacheSync)(envName => buildOverrideEnvDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors, index, envName))));
|
|
199
|
+
function buildFileLogger(filepath, context, baseLogger) {
|
|
200
|
+
if (!baseLogger) {
|
|
201
|
+
return () => {};
|
|
202
|
+
}
|
|
203
|
+
return baseLogger.configure(context.showConfig, _printer.ChainFormatter.Config, {
|
|
204
|
+
filepath
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
function buildRootDescriptors({
|
|
208
|
+
dirname,
|
|
209
|
+
options
|
|
210
|
+
}, alias, descriptors) {
|
|
211
|
+
return descriptors(dirname, options, alias);
|
|
212
|
+
}
|
|
213
|
+
function buildProgrammaticLogger(_, context, baseLogger) {
|
|
214
|
+
var _context$caller;
|
|
215
|
+
if (!baseLogger) {
|
|
216
|
+
return () => {};
|
|
217
|
+
}
|
|
218
|
+
return baseLogger.configure(context.showConfig, _printer.ChainFormatter.Programmatic, {
|
|
219
|
+
callerName: (_context$caller = context.caller) == null ? void 0 : _context$caller.name
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
function buildEnvDescriptors({
|
|
223
|
+
dirname,
|
|
224
|
+
options
|
|
225
|
+
}, alias, descriptors, envName) {
|
|
226
|
+
var _options$env;
|
|
227
|
+
const opts = (_options$env = options.env) == null ? void 0 : _options$env[envName];
|
|
228
|
+
return opts ? descriptors(dirname, opts, `${alias}.env["${envName}"]`) : null;
|
|
229
|
+
}
|
|
230
|
+
function buildOverrideDescriptors({
|
|
231
|
+
dirname,
|
|
232
|
+
options
|
|
233
|
+
}, alias, descriptors, index) {
|
|
234
|
+
var _options$overrides;
|
|
235
|
+
const opts = (_options$overrides = options.overrides) == null ? void 0 : _options$overrides[index];
|
|
236
|
+
if (!opts) throw new Error("Assertion failure - missing override");
|
|
237
|
+
return descriptors(dirname, opts, `${alias}.overrides[${index}]`);
|
|
238
|
+
}
|
|
239
|
+
function buildOverrideEnvDescriptors({
|
|
240
|
+
dirname,
|
|
241
|
+
options
|
|
242
|
+
}, alias, descriptors, index, envName) {
|
|
243
|
+
var _options$overrides2, _override$env;
|
|
244
|
+
const override = (_options$overrides2 = options.overrides) == null ? void 0 : _options$overrides2[index];
|
|
245
|
+
if (!override) throw new Error("Assertion failure - missing override");
|
|
246
|
+
const opts = (_override$env = override.env) == null ? void 0 : _override$env[envName];
|
|
247
|
+
return opts ? descriptors(dirname, opts, `${alias}.overrides[${index}].env["${envName}"]`) : null;
|
|
248
|
+
}
|
|
249
|
+
function makeChainWalker({
|
|
250
|
+
root,
|
|
251
|
+
env,
|
|
252
|
+
overrides,
|
|
253
|
+
overridesEnv,
|
|
254
|
+
createLogger
|
|
255
|
+
}) {
|
|
256
|
+
return function* chainWalker(input, context, files = new Set(), baseLogger) {
|
|
257
|
+
const {
|
|
258
|
+
dirname
|
|
259
|
+
} = input;
|
|
260
|
+
const flattenedConfigs = [];
|
|
261
|
+
const rootOpts = root(input);
|
|
262
|
+
if (configIsApplicable(rootOpts, dirname, context, input.filepath)) {
|
|
263
|
+
flattenedConfigs.push({
|
|
264
|
+
config: rootOpts,
|
|
265
|
+
envName: undefined,
|
|
266
|
+
index: undefined
|
|
267
|
+
});
|
|
268
|
+
const envOpts = env(input, context.envName);
|
|
269
|
+
if (envOpts && configIsApplicable(envOpts, dirname, context, input.filepath)) {
|
|
270
|
+
flattenedConfigs.push({
|
|
271
|
+
config: envOpts,
|
|
272
|
+
envName: context.envName,
|
|
273
|
+
index: undefined
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
(rootOpts.options.overrides || []).forEach((_, index) => {
|
|
277
|
+
const overrideOps = overrides(input, index);
|
|
278
|
+
if (configIsApplicable(overrideOps, dirname, context, input.filepath)) {
|
|
279
|
+
flattenedConfigs.push({
|
|
280
|
+
config: overrideOps,
|
|
281
|
+
index,
|
|
282
|
+
envName: undefined
|
|
283
|
+
});
|
|
284
|
+
const overrideEnvOpts = overridesEnv(input, index, context.envName);
|
|
285
|
+
if (overrideEnvOpts && configIsApplicable(overrideEnvOpts, dirname, context, input.filepath)) {
|
|
286
|
+
flattenedConfigs.push({
|
|
287
|
+
config: overrideEnvOpts,
|
|
288
|
+
index,
|
|
289
|
+
envName: context.envName
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
if (flattenedConfigs.some(({
|
|
296
|
+
config: {
|
|
297
|
+
options: {
|
|
298
|
+
ignore,
|
|
299
|
+
only
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}) => shouldIgnore(context, ignore, only, dirname))) {
|
|
303
|
+
return null;
|
|
304
|
+
}
|
|
305
|
+
const chain = emptyChain();
|
|
306
|
+
const logger = createLogger(input, context, baseLogger);
|
|
307
|
+
for (const {
|
|
308
|
+
config,
|
|
309
|
+
index,
|
|
310
|
+
envName
|
|
311
|
+
} of flattenedConfigs) {
|
|
312
|
+
if (!(yield* mergeExtendsChain(chain, config.options, dirname, context, files, baseLogger))) {
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
logger(config, index, envName);
|
|
316
|
+
yield* mergeChainOpts(chain, config);
|
|
317
|
+
}
|
|
318
|
+
return chain;
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
function* mergeExtendsChain(chain, opts, dirname, context, files, baseLogger) {
|
|
322
|
+
if (opts.extends === undefined) return true;
|
|
323
|
+
const file = yield* (0, _index.loadConfig)(opts.extends, dirname, context.envName, context.caller);
|
|
324
|
+
if (files.has(file)) {
|
|
325
|
+
throw new Error(`Configuration cycle detected loading ${file.filepath}.\n` + `File already loaded following the config chain:\n` + Array.from(files, file => ` - ${file.filepath}`).join("\n"));
|
|
326
|
+
}
|
|
327
|
+
files.add(file);
|
|
328
|
+
const fileChain = yield* loadFileChain(validateExtendFile(file), context, files, baseLogger);
|
|
329
|
+
files.delete(file);
|
|
330
|
+
if (!fileChain) return false;
|
|
331
|
+
mergeChain(chain, fileChain);
|
|
332
|
+
return true;
|
|
333
|
+
}
|
|
334
|
+
function mergeChain(target, source) {
|
|
335
|
+
target.options.push(...source.options);
|
|
336
|
+
target.plugins.push(...source.plugins);
|
|
337
|
+
target.presets.push(...source.presets);
|
|
338
|
+
for (const file of source.files) {
|
|
339
|
+
target.files.add(file);
|
|
340
|
+
}
|
|
341
|
+
return target;
|
|
342
|
+
}
|
|
343
|
+
function* mergeChainOpts(target, {
|
|
344
|
+
options,
|
|
345
|
+
plugins,
|
|
346
|
+
presets
|
|
347
|
+
}) {
|
|
348
|
+
target.options.push(options);
|
|
349
|
+
target.plugins.push(...(yield* plugins()));
|
|
350
|
+
target.presets.push(...(yield* presets()));
|
|
351
|
+
return target;
|
|
352
|
+
}
|
|
353
|
+
function emptyChain() {
|
|
354
|
+
return {
|
|
355
|
+
options: [],
|
|
356
|
+
presets: [],
|
|
357
|
+
plugins: [],
|
|
358
|
+
files: new Set()
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
function normalizeOptions(opts) {
|
|
362
|
+
const options = Object.assign({}, opts);
|
|
363
|
+
delete options.extends;
|
|
364
|
+
delete options.env;
|
|
365
|
+
delete options.overrides;
|
|
366
|
+
delete options.plugins;
|
|
367
|
+
delete options.presets;
|
|
368
|
+
delete options.passPerPreset;
|
|
369
|
+
delete options.ignore;
|
|
370
|
+
delete options.only;
|
|
371
|
+
delete options.test;
|
|
372
|
+
delete options.include;
|
|
373
|
+
delete options.exclude;
|
|
374
|
+
if (hasOwnProperty.call(options, "sourceMap")) {
|
|
375
|
+
options.sourceMaps = options.sourceMap;
|
|
376
|
+
delete options.sourceMap;
|
|
377
|
+
}
|
|
378
|
+
return options;
|
|
379
|
+
}
|
|
380
|
+
function dedupDescriptors(items) {
|
|
381
|
+
const map = new Map();
|
|
382
|
+
const descriptors = [];
|
|
383
|
+
for (const item of items) {
|
|
384
|
+
if (typeof item.value === "function") {
|
|
385
|
+
const fnKey = item.value;
|
|
386
|
+
let nameMap = map.get(fnKey);
|
|
387
|
+
if (!nameMap) {
|
|
388
|
+
nameMap = new Map();
|
|
389
|
+
map.set(fnKey, nameMap);
|
|
390
|
+
}
|
|
391
|
+
let desc = nameMap.get(item.name);
|
|
392
|
+
if (!desc) {
|
|
393
|
+
desc = {
|
|
394
|
+
value: item
|
|
395
|
+
};
|
|
396
|
+
descriptors.push(desc);
|
|
397
|
+
if (!item.ownPass) nameMap.set(item.name, desc);
|
|
398
|
+
} else {
|
|
399
|
+
desc.value = item;
|
|
400
|
+
}
|
|
401
|
+
} else {
|
|
402
|
+
descriptors.push({
|
|
403
|
+
value: item
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
return descriptors.reduce((acc, desc) => {
|
|
408
|
+
acc.push(desc.value);
|
|
409
|
+
return acc;
|
|
410
|
+
}, []);
|
|
411
|
+
}
|
|
412
|
+
function configIsApplicable({
|
|
413
|
+
options
|
|
414
|
+
}, dirname, context, configName) {
|
|
415
|
+
return (options.test === undefined || configFieldIsApplicable(context, options.test, dirname, configName)) && (options.include === undefined || configFieldIsApplicable(context, options.include, dirname, configName)) && (options.exclude === undefined || !configFieldIsApplicable(context, options.exclude, dirname, configName));
|
|
416
|
+
}
|
|
417
|
+
function configFieldIsApplicable(context, test, dirname, configName) {
|
|
418
|
+
const patterns = Array.isArray(test) ? test : [test];
|
|
419
|
+
return matchesPatterns(context, patterns, dirname, configName);
|
|
420
|
+
}
|
|
421
|
+
function ignoreListReplacer(_key, value) {
|
|
422
|
+
if (value instanceof RegExp) {
|
|
423
|
+
return String(value);
|
|
424
|
+
}
|
|
425
|
+
return value;
|
|
426
|
+
}
|
|
427
|
+
function shouldIgnore(context, ignore, only, dirname) {
|
|
428
|
+
if (ignore && matchesPatterns(context, ignore, dirname)) {
|
|
429
|
+
var _context$filename;
|
|
430
|
+
const message = `No config is applied to "${(_context$filename = context.filename) != null ? _context$filename : "(unknown)"}" because it matches one of \`ignore: ${JSON.stringify(ignore, ignoreListReplacer)}\` from "${dirname}"`;
|
|
431
|
+
debug(message);
|
|
432
|
+
if (context.showConfig) {
|
|
433
|
+
console.log(message);
|
|
434
|
+
}
|
|
435
|
+
return true;
|
|
436
|
+
}
|
|
437
|
+
if (only && !matchesPatterns(context, only, dirname)) {
|
|
438
|
+
var _context$filename2;
|
|
439
|
+
const message = `No config is applied to "${(_context$filename2 = context.filename) != null ? _context$filename2 : "(unknown)"}" because it fails to match one of \`only: ${JSON.stringify(only, ignoreListReplacer)}\` from "${dirname}"`;
|
|
440
|
+
debug(message);
|
|
441
|
+
if (context.showConfig) {
|
|
442
|
+
console.log(message);
|
|
443
|
+
}
|
|
444
|
+
return true;
|
|
445
|
+
}
|
|
446
|
+
return false;
|
|
447
|
+
}
|
|
448
|
+
function matchesPatterns(context, patterns, dirname, configName) {
|
|
449
|
+
return patterns.some(pattern => matchPattern(pattern, dirname, context.filename, context, configName));
|
|
450
|
+
}
|
|
451
|
+
function matchPattern(pattern, dirname, pathToTest, context, configName) {
|
|
452
|
+
if (typeof pattern === "function") {
|
|
453
|
+
return !!(0, _rewriteStackTrace.endHiddenCallStack)(pattern)(pathToTest, {
|
|
454
|
+
dirname,
|
|
455
|
+
envName: context.envName,
|
|
456
|
+
caller: context.caller
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
if (typeof pathToTest !== "string") {
|
|
460
|
+
throw new _configError.default(`Configuration contains string/RegExp pattern, but no filename was passed to Babel`, configName);
|
|
461
|
+
}
|
|
462
|
+
if (typeof pattern === "string") {
|
|
463
|
+
pattern = (0, _patternToRegex.default)(pattern, dirname);
|
|
464
|
+
}
|
|
465
|
+
return pattern.test(pathToTest);
|
|
466
|
+
}
|
|
467
|
+
0 && 0;
|
|
468
|
+
|
|
469
|
+
//# sourceMappingURL=config-chain.js.map
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createCachedDescriptors = createCachedDescriptors;
|
|
7
|
+
exports.createDescriptor = createDescriptor;
|
|
8
|
+
exports.createUncachedDescriptors = createUncachedDescriptors;
|
|
9
|
+
function _gensync() {
|
|
10
|
+
const data = require("gensync");
|
|
11
|
+
_gensync = function () {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
return data;
|
|
15
|
+
}
|
|
16
|
+
var _functional = require("../gensync-utils/functional.js");
|
|
17
|
+
var _index = require("./files/index.js");
|
|
18
|
+
var _item = require("./item.js");
|
|
19
|
+
var _caching = require("./caching.js");
|
|
20
|
+
var _resolveTargets = require("./resolve-targets.js");
|
|
21
|
+
function isEqualDescriptor(a, b) {
|
|
22
|
+
var _a$file, _b$file, _a$file2, _b$file2;
|
|
23
|
+
return a.name === b.name && a.value === b.value && a.options === b.options && a.dirname === b.dirname && a.alias === b.alias && a.ownPass === b.ownPass && ((_a$file = a.file) == null ? void 0 : _a$file.request) === ((_b$file = b.file) == null ? void 0 : _b$file.request) && ((_a$file2 = a.file) == null ? void 0 : _a$file2.resolved) === ((_b$file2 = b.file) == null ? void 0 : _b$file2.resolved);
|
|
24
|
+
}
|
|
25
|
+
function* handlerOf(value) {
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
function optionsWithResolvedBrowserslistConfigFile(options, dirname) {
|
|
29
|
+
if (typeof options.browserslistConfigFile === "string") {
|
|
30
|
+
options.browserslistConfigFile = (0, _resolveTargets.resolveBrowserslistConfigFile)(options.browserslistConfigFile, dirname);
|
|
31
|
+
}
|
|
32
|
+
return options;
|
|
33
|
+
}
|
|
34
|
+
function createCachedDescriptors(dirname, options, alias) {
|
|
35
|
+
const {
|
|
36
|
+
plugins,
|
|
37
|
+
presets,
|
|
38
|
+
passPerPreset
|
|
39
|
+
} = options;
|
|
40
|
+
return {
|
|
41
|
+
options: optionsWithResolvedBrowserslistConfigFile(options, dirname),
|
|
42
|
+
plugins: plugins ? () => createCachedPluginDescriptors(plugins, dirname)(alias) : () => handlerOf([]),
|
|
43
|
+
presets: presets ? () => createCachedPresetDescriptors(presets, dirname)(alias)(!!passPerPreset) : () => handlerOf([])
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function createUncachedDescriptors(dirname, options, alias) {
|
|
47
|
+
return {
|
|
48
|
+
options: optionsWithResolvedBrowserslistConfigFile(options, dirname),
|
|
49
|
+
plugins: (0, _functional.once)(() => createPluginDescriptors(options.plugins || [], dirname, alias)),
|
|
50
|
+
presets: (0, _functional.once)(() => createPresetDescriptors(options.presets || [], dirname, alias, !!options.passPerPreset))
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const PRESET_DESCRIPTOR_CACHE = new WeakMap();
|
|
54
|
+
const createCachedPresetDescriptors = (0, _caching.makeWeakCacheSync)((items, cache) => {
|
|
55
|
+
const dirname = cache.using(dir => dir);
|
|
56
|
+
return (0, _caching.makeStrongCacheSync)(alias => (0, _caching.makeStrongCache)(function* (passPerPreset) {
|
|
57
|
+
const descriptors = yield* createPresetDescriptors(items, dirname, alias, passPerPreset);
|
|
58
|
+
return descriptors.map(desc => loadCachedDescriptor(PRESET_DESCRIPTOR_CACHE, desc));
|
|
59
|
+
}));
|
|
60
|
+
});
|
|
61
|
+
const PLUGIN_DESCRIPTOR_CACHE = new WeakMap();
|
|
62
|
+
const createCachedPluginDescriptors = (0, _caching.makeWeakCacheSync)((items, cache) => {
|
|
63
|
+
const dirname = cache.using(dir => dir);
|
|
64
|
+
return (0, _caching.makeStrongCache)(function* (alias) {
|
|
65
|
+
const descriptors = yield* createPluginDescriptors(items, dirname, alias);
|
|
66
|
+
return descriptors.map(desc => loadCachedDescriptor(PLUGIN_DESCRIPTOR_CACHE, desc));
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
const DEFAULT_OPTIONS = {};
|
|
70
|
+
function loadCachedDescriptor(cache, desc) {
|
|
71
|
+
const {
|
|
72
|
+
value,
|
|
73
|
+
options = DEFAULT_OPTIONS
|
|
74
|
+
} = desc;
|
|
75
|
+
if (options === false) return desc;
|
|
76
|
+
let cacheByOptions = cache.get(value);
|
|
77
|
+
if (!cacheByOptions) {
|
|
78
|
+
cacheByOptions = new WeakMap();
|
|
79
|
+
cache.set(value, cacheByOptions);
|
|
80
|
+
}
|
|
81
|
+
let possibilities = cacheByOptions.get(options);
|
|
82
|
+
if (!possibilities) {
|
|
83
|
+
possibilities = [];
|
|
84
|
+
cacheByOptions.set(options, possibilities);
|
|
85
|
+
}
|
|
86
|
+
if (!possibilities.includes(desc)) {
|
|
87
|
+
const matches = possibilities.filter(possibility => isEqualDescriptor(possibility, desc));
|
|
88
|
+
if (matches.length > 0) {
|
|
89
|
+
return matches[0];
|
|
90
|
+
}
|
|
91
|
+
possibilities.push(desc);
|
|
92
|
+
}
|
|
93
|
+
return desc;
|
|
94
|
+
}
|
|
95
|
+
function* createPresetDescriptors(items, dirname, alias, passPerPreset) {
|
|
96
|
+
return yield* createDescriptors("preset", items, dirname, alias, passPerPreset);
|
|
97
|
+
}
|
|
98
|
+
function* createPluginDescriptors(items, dirname, alias) {
|
|
99
|
+
return yield* createDescriptors("plugin", items, dirname, alias);
|
|
100
|
+
}
|
|
101
|
+
function* createDescriptors(type, items, dirname, alias, ownPass) {
|
|
102
|
+
const descriptors = yield* _gensync().all(items.map((item, index) => createDescriptor(item, dirname, {
|
|
103
|
+
type,
|
|
104
|
+
alias: `${alias}$${index}`,
|
|
105
|
+
ownPass: !!ownPass
|
|
106
|
+
})));
|
|
107
|
+
assertNoDuplicates(descriptors);
|
|
108
|
+
return descriptors;
|
|
109
|
+
}
|
|
110
|
+
function* createDescriptor(pair, dirname, {
|
|
111
|
+
type,
|
|
112
|
+
alias,
|
|
113
|
+
ownPass
|
|
114
|
+
}) {
|
|
115
|
+
const desc = (0, _item.getItemDescriptor)(pair);
|
|
116
|
+
if (desc) {
|
|
117
|
+
return desc;
|
|
118
|
+
}
|
|
119
|
+
let name;
|
|
120
|
+
let options;
|
|
121
|
+
let value = pair;
|
|
122
|
+
if (Array.isArray(value)) {
|
|
123
|
+
if (value.length === 3) {
|
|
124
|
+
[value, options, name] = value;
|
|
125
|
+
} else {
|
|
126
|
+
[value, options] = value;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
let file = undefined;
|
|
130
|
+
let filepath = null;
|
|
131
|
+
if (typeof value === "string") {
|
|
132
|
+
if (typeof type !== "string") {
|
|
133
|
+
throw new Error("To resolve a string-based item, the type of item must be given");
|
|
134
|
+
}
|
|
135
|
+
const resolver = type === "plugin" ? _index.loadPlugin : _index.loadPreset;
|
|
136
|
+
const request = value;
|
|
137
|
+
({
|
|
138
|
+
filepath,
|
|
139
|
+
value
|
|
140
|
+
} = yield* resolver(value, dirname));
|
|
141
|
+
file = {
|
|
142
|
+
request,
|
|
143
|
+
resolved: filepath
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
if (!value) {
|
|
147
|
+
throw new Error(`Unexpected falsy value: ${String(value)}`);
|
|
148
|
+
}
|
|
149
|
+
if (typeof value === "object" && value.__esModule) {
|
|
150
|
+
if (value.default) {
|
|
151
|
+
value = value.default;
|
|
152
|
+
} else {
|
|
153
|
+
throw new Error("Must export a default export when using ES6 modules.");
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (typeof value !== "object" && typeof value !== "function") {
|
|
157
|
+
throw new Error(`Unsupported format: ${typeof value}. Expected an object or a function.`);
|
|
158
|
+
}
|
|
159
|
+
if (filepath !== null && typeof value === "object" && value) {
|
|
160
|
+
throw new Error(`Plugin/Preset files are not allowed to export objects, only functions. In ${filepath}`);
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
name,
|
|
164
|
+
alias: filepath || alias,
|
|
165
|
+
value,
|
|
166
|
+
options,
|
|
167
|
+
dirname,
|
|
168
|
+
ownPass,
|
|
169
|
+
file
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function assertNoDuplicates(items) {
|
|
173
|
+
const map = new Map();
|
|
174
|
+
for (const item of items) {
|
|
175
|
+
if (typeof item.value !== "function") continue;
|
|
176
|
+
let nameMap = map.get(item.value);
|
|
177
|
+
if (!nameMap) {
|
|
178
|
+
nameMap = new Set();
|
|
179
|
+
map.set(item.value, nameMap);
|
|
180
|
+
}
|
|
181
|
+
if (nameMap.has(item.name)) {
|
|
182
|
+
const conflicts = items.filter(i => i.value === item.value);
|
|
183
|
+
throw new Error([`Duplicate plugin/preset detected.`, `If you'd like to use two separate instances of a plugin,`, `they need separate names, e.g.`, ``, ` plugins: [`, ` ['some-plugin', {}],`, ` ['some-plugin', {}, 'some unique name'],`, ` ]`, ``, `Duplicates detected are:`, `${JSON.stringify(conflicts, null, 2)}`].join("\n"));
|
|
184
|
+
}
|
|
185
|
+
nameMap.add(item.name);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
0 && 0;
|
|
189
|
+
|
|
190
|
+
//# sourceMappingURL=config-descriptors.js.map
|