@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,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
function _stream() {
|
|
8
|
+
const data = require("stream");
|
|
9
|
+
_stream = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _sourceMap() {
|
|
15
|
+
const data = _interopRequireDefault(require("@parcel/source-map"));
|
|
16
|
+
_sourceMap = 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 _assetUtils = require("./assetUtils");
|
|
29
|
+
var _serializer = require("./serializer");
|
|
30
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
+
class CommittedAsset {
|
|
32
|
+
constructor(value, options) {
|
|
33
|
+
this.value = value;
|
|
34
|
+
this.key = this.value.contentKey;
|
|
35
|
+
this.options = options;
|
|
36
|
+
}
|
|
37
|
+
getContent() {
|
|
38
|
+
if (this.content == null) {
|
|
39
|
+
if (this.key != null) {
|
|
40
|
+
if (this.value.isLargeBlob) {
|
|
41
|
+
return this.options.cache.getStream(this.key);
|
|
42
|
+
} else {
|
|
43
|
+
return this.options.cache.getBlob(this.key);
|
|
44
|
+
}
|
|
45
|
+
} else if (this.value.astKey != null) {
|
|
46
|
+
return (0, _utils().streamFromPromise)((0, _assetUtils.generateFromAST)(this).then(({
|
|
47
|
+
content
|
|
48
|
+
}) => {
|
|
49
|
+
if (!(content instanceof _stream().Readable)) {
|
|
50
|
+
this.content = Promise.resolve(content);
|
|
51
|
+
}
|
|
52
|
+
return content;
|
|
53
|
+
}));
|
|
54
|
+
} else {
|
|
55
|
+
throw new Error('Asset has no content');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return this.content;
|
|
59
|
+
}
|
|
60
|
+
async getCode() {
|
|
61
|
+
let content;
|
|
62
|
+
if (this.content == null && this.key != null) {
|
|
63
|
+
this.content = this.options.cache.getBlob(this.key);
|
|
64
|
+
content = await this.content;
|
|
65
|
+
} else {
|
|
66
|
+
content = await this.getContent();
|
|
67
|
+
}
|
|
68
|
+
if (typeof content === 'string' || content instanceof Buffer) {
|
|
69
|
+
return content.toString();
|
|
70
|
+
} else if (content != null) {
|
|
71
|
+
this.content = (0, _utils().bufferStream)(content);
|
|
72
|
+
return (await this.content).toString();
|
|
73
|
+
}
|
|
74
|
+
return '';
|
|
75
|
+
}
|
|
76
|
+
async getBuffer() {
|
|
77
|
+
let content = await this.getContent();
|
|
78
|
+
if (content == null) {
|
|
79
|
+
return Buffer.alloc(0);
|
|
80
|
+
} else if (typeof content === 'string' || content instanceof Buffer) {
|
|
81
|
+
return Buffer.from(content);
|
|
82
|
+
}
|
|
83
|
+
this.content = (0, _utils().bufferStream)(content);
|
|
84
|
+
return this.content;
|
|
85
|
+
}
|
|
86
|
+
getStream() {
|
|
87
|
+
let content = this.getContent();
|
|
88
|
+
return content instanceof Promise ? (0, _utils().streamFromPromise)(content) : (0, _utils().blobToStream)(content);
|
|
89
|
+
}
|
|
90
|
+
getMapBuffer() {
|
|
91
|
+
let mapKey = this.value.mapKey;
|
|
92
|
+
if (mapKey != null && this.mapBuffer == null) {
|
|
93
|
+
this.mapBuffer = (async () => {
|
|
94
|
+
try {
|
|
95
|
+
return await this.options.cache.getBlob(mapKey);
|
|
96
|
+
} catch (err) {
|
|
97
|
+
if (err.code === 'ENOENT' && this.value.astKey != null) {
|
|
98
|
+
var _await$generateFromAS;
|
|
99
|
+
return (_await$generateFromAS = (await (0, _assetUtils.generateFromAST)(this)).map) === null || _await$generateFromAS === void 0 ? void 0 : _await$generateFromAS.toBuffer();
|
|
100
|
+
} else {
|
|
101
|
+
throw err;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
})();
|
|
105
|
+
}
|
|
106
|
+
return this.mapBuffer ?? Promise.resolve();
|
|
107
|
+
}
|
|
108
|
+
getMap() {
|
|
109
|
+
if (this.map == null) {
|
|
110
|
+
this.map = (async () => {
|
|
111
|
+
let mapBuffer = await this.getMapBuffer();
|
|
112
|
+
if (mapBuffer) {
|
|
113
|
+
// Get sourcemap from flatbuffer
|
|
114
|
+
return new (_sourceMap().default)(this.options.projectRoot, mapBuffer);
|
|
115
|
+
}
|
|
116
|
+
})();
|
|
117
|
+
}
|
|
118
|
+
return this.map;
|
|
119
|
+
}
|
|
120
|
+
getAST() {
|
|
121
|
+
if (this.value.astKey == null) {
|
|
122
|
+
return Promise.resolve(null);
|
|
123
|
+
}
|
|
124
|
+
if (this.ast == null) {
|
|
125
|
+
this.ast = this.options.cache.getBlob(this.value.astKey).then(serializedAst => (0, _serializer.deserializeRaw)(serializedAst));
|
|
126
|
+
}
|
|
127
|
+
return this.ast;
|
|
128
|
+
}
|
|
129
|
+
getDependencies() {
|
|
130
|
+
return Array.from(this.value.dependencies.values());
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.default = CommittedAsset;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createDependency = createDependency;
|
|
7
|
+
exports.mergeDependencies = mergeDependencies;
|
|
8
|
+
function _rust() {
|
|
9
|
+
const data = require("@atlaspack/rust");
|
|
10
|
+
_rust = function () {
|
|
11
|
+
return data;
|
|
12
|
+
};
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
var _types = require("./types");
|
|
16
|
+
var _utils = require("./utils");
|
|
17
|
+
var _projectPath = require("./projectPath");
|
|
18
|
+
function createDependency(projectRoot, opts) {
|
|
19
|
+
let id = opts.id || (0, _rust().hashString)((opts.sourceAssetId ?? '') + opts.specifier + opts.env.id + (opts.target ? JSON.stringify(opts.target) : '') + (opts.pipeline ?? '') + opts.specifierType + (opts.bundleBehavior ?? '') + (opts.priority ?? 'sync') + (opts.packageConditions ? JSON.stringify(opts.packageConditions) : ''));
|
|
20
|
+
let dep = {
|
|
21
|
+
id,
|
|
22
|
+
specifier: opts.specifier,
|
|
23
|
+
specifierType: _types.SpecifierType[opts.specifierType],
|
|
24
|
+
priority: _types.Priority[opts.priority ?? 'sync'],
|
|
25
|
+
needsStableName: opts.needsStableName ?? false,
|
|
26
|
+
bundleBehavior: opts.bundleBehavior ? _types.BundleBehavior[opts.bundleBehavior] : null,
|
|
27
|
+
isEntry: opts.isEntry ?? false,
|
|
28
|
+
isOptional: opts.isOptional ?? false,
|
|
29
|
+
loc: (0, _utils.toInternalSourceLocation)(projectRoot, opts.loc),
|
|
30
|
+
env: opts.env,
|
|
31
|
+
meta: opts.meta || {},
|
|
32
|
+
target: opts.target,
|
|
33
|
+
sourceAssetId: opts.sourceAssetId,
|
|
34
|
+
sourcePath: (0, _projectPath.toProjectPath)(projectRoot, opts.sourcePath),
|
|
35
|
+
resolveFrom: (0, _projectPath.toProjectPath)(projectRoot, opts.resolveFrom),
|
|
36
|
+
range: opts.range,
|
|
37
|
+
symbols: opts.symbols && new Map([...opts.symbols].map(([k, v]) => [k, {
|
|
38
|
+
local: v.local,
|
|
39
|
+
meta: v.meta,
|
|
40
|
+
isWeak: v.isWeak,
|
|
41
|
+
loc: (0, _utils.toInternalSourceLocation)(projectRoot, v.loc)
|
|
42
|
+
}])),
|
|
43
|
+
pipeline: opts.pipeline
|
|
44
|
+
};
|
|
45
|
+
if (opts.packageConditions) {
|
|
46
|
+
convertConditions(opts.packageConditions, dep);
|
|
47
|
+
}
|
|
48
|
+
return dep;
|
|
49
|
+
}
|
|
50
|
+
function mergeDependencies(a, b) {
|
|
51
|
+
let {
|
|
52
|
+
meta,
|
|
53
|
+
symbols,
|
|
54
|
+
needsStableName,
|
|
55
|
+
isEntry,
|
|
56
|
+
isOptional,
|
|
57
|
+
...other
|
|
58
|
+
} = b;
|
|
59
|
+
Object.assign(a, other);
|
|
60
|
+
Object.assign(a.meta, meta);
|
|
61
|
+
if (a.symbols && symbols) {
|
|
62
|
+
for (let [k, v] of symbols) {
|
|
63
|
+
a.symbols.set(k, v);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (needsStableName) a.needsStableName = true;
|
|
67
|
+
if (isEntry) a.isEntry = true;
|
|
68
|
+
if (!isOptional) a.isOptional = false;
|
|
69
|
+
}
|
|
70
|
+
function convertConditions(conditions, dep) {
|
|
71
|
+
// Store common package conditions as bit flags to reduce size.
|
|
72
|
+
// Custom conditions are stored as strings.
|
|
73
|
+
let packageConditions = 0;
|
|
74
|
+
let customConditions = [];
|
|
75
|
+
for (let condition of conditions) {
|
|
76
|
+
if (_types.ExportsCondition[condition]) {
|
|
77
|
+
packageConditions |= _types.ExportsCondition[condition];
|
|
78
|
+
} else {
|
|
79
|
+
customConditions.push(condition);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (packageConditions) {
|
|
83
|
+
dep.packageConditions = packageConditions;
|
|
84
|
+
}
|
|
85
|
+
if (customConditions.length) {
|
|
86
|
+
dep.customPackageConditions = customConditions;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createEnvironment = createEnvironment;
|
|
7
|
+
exports.mergeEnvironments = mergeEnvironments;
|
|
8
|
+
function _rust() {
|
|
9
|
+
const data = require("@atlaspack/rust");
|
|
10
|
+
_rust = function () {
|
|
11
|
+
return data;
|
|
12
|
+
};
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
var _utils = require("./utils");
|
|
16
|
+
var _Environment = _interopRequireWildcard(require("./public/Environment"));
|
|
17
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
19
|
+
const DEFAULT_ENGINES = {
|
|
20
|
+
browsers: ['> 0.25%'],
|
|
21
|
+
node: '>= 8.0.0'
|
|
22
|
+
};
|
|
23
|
+
function createEnvironment({
|
|
24
|
+
context,
|
|
25
|
+
engines,
|
|
26
|
+
includeNodeModules,
|
|
27
|
+
outputFormat,
|
|
28
|
+
sourceType = 'module',
|
|
29
|
+
shouldOptimize = false,
|
|
30
|
+
isLibrary = false,
|
|
31
|
+
shouldScopeHoist = false,
|
|
32
|
+
sourceMap,
|
|
33
|
+
loc
|
|
34
|
+
} = {
|
|
35
|
+
/*::...null*/
|
|
36
|
+
}) {
|
|
37
|
+
if (context == null) {
|
|
38
|
+
var _engines, _engines2;
|
|
39
|
+
if ((_engines = engines) !== null && _engines !== void 0 && _engines.node) {
|
|
40
|
+
context = 'node';
|
|
41
|
+
} else if ((_engines2 = engines) !== null && _engines2 !== void 0 && _engines2.browsers) {
|
|
42
|
+
context = 'browser';
|
|
43
|
+
} else {
|
|
44
|
+
context = 'browser';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (engines == null) {
|
|
48
|
+
switch (context) {
|
|
49
|
+
case 'node':
|
|
50
|
+
case 'electron-main':
|
|
51
|
+
engines = {
|
|
52
|
+
node: DEFAULT_ENGINES.node
|
|
53
|
+
};
|
|
54
|
+
break;
|
|
55
|
+
case 'browser':
|
|
56
|
+
case 'web-worker':
|
|
57
|
+
case 'service-worker':
|
|
58
|
+
case 'electron-renderer':
|
|
59
|
+
engines = {
|
|
60
|
+
browsers: DEFAULT_ENGINES.browsers
|
|
61
|
+
};
|
|
62
|
+
break;
|
|
63
|
+
default:
|
|
64
|
+
engines = {};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (includeNodeModules == null) {
|
|
68
|
+
switch (context) {
|
|
69
|
+
case 'node':
|
|
70
|
+
case 'electron-main':
|
|
71
|
+
case 'electron-renderer':
|
|
72
|
+
includeNodeModules = false;
|
|
73
|
+
break;
|
|
74
|
+
case 'browser':
|
|
75
|
+
case 'web-worker':
|
|
76
|
+
case 'service-worker':
|
|
77
|
+
default:
|
|
78
|
+
includeNodeModules = true;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (outputFormat == null) {
|
|
83
|
+
switch (context) {
|
|
84
|
+
case 'node':
|
|
85
|
+
case 'electron-main':
|
|
86
|
+
case 'electron-renderer':
|
|
87
|
+
outputFormat = 'commonjs';
|
|
88
|
+
break;
|
|
89
|
+
default:
|
|
90
|
+
outputFormat = 'global';
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
let res = {
|
|
95
|
+
id: '',
|
|
96
|
+
context,
|
|
97
|
+
engines,
|
|
98
|
+
includeNodeModules,
|
|
99
|
+
outputFormat,
|
|
100
|
+
sourceType,
|
|
101
|
+
isLibrary,
|
|
102
|
+
shouldOptimize,
|
|
103
|
+
shouldScopeHoist,
|
|
104
|
+
sourceMap,
|
|
105
|
+
loc
|
|
106
|
+
};
|
|
107
|
+
res.id = getEnvironmentHash(res);
|
|
108
|
+
return res;
|
|
109
|
+
}
|
|
110
|
+
function mergeEnvironments(projectRoot, a, b) {
|
|
111
|
+
// If merging the same object, avoid copying.
|
|
112
|
+
if (a === b || !b) {
|
|
113
|
+
return a;
|
|
114
|
+
}
|
|
115
|
+
if (b instanceof _Environment.default) {
|
|
116
|
+
return (0, _Environment.environmentToInternalEnvironment)(b);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// $FlowFixMe - ignore the `id` that is already on a
|
|
120
|
+
return createEnvironment({
|
|
121
|
+
...a,
|
|
122
|
+
...b,
|
|
123
|
+
loc: b.loc ? (0, _utils.toInternalSourceLocation)(projectRoot, b.loc) : a.loc
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
function getEnvironmentHash(env) {
|
|
127
|
+
return (0, _rust().hashString)(JSON.stringify([env.context, env.engines, env.includeNodeModules, env.outputFormat, env.sourceType, env.isLibrary, env.shouldOptimize, env.shouldScopeHoist, env.sourceMap]));
|
|
128
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createConfig = createConfig;
|
|
7
|
+
var _projectPath = require("./projectPath");
|
|
8
|
+
var _Environment = require("./Environment");
|
|
9
|
+
function _rust() {
|
|
10
|
+
const data = require("@atlaspack/rust");
|
|
11
|
+
_rust = function () {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
return data;
|
|
15
|
+
}
|
|
16
|
+
function createConfig({
|
|
17
|
+
plugin,
|
|
18
|
+
isSource,
|
|
19
|
+
searchPath,
|
|
20
|
+
env,
|
|
21
|
+
result,
|
|
22
|
+
invalidateOnFileChange,
|
|
23
|
+
invalidateOnConfigKeyChange,
|
|
24
|
+
invalidateOnFileCreate,
|
|
25
|
+
invalidateOnEnvChange,
|
|
26
|
+
invalidateOnOptionChange,
|
|
27
|
+
devDeps,
|
|
28
|
+
invalidateOnStartup,
|
|
29
|
+
invalidateOnBuild
|
|
30
|
+
}) {
|
|
31
|
+
let environment = env ?? (0, _Environment.createEnvironment)();
|
|
32
|
+
return {
|
|
33
|
+
id: (0, _rust().hashString)(plugin + (0, _projectPath.fromProjectPathRelative)(searchPath) + environment.id + String(isSource)),
|
|
34
|
+
isSource: isSource ?? false,
|
|
35
|
+
searchPath,
|
|
36
|
+
env: environment,
|
|
37
|
+
result: result ?? null,
|
|
38
|
+
cacheKey: null,
|
|
39
|
+
invalidateOnFileChange: invalidateOnFileChange ?? new Set(),
|
|
40
|
+
invalidateOnConfigKeyChange: invalidateOnConfigKeyChange ?? [],
|
|
41
|
+
invalidateOnFileCreate: invalidateOnFileCreate ?? [],
|
|
42
|
+
invalidateOnEnvChange: invalidateOnEnvChange ?? new Set(),
|
|
43
|
+
invalidateOnOptionChange: invalidateOnOptionChange ?? new Set(),
|
|
44
|
+
devDeps: devDeps ?? [],
|
|
45
|
+
invalidateOnStartup: invalidateOnStartup ?? false,
|
|
46
|
+
invalidateOnBuild: invalidateOnBuild ?? false
|
|
47
|
+
};
|
|
48
|
+
}
|