@atlaspack/core 2.12.1-canary.3354
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/LICENSE +201 -0
- package/index.d.ts +22 -0
- package/lib/AssetGraph.js +518 -0
- package/lib/Atlaspack.js +587 -0
- package/lib/AtlaspackConfig.js +298 -0
- package/lib/AtlaspackConfig.schema.js +125 -0
- package/lib/BundleGraph.js +1445 -0
- package/lib/CommittedAsset.js +133 -0
- package/lib/Dependency.js +88 -0
- package/lib/Environment.js +128 -0
- package/lib/InternalConfig.js +48 -0
- package/lib/PackagerRunner.js +519 -0
- package/lib/ReporterRunner.js +151 -0
- package/lib/RequestTracker.js +1089 -0
- package/lib/SymbolPropagation.js +625 -0
- package/lib/TargetDescriptor.schema.js +115 -0
- package/lib/Transformation.js +536 -0
- package/lib/UncommittedAsset.js +342 -0
- package/lib/Validation.js +215 -0
- package/lib/applyRuntimes.js +279 -0
- package/lib/assetUtils.js +189 -0
- package/lib/atlaspack-v3/AtlaspackV3.js +74 -0
- package/lib/atlaspack-v3/fs.js +30 -0
- package/lib/atlaspack-v3/index.js +19 -0
- package/lib/atlaspack-v3/jsCallable.js +15 -0
- package/lib/atlaspack-v3/plugins/Resolver.js +12 -0
- package/lib/atlaspack-v3/plugins/index.js +16 -0
- package/lib/atlaspack-v3/worker/index.js +3 -0
- package/lib/atlaspack-v3/worker/worker.js +30 -0
- package/lib/buildCache.js +18 -0
- package/lib/constants.js +21 -0
- package/lib/dumpGraphToGraphViz.js +206 -0
- package/lib/index.js +106 -0
- package/lib/loadAtlaspackPlugin.js +148 -0
- package/lib/loadDotEnv.js +54 -0
- package/lib/projectPath.js +86 -0
- package/lib/public/Asset.js +259 -0
- package/lib/public/Bundle.js +231 -0
- package/lib/public/BundleGraph.js +193 -0
- package/lib/public/BundleGroup.js +44 -0
- package/lib/public/Config.js +202 -0
- package/lib/public/Dependency.js +131 -0
- package/lib/public/Environment.js +244 -0
- package/lib/public/MutableBundleGraph.js +184 -0
- package/lib/public/PluginOptions.js +71 -0
- package/lib/public/Symbols.js +247 -0
- package/lib/public/Target.js +64 -0
- package/lib/registerCoreWithSerializer.js +45 -0
- package/lib/requests/AssetGraphRequest.js +427 -0
- package/lib/requests/AssetGraphRequestRust.js +187 -0
- package/lib/requests/AssetRequest.js +137 -0
- package/lib/requests/AtlaspackBuildRequest.js +78 -0
- package/lib/requests/AtlaspackConfigRequest.js +473 -0
- package/lib/requests/BundleGraphRequest.js +419 -0
- package/lib/requests/ConfigRequest.js +198 -0
- package/lib/requests/DevDepRequest.js +166 -0
- package/lib/requests/EntryRequest.js +295 -0
- package/lib/requests/PackageRequest.js +88 -0
- package/lib/requests/PathRequest.js +349 -0
- package/lib/requests/TargetRequest.js +1177 -0
- package/lib/requests/ValidationRequest.js +66 -0
- package/lib/requests/WriteBundleRequest.js +252 -0
- package/lib/requests/WriteBundlesRequest.js +153 -0
- package/lib/resolveOptions.js +234 -0
- package/lib/serializer.js +216 -0
- package/lib/serializerCore.browser.js +29 -0
- package/lib/serializerCore.js +16 -0
- package/lib/summarizeRequest.js +55 -0
- package/lib/types.js +35 -0
- package/lib/utils.js +160 -0
- package/lib/worker.js +170 -0
- package/package.json +59 -0
- package/src/AssetGraph.js +646 -0
- package/src/Atlaspack.js +632 -0
- package/src/AtlaspackConfig.js +490 -0
- package/src/AtlaspackConfig.schema.js +141 -0
- package/src/BundleGraph.js +2193 -0
- package/src/CommittedAsset.js +143 -0
- package/src/Dependency.js +142 -0
- package/src/Environment.js +151 -0
- package/src/InternalConfig.js +72 -0
- package/src/PackagerRunner.js +790 -0
- package/src/ReporterRunner.js +158 -0
- package/src/RequestTracker.js +1697 -0
- package/src/SymbolPropagation.js +794 -0
- package/src/TargetDescriptor.schema.js +136 -0
- package/src/Transformation.js +752 -0
- package/src/UncommittedAsset.js +426 -0
- package/src/Validation.js +223 -0
- package/src/applyRuntimes.js +341 -0
- package/src/assetUtils.js +254 -0
- package/src/atlaspack-v3/AtlaspackV3.js +73 -0
- package/src/atlaspack-v3/fs.js +36 -0
- package/src/atlaspack-v3/index.js +5 -0
- package/src/atlaspack-v3/jsCallable.js +13 -0
- package/src/atlaspack-v3/plugins/Resolver.js +9 -0
- package/src/atlaspack-v3/plugins/index.js +3 -0
- package/src/atlaspack-v3/worker/index.js +8 -0
- package/src/atlaspack-v3/worker/worker.js +14 -0
- package/src/buildCache.js +15 -0
- package/src/constants.js +22 -0
- package/src/dumpGraphToGraphViz.js +244 -0
- package/src/index.js +22 -0
- package/src/loadAtlaspackPlugin.js +239 -0
- package/src/loadDotEnv.js +56 -0
- package/src/projectPath.js +87 -0
- package/src/public/Asset.js +359 -0
- package/src/public/Bundle.js +337 -0
- package/src/public/BundleGraph.js +335 -0
- package/src/public/BundleGroup.js +55 -0
- package/src/public/Config.js +261 -0
- package/src/public/Dependency.js +176 -0
- package/src/public/Environment.js +316 -0
- package/src/public/MutableBundleGraph.js +320 -0
- package/src/public/PluginOptions.js +99 -0
- package/src/public/Symbols.js +315 -0
- package/src/public/Target.js +71 -0
- package/src/registerCoreWithSerializer.js +34 -0
- package/src/requests/AssetGraphRequest.js +577 -0
- package/src/requests/AssetGraphRequestRust.js +222 -0
- package/src/requests/AssetRequest.js +179 -0
- package/src/requests/AtlaspackBuildRequest.js +109 -0
- package/src/requests/AtlaspackConfigRequest.js +709 -0
- package/src/requests/BundleGraphRequest.js +547 -0
- package/src/requests/ConfigRequest.js +287 -0
- package/src/requests/DevDepRequest.js +246 -0
- package/src/requests/EntryRequest.js +385 -0
- package/src/requests/PackageRequest.js +105 -0
- package/src/requests/PathRequest.js +454 -0
- package/src/requests/TargetRequest.js +1632 -0
- package/src/requests/ValidationRequest.js +79 -0
- package/src/requests/WriteBundleRequest.js +362 -0
- package/src/requests/WriteBundlesRequest.js +209 -0
- package/src/resolveOptions.js +278 -0
- package/src/serializer.js +255 -0
- package/src/serializerCore.browser.js +8 -0
- package/src/serializerCore.js +5 -0
- package/src/summarizeRequest.js +47 -0
- package/src/types.js +581 -0
- package/src/utils.js +211 -0
- package/src/worker.js +189 -0
- package/test/AssetGraph.test.js +679 -0
- package/test/Atlaspack.test.js +142 -0
- package/test/AtlaspackConfig.test.js +405 -0
- package/test/AtlaspackConfigRequest.test.js +993 -0
- package/test/BundleGraph.test.js +121 -0
- package/test/EntryRequest.test.js +215 -0
- package/test/Environment.test.js +99 -0
- package/test/InternalAsset.test.js +76 -0
- package/test/PackagerRunner.test.js +27 -0
- package/test/PublicAsset.test.js +40 -0
- package/test/PublicBundle.test.js +68 -0
- package/test/PublicDependency.test.js +22 -0
- package/test/PublicEnvironment.test.js +27 -0
- package/test/PublicMutableBundleGraph.test.js +192 -0
- package/test/RequestTracker.test.js +448 -0
- package/test/SymbolPropagation.test.js +716 -0
- package/test/TargetRequest.test.js +1715 -0
- package/test/fixtures/application-targets/package.json +3 -0
- package/test/fixtures/atlaspack/index.js +1 -0
- package/test/fixtures/atlaspack/other.js +3 -0
- package/test/fixtures/atlaspack/package.json +1 -0
- package/test/fixtures/atlaspack/yarn.lock +0 -0
- package/test/fixtures/bundle.js +10 -0
- package/test/fixtures/common-targets/package.json +24 -0
- package/test/fixtures/common-targets-ignore/package.json +13 -0
- package/test/fixtures/config/.atlaspackrc +6 -0
- package/test/fixtures/config/subfolder/.atlaspackrc +6 -0
- package/test/fixtures/config-extends-not-found/.atlaspackrc +3 -0
- package/test/fixtures/config-extends-not-found/.atlaspackrc-json5 +3 -0
- package/test/fixtures/config-extends-not-found/.atlaspackrc-multiple +3 -0
- package/test/fixtures/config-extends-not-found/.atlaspackrc-node-modules +3 -0
- package/test/fixtures/config-malformed/.atlaspackrc +3 -0
- package/test/fixtures/config-node-pipeline/.atlaspackrc +6 -0
- package/test/fixtures/config-plugin-not-found/.atlaspackrc +6 -0
- package/test/fixtures/context/package.json +8 -0
- package/test/fixtures/custom-format-infer-ext/package.json +6 -0
- package/test/fixtures/custom-format-infer-type/package.json +7 -0
- package/test/fixtures/custom-format-mismatch/package.json +8 -0
- package/test/fixtures/custom-targets/package.json +20 -0
- package/test/fixtures/custom-targets-distdir/package.json +11 -0
- package/test/fixtures/duplicate-targets/package.json +4 -0
- package/test/fixtures/glob-like/[entry].js +0 -0
- package/test/fixtures/invalid-distpath/package.json +11 -0
- package/test/fixtures/invalid-engines/package.json +12 -0
- package/test/fixtures/invalid-source-missing/package.json +5 -0
- package/test/fixtures/invalid-source-not-file/package.json +5 -0
- package/test/fixtures/invalid-source-not-file/src/index.js +1 -0
- package/test/fixtures/invalid-target-source-missing/package.json +9 -0
- package/test/fixtures/invalid-target-source-not-file/package.json +9 -0
- package/test/fixtures/invalid-target-source-not-file/src/index.js +1 -0
- package/test/fixtures/invalid-targets/package.json +19 -0
- package/test/fixtures/library-custom-scopehoist/package.json +9 -0
- package/test/fixtures/library-scopehoist/package.json +8 -0
- package/test/fixtures/local-plugin-config-pkg/.atlaspackrc +3 -0
- package/test/fixtures/local-plugin-config-pkg/node_modules/atlaspack-config-local/index.json +8 -0
- package/test/fixtures/local-plugin-config-pkg/node_modules/atlaspack-config-local/local-plugin.js +7 -0
- package/test/fixtures/local-plugin-config-pkg/node_modules/atlaspack-config-local/package.json +7 -0
- package/test/fixtures/main-format-mismatch/package.json +8 -0
- package/test/fixtures/main-global/package.json +8 -0
- package/test/fixtures/main-mjs/package.json +8 -0
- package/test/fixtures/module-a.js +1 -0
- package/test/fixtures/module-b.js +1 -0
- package/test/fixtures/plugins/local-plugin.js +7 -0
- package/test/fixtures/plugins/node_modules/atlaspack-transformer-bad-engines/index.js +7 -0
- package/test/fixtures/plugins/node_modules/atlaspack-transformer-bad-engines/package.json +7 -0
- package/test/fixtures/plugins/node_modules/atlaspack-transformer-no-engines/index.js +7 -0
- package/test/fixtures/plugins/node_modules/atlaspack-transformer-no-engines/package.json +4 -0
- package/test/fixtures/targets-default-distdir-none/package.json +5 -0
- package/test/fixtures/targets-default-distdir-one/package.json +8 -0
- package/test/fixtures/targets-default-distdir-two/package.json +18 -0
- package/test/requests/ConfigRequest.test.js +254 -0
- package/test/serializer.test.js +302 -0
- package/test/test-utils.js +80 -0
- package/test/utils.test.js +43 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.bundleGroupToInternalBundleGroup = bundleGroupToInternalBundleGroup;
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
function _nullthrows() {
|
|
9
|
+
const data = _interopRequireDefault(require("nullthrows"));
|
|
10
|
+
_nullthrows = function () {
|
|
11
|
+
return data;
|
|
12
|
+
};
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
var _Target = _interopRequireDefault(require("./Target"));
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
const internalBundleGroupToBundleGroup = new WeakMap();
|
|
18
|
+
const _bundleGroupToInternalBundleGroup = new WeakMap();
|
|
19
|
+
function bundleGroupToInternalBundleGroup(target) {
|
|
20
|
+
return (0, _nullthrows().default)(_bundleGroupToInternalBundleGroup.get(target));
|
|
21
|
+
}
|
|
22
|
+
class BundleGroup {
|
|
23
|
+
#bundleGroup /*: InternalBundleGroup */;
|
|
24
|
+
#options /*: AtlaspackOptions */;
|
|
25
|
+
|
|
26
|
+
constructor(bundleGroup, options) {
|
|
27
|
+
let existing = internalBundleGroupToBundleGroup.get(bundleGroup);
|
|
28
|
+
if (existing != null) {
|
|
29
|
+
return existing;
|
|
30
|
+
}
|
|
31
|
+
this.#bundleGroup = bundleGroup;
|
|
32
|
+
this.#options = options;
|
|
33
|
+
_bundleGroupToInternalBundleGroup.set(this, bundleGroup);
|
|
34
|
+
internalBundleGroupToBundleGroup.set(bundleGroup, this);
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
get target() {
|
|
38
|
+
return new _Target.default(this.#bundleGroup.target, this.#options);
|
|
39
|
+
}
|
|
40
|
+
get entryAssetId() {
|
|
41
|
+
return this.#bundleGroup.entryAssetId;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.default = BundleGroup;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
function _assert() {
|
|
8
|
+
const data = _interopRequireDefault(require("assert"));
|
|
9
|
+
_assert = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _path() {
|
|
15
|
+
const data = _interopRequireDefault(require("path"));
|
|
16
|
+
_path = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _utils() {
|
|
22
|
+
const data = require("@atlaspack/utils");
|
|
23
|
+
_utils = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
var _Environment = _interopRequireDefault(require("./Environment"));
|
|
29
|
+
var _projectPath = require("../projectPath");
|
|
30
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
+
const internalConfigToConfig = new (_utils().DefaultWeakMap)(() => new WeakMap());
|
|
32
|
+
class PublicConfig {
|
|
33
|
+
#config /*: Config */;
|
|
34
|
+
#pkg /*: ?PackageJSON */;
|
|
35
|
+
#pkgFilePath /*: ?FilePath */;
|
|
36
|
+
#options /*: AtlaspackOptions */;
|
|
37
|
+
|
|
38
|
+
constructor(config, options) {
|
|
39
|
+
let existing = internalConfigToConfig.get(options).get(config);
|
|
40
|
+
if (existing != null) {
|
|
41
|
+
return existing;
|
|
42
|
+
}
|
|
43
|
+
this.#config = config;
|
|
44
|
+
this.#options = options;
|
|
45
|
+
internalConfigToConfig.get(options).set(config, this);
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
get env() {
|
|
49
|
+
return new _Environment.default(this.#config.env, this.#options);
|
|
50
|
+
}
|
|
51
|
+
get searchPath() {
|
|
52
|
+
return (0, _projectPath.fromProjectPath)(this.#options.projectRoot, this.#config.searchPath);
|
|
53
|
+
}
|
|
54
|
+
get result() {
|
|
55
|
+
return this.#config.result;
|
|
56
|
+
}
|
|
57
|
+
get isSource() {
|
|
58
|
+
return this.#config.isSource;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// $FlowFixMe
|
|
62
|
+
setResult(result) {
|
|
63
|
+
this.#config.result = result;
|
|
64
|
+
}
|
|
65
|
+
setCacheKey(cacheKey) {
|
|
66
|
+
this.#config.cacheKey = cacheKey;
|
|
67
|
+
}
|
|
68
|
+
invalidateOnFileChange(filePath) {
|
|
69
|
+
this.#config.invalidateOnFileChange.add((0, _projectPath.toProjectPath)(this.#options.projectRoot, filePath));
|
|
70
|
+
}
|
|
71
|
+
invalidateOnConfigKeyChange(filePath, configKey) {
|
|
72
|
+
this.#config.invalidateOnConfigKeyChange.push({
|
|
73
|
+
filePath: (0, _projectPath.toProjectPath)(this.#options.projectRoot, filePath),
|
|
74
|
+
configKey
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
addDevDependency(devDep) {
|
|
78
|
+
var _devDep$additionalInv;
|
|
79
|
+
this.#config.devDeps.push({
|
|
80
|
+
...devDep,
|
|
81
|
+
resolveFrom: (0, _projectPath.toProjectPath)(this.#options.projectRoot, devDep.resolveFrom),
|
|
82
|
+
additionalInvalidations: (_devDep$additionalInv = devDep.additionalInvalidations) === null || _devDep$additionalInv === void 0 ? void 0 : _devDep$additionalInv.map(i => ({
|
|
83
|
+
...i,
|
|
84
|
+
resolveFrom: (0, _projectPath.toProjectPath)(this.#options.projectRoot, i.resolveFrom)
|
|
85
|
+
}))
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
invalidateOnFileCreate(invalidation) {
|
|
89
|
+
if (invalidation.glob != null) {
|
|
90
|
+
// $FlowFixMe
|
|
91
|
+
this.#config.invalidateOnFileCreate.push(invalidation);
|
|
92
|
+
} else if (invalidation.filePath != null) {
|
|
93
|
+
this.#config.invalidateOnFileCreate.push({
|
|
94
|
+
filePath: (0, _projectPath.toProjectPath)(this.#options.projectRoot, invalidation.filePath)
|
|
95
|
+
});
|
|
96
|
+
} else {
|
|
97
|
+
(0, _assert().default)(invalidation.aboveFilePath != null);
|
|
98
|
+
this.#config.invalidateOnFileCreate.push({
|
|
99
|
+
// $FlowFixMe
|
|
100
|
+
fileName: invalidation.fileName,
|
|
101
|
+
aboveFilePath: (0, _projectPath.toProjectPath)(this.#options.projectRoot, invalidation.aboveFilePath)
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
invalidateOnEnvChange(env) {
|
|
106
|
+
this.#config.invalidateOnEnvChange.add(env);
|
|
107
|
+
}
|
|
108
|
+
invalidateOnStartup() {
|
|
109
|
+
this.#config.invalidateOnStartup = true;
|
|
110
|
+
}
|
|
111
|
+
invalidateOnBuild() {
|
|
112
|
+
this.#config.invalidateOnBuild = true;
|
|
113
|
+
}
|
|
114
|
+
async getConfigFrom(searchPath, fileNames, options) {
|
|
115
|
+
let packageKey = options === null || options === void 0 ? void 0 : options.packageKey;
|
|
116
|
+
if (packageKey != null) {
|
|
117
|
+
let pkg = await this.getConfigFrom(searchPath, ['package.json'], {
|
|
118
|
+
exclude: true
|
|
119
|
+
});
|
|
120
|
+
if (pkg && pkg.contents[packageKey]) {
|
|
121
|
+
// Invalidate only when the package key changes
|
|
122
|
+
this.invalidateOnConfigKeyChange(pkg.filePath, packageKey);
|
|
123
|
+
return {
|
|
124
|
+
contents: pkg.contents[packageKey],
|
|
125
|
+
filePath: pkg.filePath
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (fileNames.length === 0) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Invalidate when any of the file names are created above the search path.
|
|
134
|
+
for (let fileName of fileNames) {
|
|
135
|
+
this.invalidateOnFileCreate({
|
|
136
|
+
fileName,
|
|
137
|
+
aboveFilePath: searchPath
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
let parse = options && options.parse;
|
|
141
|
+
let configFilePath = await (0, _utils().resolveConfig)(this.#options.inputFS, searchPath, fileNames, this.#options.projectRoot);
|
|
142
|
+
if (configFilePath == null) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
if (!options || !options.exclude) {
|
|
146
|
+
this.invalidateOnFileChange(configFilePath);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// If this is a JavaScript file, load it with the package manager.
|
|
150
|
+
let extname = _path().default.extname(configFilePath);
|
|
151
|
+
if (extname === '.js' || extname === '.cjs' || extname === '.mjs') {
|
|
152
|
+
let specifier = (0, _utils().relativePath)(_path().default.dirname(searchPath), configFilePath);
|
|
153
|
+
|
|
154
|
+
// Add dev dependency so we reload the config and any dependencies in watch mode.
|
|
155
|
+
this.addDevDependency({
|
|
156
|
+
specifier,
|
|
157
|
+
resolveFrom: searchPath
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
// Invalidate on startup in case the config is non-deterministic,
|
|
161
|
+
// e.g. uses unknown environment variables, reads from the filesystem, etc.
|
|
162
|
+
this.invalidateOnStartup();
|
|
163
|
+
let config = await this.#options.packageManager.require(specifier, searchPath);
|
|
164
|
+
if (
|
|
165
|
+
// $FlowFixMe
|
|
166
|
+
Object.prototype.toString.call(config) === '[object Module]' && config.default != null) {
|
|
167
|
+
// Native ESM config. Try to use a default export, otherwise fall back to the whole namespace.
|
|
168
|
+
config = config.default;
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
contents: config,
|
|
172
|
+
filePath: configFilePath
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
let conf = await (0, _utils().readConfig)(this.#options.inputFS, configFilePath, parse == null ? null : {
|
|
176
|
+
parse
|
|
177
|
+
});
|
|
178
|
+
if (conf == null) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
return {
|
|
182
|
+
contents: conf.config,
|
|
183
|
+
filePath: configFilePath
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
getConfig(filePaths, options) {
|
|
187
|
+
return this.getConfigFrom(this.searchPath, filePaths, options);
|
|
188
|
+
}
|
|
189
|
+
async getPackage() {
|
|
190
|
+
if (this.#pkg) {
|
|
191
|
+
return this.#pkg;
|
|
192
|
+
}
|
|
193
|
+
let pkgConfig = await this.getConfig(['package.json']);
|
|
194
|
+
if (!pkgConfig) {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
this.#pkg = pkgConfig.contents;
|
|
198
|
+
this.#pkgFilePath = pkgConfig.filePath;
|
|
199
|
+
return this.#pkg;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
exports.default = PublicConfig;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
exports.dependencyToInternalDependency = dependencyToInternalDependency;
|
|
8
|
+
exports.getPublicDependency = getPublicDependency;
|
|
9
|
+
var _types = require("../types");
|
|
10
|
+
function _nullthrows() {
|
|
11
|
+
const data = _interopRequireDefault(require("nullthrows"));
|
|
12
|
+
_nullthrows = function () {
|
|
13
|
+
return data;
|
|
14
|
+
};
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
var _Environment = _interopRequireDefault(require("./Environment"));
|
|
18
|
+
var _Target = _interopRequireDefault(require("./Target"));
|
|
19
|
+
var _Symbols = require("./Symbols");
|
|
20
|
+
var _projectPath = require("../projectPath");
|
|
21
|
+
var _utils = require("../utils");
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
const SpecifierTypeNames = Object.keys(_types.SpecifierType);
|
|
24
|
+
const PriorityNames = Object.keys(_types.Priority);
|
|
25
|
+
const inspect = Symbol.for('nodejs.util.inspect.custom');
|
|
26
|
+
const internalDependencyToDependency = new WeakMap();
|
|
27
|
+
const _dependencyToInternalDependency = new WeakMap();
|
|
28
|
+
function dependencyToInternalDependency(dependency) {
|
|
29
|
+
return (0, _nullthrows().default)(_dependencyToInternalDependency.get(dependency));
|
|
30
|
+
}
|
|
31
|
+
function getPublicDependency(dep, options) {
|
|
32
|
+
let existing = internalDependencyToDependency.get(dep);
|
|
33
|
+
if (existing != null) {
|
|
34
|
+
return existing;
|
|
35
|
+
}
|
|
36
|
+
return new Dependency(dep, options);
|
|
37
|
+
}
|
|
38
|
+
class Dependency {
|
|
39
|
+
#dep /*: InternalDependency */;
|
|
40
|
+
#options /*: AtlaspackOptions */;
|
|
41
|
+
|
|
42
|
+
constructor(dep, options) {
|
|
43
|
+
this.#dep = dep;
|
|
44
|
+
this.#options = options;
|
|
45
|
+
_dependencyToInternalDependency.set(this, dep);
|
|
46
|
+
internalDependencyToDependency.set(dep, this);
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// $FlowFixMe
|
|
51
|
+
[inspect]() {
|
|
52
|
+
return `Dependency(${String(this.sourcePath)} -> ${this.specifier})`;
|
|
53
|
+
}
|
|
54
|
+
get id() {
|
|
55
|
+
return this.#dep.id;
|
|
56
|
+
}
|
|
57
|
+
get specifier() {
|
|
58
|
+
return this.#dep.specifier;
|
|
59
|
+
}
|
|
60
|
+
get specifierType() {
|
|
61
|
+
return SpecifierTypeNames[this.#dep.specifierType];
|
|
62
|
+
}
|
|
63
|
+
get priority() {
|
|
64
|
+
return PriorityNames[this.#dep.priority];
|
|
65
|
+
}
|
|
66
|
+
get needsStableName() {
|
|
67
|
+
return this.#dep.needsStableName;
|
|
68
|
+
}
|
|
69
|
+
get bundleBehavior() {
|
|
70
|
+
let bundleBehavior = this.#dep.bundleBehavior;
|
|
71
|
+
return bundleBehavior == null ? null : _types.BundleBehaviorNames[bundleBehavior];
|
|
72
|
+
}
|
|
73
|
+
get isEntry() {
|
|
74
|
+
return this.#dep.isEntry;
|
|
75
|
+
}
|
|
76
|
+
get isOptional() {
|
|
77
|
+
return this.#dep.isOptional;
|
|
78
|
+
}
|
|
79
|
+
get loc() {
|
|
80
|
+
return (0, _utils.fromInternalSourceLocation)(this.#options.projectRoot, this.#dep.loc);
|
|
81
|
+
}
|
|
82
|
+
get env() {
|
|
83
|
+
return new _Environment.default(this.#dep.env, this.#options);
|
|
84
|
+
}
|
|
85
|
+
get packageConditions() {
|
|
86
|
+
// Merge custom conditions with conditions stored as bitflags.
|
|
87
|
+
// Order is not important because exports conditions are resolved
|
|
88
|
+
// in the order they are declared in the package.json.
|
|
89
|
+
let conditions = this.#dep.customPackageConditions;
|
|
90
|
+
if (this.#dep.packageConditions) {
|
|
91
|
+
conditions = conditions ? [...conditions] : [];
|
|
92
|
+
for (let key in _types.ExportsCondition) {
|
|
93
|
+
if (this.#dep.packageConditions & _types.ExportsCondition[key]) {
|
|
94
|
+
conditions.push(key);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return conditions;
|
|
99
|
+
}
|
|
100
|
+
get meta() {
|
|
101
|
+
return this.#dep.meta;
|
|
102
|
+
}
|
|
103
|
+
get symbols() {
|
|
104
|
+
return new _Symbols.MutableDependencySymbols(this.#options, this.#dep);
|
|
105
|
+
}
|
|
106
|
+
get target() {
|
|
107
|
+
let target = this.#dep.target;
|
|
108
|
+
return target ? new _Target.default(target, this.#options) : null;
|
|
109
|
+
}
|
|
110
|
+
get sourceAssetId() {
|
|
111
|
+
// TODO: does this need to be public?
|
|
112
|
+
return this.#dep.sourceAssetId;
|
|
113
|
+
}
|
|
114
|
+
get sourcePath() {
|
|
115
|
+
// TODO: does this need to be public?
|
|
116
|
+
return (0, _projectPath.fromProjectPath)(this.#options.projectRoot, this.#dep.sourcePath);
|
|
117
|
+
}
|
|
118
|
+
get sourceAssetType() {
|
|
119
|
+
return this.#dep.sourceAssetType;
|
|
120
|
+
}
|
|
121
|
+
get resolveFrom() {
|
|
122
|
+
return (0, _projectPath.fromProjectPath)(this.#options.projectRoot, this.#dep.resolveFrom ?? this.#dep.sourcePath);
|
|
123
|
+
}
|
|
124
|
+
get range() {
|
|
125
|
+
return this.#dep.range;
|
|
126
|
+
}
|
|
127
|
+
get pipeline() {
|
|
128
|
+
return this.#dep.pipeline;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.default = Dependency;
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.ISOLATED_ENVS = exports.BROWSER_ENVS = void 0;
|
|
7
|
+
exports.environmentToInternalEnvironment = environmentToInternalEnvironment;
|
|
8
|
+
function _nullthrows() {
|
|
9
|
+
const data = _interopRequireDefault(require("nullthrows"));
|
|
10
|
+
_nullthrows = function () {
|
|
11
|
+
return data;
|
|
12
|
+
};
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
function _browserslist() {
|
|
16
|
+
const data = _interopRequireDefault(require("browserslist"));
|
|
17
|
+
_browserslist = function () {
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
function _semver() {
|
|
23
|
+
const data = _interopRequireDefault(require("semver"));
|
|
24
|
+
_semver = function () {
|
|
25
|
+
return data;
|
|
26
|
+
};
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
var _utils = require("../utils");
|
|
30
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
+
const inspect = Symbol.for('nodejs.util.inspect.custom');
|
|
32
|
+
const BROWSER_ENVS = exports.BROWSER_ENVS = new Set(['browser', 'web-worker', 'service-worker', 'worklet', 'electron-renderer']);
|
|
33
|
+
const ELECTRON_ENVS = new Set(['electron-main', 'electron-renderer']);
|
|
34
|
+
const NODE_ENVS = new Set(['node', ...ELECTRON_ENVS]);
|
|
35
|
+
const WORKER_ENVS = new Set(['web-worker', 'service-worker']);
|
|
36
|
+
const ISOLATED_ENVS = exports.ISOLATED_ENVS = new Set([...WORKER_ENVS, 'worklet']);
|
|
37
|
+
const ALL_BROWSERS = ['chrome', 'and_chr', 'edge', 'firefox', 'and_ff', 'safari', 'ios', 'samsung', 'opera', 'ie', 'op_mini', 'blackberry', 'op_mob', 'ie_mob', 'and_uc', 'and_qq', 'baidu', 'kaios'];
|
|
38
|
+
|
|
39
|
+
// See require("caniuse-api").getSupport(<feature name>)
|
|
40
|
+
const supportData = {
|
|
41
|
+
esmodules: {
|
|
42
|
+
edge: '16',
|
|
43
|
+
firefox: '60',
|
|
44
|
+
chrome: '61',
|
|
45
|
+
safari: '10.1',
|
|
46
|
+
opera: '48',
|
|
47
|
+
ios: '10.3',
|
|
48
|
+
android: '76',
|
|
49
|
+
and_chr: '76',
|
|
50
|
+
and_ff: '68',
|
|
51
|
+
samsung: '8.2',
|
|
52
|
+
and_qq: '10.4',
|
|
53
|
+
op_mob: '64'
|
|
54
|
+
},
|
|
55
|
+
'dynamic-import': {
|
|
56
|
+
edge: '76',
|
|
57
|
+
firefox: '67',
|
|
58
|
+
chrome: '63',
|
|
59
|
+
safari: '11.1',
|
|
60
|
+
opera: '50',
|
|
61
|
+
ios: '11.3',
|
|
62
|
+
android: '63',
|
|
63
|
+
and_chr: '63',
|
|
64
|
+
and_ff: '67',
|
|
65
|
+
samsung: '8',
|
|
66
|
+
and_qq: '10.4',
|
|
67
|
+
op_mob: '64'
|
|
68
|
+
},
|
|
69
|
+
'worker-module': {
|
|
70
|
+
edge: '80',
|
|
71
|
+
chrome: '80',
|
|
72
|
+
opera: '67',
|
|
73
|
+
android: '81',
|
|
74
|
+
and_chr: '86'
|
|
75
|
+
},
|
|
76
|
+
'service-worker-module': {
|
|
77
|
+
// TODO: Safari 14.1??
|
|
78
|
+
},
|
|
79
|
+
'import-meta-url': {
|
|
80
|
+
edge: '79',
|
|
81
|
+
firefox: '62',
|
|
82
|
+
chrome: '64',
|
|
83
|
+
safari: '11.1',
|
|
84
|
+
opera: '51',
|
|
85
|
+
ios: '12',
|
|
86
|
+
android: '64',
|
|
87
|
+
and_chr: '64',
|
|
88
|
+
and_ff: '62',
|
|
89
|
+
samsung: '9.2',
|
|
90
|
+
and_qq: '10.4',
|
|
91
|
+
op_mob: '64'
|
|
92
|
+
},
|
|
93
|
+
'arrow-functions': {
|
|
94
|
+
chrome: '47',
|
|
95
|
+
opera: '34',
|
|
96
|
+
edge: '13',
|
|
97
|
+
firefox: '45',
|
|
98
|
+
safari: '10',
|
|
99
|
+
node: '6',
|
|
100
|
+
ios: '10',
|
|
101
|
+
samsung: '5',
|
|
102
|
+
electron: '0.36',
|
|
103
|
+
android: '50',
|
|
104
|
+
qq: '10.4',
|
|
105
|
+
baidu: '7.12',
|
|
106
|
+
kaios: '2.5',
|
|
107
|
+
and_chr: '50',
|
|
108
|
+
and_qq: '12.12',
|
|
109
|
+
op_mob: '64'
|
|
110
|
+
},
|
|
111
|
+
'global-this': {
|
|
112
|
+
chrome: '75',
|
|
113
|
+
edge: '79',
|
|
114
|
+
safari: '12.1',
|
|
115
|
+
firefox: '65',
|
|
116
|
+
opera: '58',
|
|
117
|
+
node: '12',
|
|
118
|
+
and_chr: '71',
|
|
119
|
+
ios: '12.2',
|
|
120
|
+
android: '71',
|
|
121
|
+
samsung: '10.1'
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
const internalEnvironmentToEnvironment = new WeakMap();
|
|
125
|
+
const _environmentToInternalEnvironment = new WeakMap();
|
|
126
|
+
function environmentToInternalEnvironment(environment) {
|
|
127
|
+
return (0, _nullthrows().default)(_environmentToInternalEnvironment.get(environment));
|
|
128
|
+
}
|
|
129
|
+
class Environment {
|
|
130
|
+
#environment /*: InternalEnvironment */;
|
|
131
|
+
#options /*: AtlaspackOptions */;
|
|
132
|
+
|
|
133
|
+
constructor(env, options) {
|
|
134
|
+
let existing = internalEnvironmentToEnvironment.get(env);
|
|
135
|
+
if (existing != null) {
|
|
136
|
+
return existing;
|
|
137
|
+
}
|
|
138
|
+
this.#environment = env;
|
|
139
|
+
this.#options = options;
|
|
140
|
+
_environmentToInternalEnvironment.set(this, env);
|
|
141
|
+
internalEnvironmentToEnvironment.set(env, this);
|
|
142
|
+
return this;
|
|
143
|
+
}
|
|
144
|
+
get id() {
|
|
145
|
+
return this.#environment.id;
|
|
146
|
+
}
|
|
147
|
+
get context() {
|
|
148
|
+
return this.#environment.context;
|
|
149
|
+
}
|
|
150
|
+
get engines() {
|
|
151
|
+
return this.#environment.engines;
|
|
152
|
+
}
|
|
153
|
+
get includeNodeModules() {
|
|
154
|
+
return this.#environment.includeNodeModules;
|
|
155
|
+
}
|
|
156
|
+
get outputFormat() {
|
|
157
|
+
return this.#environment.outputFormat;
|
|
158
|
+
}
|
|
159
|
+
get sourceType() {
|
|
160
|
+
return this.#environment.sourceType;
|
|
161
|
+
}
|
|
162
|
+
get isLibrary() {
|
|
163
|
+
return this.#environment.isLibrary;
|
|
164
|
+
}
|
|
165
|
+
get shouldOptimize() {
|
|
166
|
+
return this.#environment.shouldOptimize;
|
|
167
|
+
}
|
|
168
|
+
get shouldScopeHoist() {
|
|
169
|
+
return this.#environment.shouldScopeHoist;
|
|
170
|
+
}
|
|
171
|
+
get sourceMap() {
|
|
172
|
+
return this.#environment.sourceMap;
|
|
173
|
+
}
|
|
174
|
+
get loc() {
|
|
175
|
+
return (0, _utils.fromInternalSourceLocation)(this.#options.projectRoot, this.#environment.loc);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// $FlowFixMe[unsupported-syntax]
|
|
179
|
+
[inspect]() {
|
|
180
|
+
return `Env(${this.#environment.context})`;
|
|
181
|
+
}
|
|
182
|
+
isBrowser() {
|
|
183
|
+
return BROWSER_ENVS.has(this.#environment.context);
|
|
184
|
+
}
|
|
185
|
+
isNode() {
|
|
186
|
+
return NODE_ENVS.has(this.#environment.context);
|
|
187
|
+
}
|
|
188
|
+
isElectron() {
|
|
189
|
+
return ELECTRON_ENVS.has(this.#environment.context);
|
|
190
|
+
}
|
|
191
|
+
isIsolated() {
|
|
192
|
+
return ISOLATED_ENVS.has(this.#environment.context);
|
|
193
|
+
}
|
|
194
|
+
isWorker() {
|
|
195
|
+
return WORKER_ENVS.has(this.#environment.context);
|
|
196
|
+
}
|
|
197
|
+
isWorklet() {
|
|
198
|
+
return this.#environment.context === 'worklet';
|
|
199
|
+
}
|
|
200
|
+
matchesEngines(minVersions, defaultValue = false) {
|
|
201
|
+
// Determine if the environment matches some minimum version requirements.
|
|
202
|
+
// For browsers, we run a browserslist query with and without the minimum
|
|
203
|
+
// required browsers and compare the lists. For node, we just check semver.
|
|
204
|
+
if (this.isBrowser() && this.engines.browsers != null) {
|
|
205
|
+
let targetBrowsers = this.engines.browsers;
|
|
206
|
+
let browsers = targetBrowsers != null && !Array.isArray(targetBrowsers) ? [targetBrowsers] : targetBrowsers;
|
|
207
|
+
|
|
208
|
+
// If outputting esmodules, exclude browsers without support.
|
|
209
|
+
if (this.outputFormat === 'esmodule') {
|
|
210
|
+
browsers = [...browsers, ...getExcludedBrowsers(supportData.esmodules)];
|
|
211
|
+
}
|
|
212
|
+
let matchedBrowsers = (0, _browserslist().default)(browsers);
|
|
213
|
+
if (matchedBrowsers.length === 0) {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
let minBrowsers = getExcludedBrowsers(minVersions);
|
|
217
|
+
let withoutMinBrowsers = (0, _browserslist().default)([...browsers, ...minBrowsers]);
|
|
218
|
+
return matchedBrowsers.length === withoutMinBrowsers.length;
|
|
219
|
+
} else if (this.isNode() && this.engines.node != null) {
|
|
220
|
+
return minVersions.node != null && !_semver().default.intersects(`< ${minVersions.node}`, this.engines.node);
|
|
221
|
+
}
|
|
222
|
+
return defaultValue;
|
|
223
|
+
}
|
|
224
|
+
supports(feature, defaultValue) {
|
|
225
|
+
let engines = supportData[feature];
|
|
226
|
+
if (!engines) {
|
|
227
|
+
throw new Error('Unknown environment feature: ' + feature);
|
|
228
|
+
}
|
|
229
|
+
return this.matchesEngines(engines, defaultValue);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
exports.default = Environment;
|
|
233
|
+
function getExcludedBrowsers(minVersions) {
|
|
234
|
+
let browsers = [];
|
|
235
|
+
for (let browser of ALL_BROWSERS) {
|
|
236
|
+
let version = minVersions[browser];
|
|
237
|
+
if (version) {
|
|
238
|
+
browsers.push(`not ${browser} < ${version}`);
|
|
239
|
+
} else {
|
|
240
|
+
browsers.push(`not ${browser} > 0`);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return browsers;
|
|
244
|
+
}
|