@atlaspack/core 2.13.2-dev.3682 → 2.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +61 -0
- package/package.json +20 -20
- package/src/Atlaspack.js +3 -2
- package/src/atlaspack-v3/AtlaspackV3.js +24 -8
- package/src/loadAtlaspackPlugin.js +26 -71
- package/src/projectPath.js +14 -1
- package/src/requests/WriteBundlesRequest.js +31 -22
- package/LICENSE +0 -201
- package/lib/AssetGraph.js +0 -521
- package/lib/Atlaspack.js +0 -676
- package/lib/AtlaspackConfig.js +0 -298
- package/lib/AtlaspackConfig.schema.js +0 -103
- package/lib/BundleGraph.js +0 -1527
- package/lib/CommittedAsset.js +0 -155
- package/lib/Dependency.js +0 -136
- package/lib/Environment.js +0 -144
- package/lib/IdentifierRegistry.js +0 -36
- package/lib/InternalConfig.js +0 -56
- package/lib/PackagerRunner.js +0 -525
- package/lib/ReporterRunner.js +0 -151
- package/lib/RequestTracker.js +0 -1178
- package/lib/SymbolPropagation.js +0 -618
- package/lib/TargetDescriptor.schema.js +0 -118
- package/lib/Transformation.js +0 -522
- package/lib/UncommittedAsset.js +0 -348
- package/lib/Validation.js +0 -203
- package/lib/applyRuntimes.js +0 -355
- package/lib/assetUtils.js +0 -205
- package/lib/atlaspack-v3/AtlaspackV3.js +0 -57
- package/lib/atlaspack-v3/NapiWorkerPool.js +0 -71
- package/lib/atlaspack-v3/fs.js +0 -39
- package/lib/atlaspack-v3/index.js +0 -26
- package/lib/atlaspack-v3/jsCallable.js +0 -20
- package/lib/atlaspack-v3/worker/compat/asset-symbols.js +0 -197
- package/lib/atlaspack-v3/worker/compat/bitflags.js +0 -84
- package/lib/atlaspack-v3/worker/compat/dependency.js +0 -44
- package/lib/atlaspack-v3/worker/compat/environment.js +0 -57
- package/lib/atlaspack-v3/worker/compat/index.js +0 -104
- package/lib/atlaspack-v3/worker/compat/mutable-asset.js +0 -164
- package/lib/atlaspack-v3/worker/compat/plugin-config.js +0 -78
- package/lib/atlaspack-v3/worker/compat/plugin-logger.js +0 -29
- package/lib/atlaspack-v3/worker/compat/plugin-options.js +0 -113
- package/lib/atlaspack-v3/worker/compat/plugin-tracer.js +0 -12
- package/lib/atlaspack-v3/worker/compat/target.js +0 -17
- package/lib/atlaspack-v3/worker/index.js +0 -3
- package/lib/atlaspack-v3/worker/worker.js +0 -280
- package/lib/constants.js +0 -21
- package/lib/dumpGraphToGraphViz.js +0 -206
- package/lib/index.js +0 -70
- package/lib/loadAtlaspackPlugin.js +0 -136
- package/lib/loadDotEnv.js +0 -54
- package/lib/projectPath.js +0 -94
- package/lib/public/Asset.js +0 -259
- package/lib/public/Bundle.js +0 -236
- package/lib/public/BundleGraph.js +0 -279
- package/lib/public/BundleGroup.js +0 -50
- package/lib/public/Config.js +0 -202
- package/lib/public/Dependency.js +0 -131
- package/lib/public/Environment.js +0 -247
- package/lib/public/MutableBundleGraph.js +0 -204
- package/lib/public/PluginOptions.js +0 -71
- package/lib/public/Symbols.js +0 -247
- package/lib/public/Target.js +0 -64
- package/lib/registerCoreWithSerializer.js +0 -51
- package/lib/requests/AssetGraphRequest.js +0 -432
- package/lib/requests/AssetGraphRequestRust.js +0 -220
- package/lib/requests/AssetRequest.js +0 -132
- package/lib/requests/AtlaspackBuildRequest.js +0 -79
- package/lib/requests/AtlaspackConfigRequest.js +0 -479
- package/lib/requests/BundleGraphRequest.js +0 -485
- package/lib/requests/ConfigRequest.js +0 -203
- package/lib/requests/DevDepRequest.js +0 -193
- package/lib/requests/EntryRequest.js +0 -295
- package/lib/requests/PackageRequest.js +0 -88
- package/lib/requests/PathRequest.js +0 -357
- package/lib/requests/TargetRequest.js +0 -1179
- package/lib/requests/ValidationRequest.js +0 -66
- package/lib/requests/WriteBundleRequest.js +0 -252
- package/lib/requests/WriteBundlesRequest.js +0 -153
- package/lib/requests/asset-graph-diff.js +0 -128
- package/lib/requests/asset-graph-dot.js +0 -131
- package/lib/resolveOptions.js +0 -265
- package/lib/serializerCore.browser.js +0 -29
- package/lib/summarizeRequest.js +0 -55
- package/lib/types.js +0 -35
- package/lib/utils.js +0 -160
- package/lib/worker.js +0 -184
package/lib/CommittedAsset.js
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
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 _buildCache() {
|
|
15
|
-
const data = require("@atlaspack/build-cache");
|
|
16
|
-
_buildCache = 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
|
-
function _sourceMap() {
|
|
29
|
-
const data = _interopRequireDefault(require("@parcel/source-map"));
|
|
30
|
-
_sourceMap = function () {
|
|
31
|
-
return data;
|
|
32
|
-
};
|
|
33
|
-
return data;
|
|
34
|
-
}
|
|
35
|
-
var _assetUtils = require("./assetUtils");
|
|
36
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
37
|
-
class CommittedAsset {
|
|
38
|
-
constructor(value, options) {
|
|
39
|
-
this.value = value;
|
|
40
|
-
this.key = this.value.contentKey;
|
|
41
|
-
this.options = options;
|
|
42
|
-
}
|
|
43
|
-
getContent() {
|
|
44
|
-
if (this.content == null) {
|
|
45
|
-
if (this.key != null) {
|
|
46
|
-
if (this.value.isLargeBlob) {
|
|
47
|
-
return this.options.cache.getStream(this.key);
|
|
48
|
-
} else {
|
|
49
|
-
return this.options.cache.getBlob(this.key);
|
|
50
|
-
}
|
|
51
|
-
} else if (this.value.astKey != null) {
|
|
52
|
-
return (0, _utils().streamFromPromise)((0, _assetUtils.generateFromAST)(this).then(({
|
|
53
|
-
content
|
|
54
|
-
}) => {
|
|
55
|
-
if (!(content instanceof _stream().Readable)) {
|
|
56
|
-
this.content = Promise.resolve(content);
|
|
57
|
-
}
|
|
58
|
-
return content;
|
|
59
|
-
}));
|
|
60
|
-
} else {
|
|
61
|
-
throw new Error('Asset has no content');
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return this.content;
|
|
65
|
-
}
|
|
66
|
-
async getCode() {
|
|
67
|
-
let content;
|
|
68
|
-
if (this.content == null && this.key != null) {
|
|
69
|
-
this.content = this.options.cache.getBlob(this.key);
|
|
70
|
-
content = await this.content;
|
|
71
|
-
} else {
|
|
72
|
-
content = await this.getContent();
|
|
73
|
-
}
|
|
74
|
-
if (typeof content === 'string' || content instanceof Buffer) {
|
|
75
|
-
return content.toString();
|
|
76
|
-
} else if (content != null) {
|
|
77
|
-
this.content = (0, _utils().bufferStream)(content);
|
|
78
|
-
return (await this.content).toString();
|
|
79
|
-
}
|
|
80
|
-
return '';
|
|
81
|
-
}
|
|
82
|
-
async getBuffer() {
|
|
83
|
-
let content = await this.getContent();
|
|
84
|
-
if (content == null) {
|
|
85
|
-
return Buffer.alloc(0);
|
|
86
|
-
} else if (typeof content === 'string' || content instanceof Buffer) {
|
|
87
|
-
return Buffer.from(content);
|
|
88
|
-
}
|
|
89
|
-
this.content = (0, _utils().bufferStream)(content);
|
|
90
|
-
return this.content;
|
|
91
|
-
}
|
|
92
|
-
getStream() {
|
|
93
|
-
let content = this.getContent();
|
|
94
|
-
return content instanceof Promise ? (0, _utils().streamFromPromise)(content) : (0, _utils().blobToStream)(content);
|
|
95
|
-
}
|
|
96
|
-
getMapBuffer() {
|
|
97
|
-
let mapKey = this.value.mapKey;
|
|
98
|
-
if (mapKey != null && this.mapBuffer == null) {
|
|
99
|
-
this.mapBuffer = (async () => {
|
|
100
|
-
try {
|
|
101
|
-
// Handle v3 assets that were processed by the native asset graph code (i.e. not runtime
|
|
102
|
-
// or helper assets)
|
|
103
|
-
if (this.options.featureFlags.atlaspackV3 && this.value.meta.isV3 === true) {
|
|
104
|
-
let buffer = await this.options.cache.getBuffer(mapKey);
|
|
105
|
-
if (!buffer) {
|
|
106
|
-
return buffer;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// We make the conversion from json to buffer here, since both js packagers lazily
|
|
110
|
-
// instantiate a sourcemap from the map buffer. This ensures we do not have to modify
|
|
111
|
-
// the packagers in any significant way. Additionally, storing the SourceMap objects
|
|
112
|
-
// upfront in these packagers appears to make larger builds more prone to failing.
|
|
113
|
-
let sourceMap = new (_sourceMap().default)(this.options.projectRoot);
|
|
114
|
-
sourceMap.addVLQMap(JSON.parse(buffer.toString()));
|
|
115
|
-
return sourceMap.toBuffer();
|
|
116
|
-
}
|
|
117
|
-
return await this.options.cache.getBlob(mapKey);
|
|
118
|
-
} catch (err) {
|
|
119
|
-
if (err.code === 'ENOENT' && this.value.astKey != null) {
|
|
120
|
-
var _await$generateFromAS;
|
|
121
|
-
return (_await$generateFromAS = (await (0, _assetUtils.generateFromAST)(this)).map) === null || _await$generateFromAS === void 0 ? void 0 : _await$generateFromAS.toBuffer();
|
|
122
|
-
} else {
|
|
123
|
-
throw err;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
})();
|
|
127
|
-
}
|
|
128
|
-
return this.mapBuffer ?? Promise.resolve();
|
|
129
|
-
}
|
|
130
|
-
getMap() {
|
|
131
|
-
if (this.map == null) {
|
|
132
|
-
this.map = (async () => {
|
|
133
|
-
let mapBuffer = await this.getMapBuffer();
|
|
134
|
-
if (mapBuffer) {
|
|
135
|
-
// Get sourcemap from flatbuffer
|
|
136
|
-
return new (_sourceMap().default)(this.options.projectRoot, mapBuffer);
|
|
137
|
-
}
|
|
138
|
-
})();
|
|
139
|
-
}
|
|
140
|
-
return this.map;
|
|
141
|
-
}
|
|
142
|
-
getAST() {
|
|
143
|
-
if (this.value.astKey == null) {
|
|
144
|
-
return Promise.resolve(null);
|
|
145
|
-
}
|
|
146
|
-
if (this.ast == null) {
|
|
147
|
-
this.ast = this.options.cache.getBlob(this.value.astKey).then(serializedAst => (0, _buildCache().deserializeRaw)(serializedAst));
|
|
148
|
-
}
|
|
149
|
-
return this.ast;
|
|
150
|
-
}
|
|
151
|
-
getDependencies() {
|
|
152
|
-
return Array.from(this.value.dependencies.values());
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
exports.default = CommittedAsset;
|
package/lib/Dependency.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createDependency = createDependency;
|
|
7
|
-
exports.createDependencyId = createDependencyId;
|
|
8
|
-
exports.mergeDependencies = mergeDependencies;
|
|
9
|
-
function _rust() {
|
|
10
|
-
const data = require("@atlaspack/rust");
|
|
11
|
-
_rust = function () {
|
|
12
|
-
return data;
|
|
13
|
-
};
|
|
14
|
-
return data;
|
|
15
|
-
}
|
|
16
|
-
var _types = require("./types");
|
|
17
|
-
var _utils = require("./utils");
|
|
18
|
-
var _projectPath = require("./projectPath");
|
|
19
|
-
function _assert() {
|
|
20
|
-
const data = _interopRequireDefault(require("assert"));
|
|
21
|
-
_assert = function () {
|
|
22
|
-
return data;
|
|
23
|
-
};
|
|
24
|
-
return data;
|
|
25
|
-
}
|
|
26
|
-
var _IdentifierRegistry = require("./IdentifierRegistry");
|
|
27
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
28
|
-
function createDependencyId({
|
|
29
|
-
sourceAssetId,
|
|
30
|
-
specifier,
|
|
31
|
-
env,
|
|
32
|
-
target,
|
|
33
|
-
pipeline,
|
|
34
|
-
specifierType,
|
|
35
|
-
bundleBehavior,
|
|
36
|
-
priority,
|
|
37
|
-
packageConditions
|
|
38
|
-
}) {
|
|
39
|
-
(0, _assert().default)(typeof specifierType === 'string');
|
|
40
|
-
(0, _assert().default)(typeof priority === 'string' || priority == null);
|
|
41
|
-
const params = {
|
|
42
|
-
sourceAssetId,
|
|
43
|
-
specifier,
|
|
44
|
-
environmentId: env.id,
|
|
45
|
-
target,
|
|
46
|
-
pipeline,
|
|
47
|
-
specifierType: _types.SpecifierType[specifierType],
|
|
48
|
-
bundleBehavior,
|
|
49
|
-
priority: priority ? _types.Priority[priority] : _types.Priority.sync,
|
|
50
|
-
packageConditions
|
|
51
|
-
};
|
|
52
|
-
const id = (0, _rust().createDependencyId)(params);
|
|
53
|
-
_IdentifierRegistry.identifierRegistry.addIdentifier('dependency', id, params);
|
|
54
|
-
return id;
|
|
55
|
-
}
|
|
56
|
-
function createDependency(projectRoot, opts) {
|
|
57
|
-
let id = opts.id || createDependencyId({
|
|
58
|
-
bundleBehavior: opts.bundleBehavior,
|
|
59
|
-
env: opts.env,
|
|
60
|
-
packageConditions: opts.packageConditions,
|
|
61
|
-
pipeline: opts.pipeline,
|
|
62
|
-
priority: opts.priority,
|
|
63
|
-
sourceAssetId: opts.sourceAssetId,
|
|
64
|
-
specifier: opts.specifier,
|
|
65
|
-
specifierType: opts.specifierType,
|
|
66
|
-
target: opts.target
|
|
67
|
-
});
|
|
68
|
-
let dep = {
|
|
69
|
-
id,
|
|
70
|
-
specifier: opts.specifier,
|
|
71
|
-
specifierType: _types.SpecifierType[opts.specifierType],
|
|
72
|
-
priority: _types.Priority[opts.priority ?? 'sync'],
|
|
73
|
-
needsStableName: opts.needsStableName ?? false,
|
|
74
|
-
bundleBehavior: opts.bundleBehavior ? _types.BundleBehavior[opts.bundleBehavior] : null,
|
|
75
|
-
isEntry: opts.isEntry ?? false,
|
|
76
|
-
isOptional: opts.isOptional ?? false,
|
|
77
|
-
loc: (0, _utils.toInternalSourceLocation)(projectRoot, opts.loc),
|
|
78
|
-
env: opts.env,
|
|
79
|
-
meta: opts.meta || {},
|
|
80
|
-
target: opts.target,
|
|
81
|
-
sourceAssetId: opts.sourceAssetId,
|
|
82
|
-
sourcePath: (0, _projectPath.toProjectPath)(projectRoot, opts.sourcePath),
|
|
83
|
-
resolveFrom: (0, _projectPath.toProjectPath)(projectRoot, opts.resolveFrom),
|
|
84
|
-
range: opts.range,
|
|
85
|
-
symbols: opts.symbols && new Map([...opts.symbols].map(([k, v]) => [k, {
|
|
86
|
-
local: v.local,
|
|
87
|
-
meta: v.meta,
|
|
88
|
-
isWeak: v.isWeak,
|
|
89
|
-
loc: (0, _utils.toInternalSourceLocation)(projectRoot, v.loc)
|
|
90
|
-
}])),
|
|
91
|
-
pipeline: opts.pipeline
|
|
92
|
-
};
|
|
93
|
-
if (opts.packageConditions) {
|
|
94
|
-
convertConditions(opts.packageConditions, dep);
|
|
95
|
-
}
|
|
96
|
-
return dep;
|
|
97
|
-
}
|
|
98
|
-
function mergeDependencies(a, b) {
|
|
99
|
-
let {
|
|
100
|
-
meta,
|
|
101
|
-
symbols,
|
|
102
|
-
needsStableName,
|
|
103
|
-
isEntry,
|
|
104
|
-
isOptional,
|
|
105
|
-
...other
|
|
106
|
-
} = b;
|
|
107
|
-
Object.assign(a, other);
|
|
108
|
-
Object.assign(a.meta, meta);
|
|
109
|
-
if (a.symbols && symbols) {
|
|
110
|
-
for (let [k, v] of symbols) {
|
|
111
|
-
a.symbols.set(k, v);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
if (needsStableName) a.needsStableName = true;
|
|
115
|
-
if (isEntry) a.isEntry = true;
|
|
116
|
-
if (!isOptional) a.isOptional = false;
|
|
117
|
-
}
|
|
118
|
-
function convertConditions(conditions, dep) {
|
|
119
|
-
// Store common package conditions as bit flags to reduce size.
|
|
120
|
-
// Custom conditions are stored as strings.
|
|
121
|
-
let packageConditions = 0;
|
|
122
|
-
let customConditions = [];
|
|
123
|
-
for (let condition of conditions) {
|
|
124
|
-
if (_types.ExportsCondition[condition]) {
|
|
125
|
-
packageConditions |= _types.ExportsCondition[condition];
|
|
126
|
-
} else {
|
|
127
|
-
customConditions.push(condition);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
if (packageConditions) {
|
|
131
|
-
dep.packageConditions = packageConditions;
|
|
132
|
-
}
|
|
133
|
-
if (customConditions.length) {
|
|
134
|
-
dep.customPackageConditions = customConditions;
|
|
135
|
-
}
|
|
136
|
-
}
|
package/lib/Environment.js
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
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
|
-
var _IdentifierRegistry = require("./IdentifierRegistry");
|
|
18
|
-
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); }
|
|
19
|
-
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; }
|
|
20
|
-
const DEFAULT_ENGINES = {
|
|
21
|
-
browsers: ['> 0.25%'],
|
|
22
|
-
node: '>= 8.0.0'
|
|
23
|
-
};
|
|
24
|
-
function createEnvironment({
|
|
25
|
-
context,
|
|
26
|
-
engines,
|
|
27
|
-
includeNodeModules,
|
|
28
|
-
outputFormat,
|
|
29
|
-
sourceType = 'module',
|
|
30
|
-
shouldOptimize = false,
|
|
31
|
-
isLibrary = false,
|
|
32
|
-
shouldScopeHoist = false,
|
|
33
|
-
sourceMap,
|
|
34
|
-
unstableSingleFileOutput = false,
|
|
35
|
-
loc
|
|
36
|
-
} = {
|
|
37
|
-
/*::...null*/
|
|
38
|
-
}) {
|
|
39
|
-
if (context == null) {
|
|
40
|
-
var _engines, _engines2;
|
|
41
|
-
if ((_engines = engines) !== null && _engines !== void 0 && _engines.node) {
|
|
42
|
-
context = 'node';
|
|
43
|
-
} else if ((_engines2 = engines) !== null && _engines2 !== void 0 && _engines2.browsers) {
|
|
44
|
-
context = 'browser';
|
|
45
|
-
} else {
|
|
46
|
-
context = 'browser';
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (engines == null) {
|
|
50
|
-
switch (context) {
|
|
51
|
-
case 'node':
|
|
52
|
-
case 'electron-main':
|
|
53
|
-
engines = {
|
|
54
|
-
node: DEFAULT_ENGINES.node
|
|
55
|
-
};
|
|
56
|
-
break;
|
|
57
|
-
case 'browser':
|
|
58
|
-
case 'web-worker':
|
|
59
|
-
case 'service-worker':
|
|
60
|
-
case 'electron-renderer':
|
|
61
|
-
engines = {
|
|
62
|
-
browsers: DEFAULT_ENGINES.browsers
|
|
63
|
-
};
|
|
64
|
-
break;
|
|
65
|
-
default:
|
|
66
|
-
engines = {};
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
if (includeNodeModules == null) {
|
|
70
|
-
switch (context) {
|
|
71
|
-
case 'node':
|
|
72
|
-
case 'electron-main':
|
|
73
|
-
case 'electron-renderer':
|
|
74
|
-
includeNodeModules = false;
|
|
75
|
-
break;
|
|
76
|
-
case 'browser':
|
|
77
|
-
case 'web-worker':
|
|
78
|
-
case 'service-worker':
|
|
79
|
-
default:
|
|
80
|
-
includeNodeModules = true;
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
if (outputFormat == null) {
|
|
85
|
-
switch (context) {
|
|
86
|
-
case 'node':
|
|
87
|
-
case 'electron-main':
|
|
88
|
-
case 'electron-renderer':
|
|
89
|
-
outputFormat = 'commonjs';
|
|
90
|
-
break;
|
|
91
|
-
default:
|
|
92
|
-
outputFormat = 'global';
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
let res = {
|
|
97
|
-
id: '',
|
|
98
|
-
context,
|
|
99
|
-
engines,
|
|
100
|
-
includeNodeModules,
|
|
101
|
-
outputFormat,
|
|
102
|
-
sourceType,
|
|
103
|
-
isLibrary,
|
|
104
|
-
shouldOptimize,
|
|
105
|
-
shouldScopeHoist,
|
|
106
|
-
sourceMap,
|
|
107
|
-
unstableSingleFileOutput,
|
|
108
|
-
loc
|
|
109
|
-
};
|
|
110
|
-
res.id = getEnvironmentHash(res);
|
|
111
|
-
return Object.freeze(res);
|
|
112
|
-
}
|
|
113
|
-
function mergeEnvironments(projectRoot, a, b) {
|
|
114
|
-
// If merging the same object, avoid copying.
|
|
115
|
-
if (a === b || !b) {
|
|
116
|
-
return a;
|
|
117
|
-
}
|
|
118
|
-
if (b instanceof _Environment.default) {
|
|
119
|
-
return (0, _Environment.environmentToInternalEnvironment)(b);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// $FlowFixMe - ignore the `id` that is already on a
|
|
123
|
-
return createEnvironment({
|
|
124
|
-
...a,
|
|
125
|
-
...b,
|
|
126
|
-
loc: b.loc ? (0, _utils.toInternalSourceLocation)(projectRoot, b.loc) : a.loc
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
function getEnvironmentHash(env) {
|
|
130
|
-
const data = {
|
|
131
|
-
context: env.context,
|
|
132
|
-
engines: env.engines,
|
|
133
|
-
includeNodeModules: env.includeNodeModules,
|
|
134
|
-
outputFormat: env.outputFormat,
|
|
135
|
-
sourceType: env.sourceType,
|
|
136
|
-
isLibrary: env.isLibrary,
|
|
137
|
-
shouldOptimize: env.shouldOptimize,
|
|
138
|
-
shouldScopeHoist: env.shouldScopeHoist,
|
|
139
|
-
sourceMap: env.sourceMap
|
|
140
|
-
};
|
|
141
|
-
const id = (0, _rust().createEnvironmentId)(data);
|
|
142
|
-
_IdentifierRegistry.identifierRegistry.addIdentifier('environment', id, data);
|
|
143
|
-
return id;
|
|
144
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.identifierRegistry = exports.IdentifierRegistry = void 0;
|
|
7
|
-
function _fs() {
|
|
8
|
-
const data = _interopRequireDefault(require("fs"));
|
|
9
|
-
_fs = function () {
|
|
10
|
-
return data;
|
|
11
|
-
};
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
class IdentifierRegistry {
|
|
16
|
-
#enabled;
|
|
17
|
-
#createdDirectory = false;
|
|
18
|
-
constructor(enabled) {
|
|
19
|
-
this.#enabled = enabled;
|
|
20
|
-
}
|
|
21
|
-
addIdentifier(type, identifier, data) {
|
|
22
|
-
if (this.#enabled) {
|
|
23
|
-
if (!this.#createdDirectory) {
|
|
24
|
-
_fs().default.mkdirSync('./.atlaspack', {
|
|
25
|
-
recursive: true
|
|
26
|
-
});
|
|
27
|
-
this.#createdDirectory = true;
|
|
28
|
-
}
|
|
29
|
-
_fs().default.appendFile('./.atlaspack/atlaspack-identifiers.txt',
|
|
30
|
-
// $FlowFixMe
|
|
31
|
-
`${type} ${identifier} ${JSON.stringify(data)}\n`, () => {});
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.IdentifierRegistry = IdentifierRegistry;
|
|
36
|
-
const identifierRegistry = exports.identifierRegistry = new IdentifierRegistry(process.env.ATLASPACK_IDENTIFIER_DEBUG === 'true');
|
package/lib/InternalConfig.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
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
|
-
var _IdentifierRegistry = require("./IdentifierRegistry");
|
|
17
|
-
function createConfig({
|
|
18
|
-
plugin,
|
|
19
|
-
isSource,
|
|
20
|
-
searchPath,
|
|
21
|
-
env,
|
|
22
|
-
result,
|
|
23
|
-
invalidateOnFileChange,
|
|
24
|
-
invalidateOnConfigKeyChange,
|
|
25
|
-
invalidateOnFileCreate,
|
|
26
|
-
invalidateOnEnvChange,
|
|
27
|
-
invalidateOnOptionChange,
|
|
28
|
-
devDeps,
|
|
29
|
-
invalidateOnStartup,
|
|
30
|
-
invalidateOnBuild
|
|
31
|
-
}) {
|
|
32
|
-
let environment = env ?? (0, _Environment.createEnvironment)();
|
|
33
|
-
const configId = (0, _rust().hashString)(plugin + (0, _projectPath.fromProjectPathRelative)(searchPath) + environment.id + String(isSource));
|
|
34
|
-
_IdentifierRegistry.identifierRegistry.addIdentifier('config_request', configId, {
|
|
35
|
-
plugin,
|
|
36
|
-
searchPath,
|
|
37
|
-
environmentId: environment.id,
|
|
38
|
-
isSource
|
|
39
|
-
});
|
|
40
|
-
return {
|
|
41
|
-
id: configId,
|
|
42
|
-
isSource: isSource ?? false,
|
|
43
|
-
searchPath,
|
|
44
|
-
env: environment,
|
|
45
|
-
result: result ?? null,
|
|
46
|
-
cacheKey: null,
|
|
47
|
-
invalidateOnFileChange: invalidateOnFileChange ?? new Set(),
|
|
48
|
-
invalidateOnConfigKeyChange: invalidateOnConfigKeyChange ?? [],
|
|
49
|
-
invalidateOnFileCreate: invalidateOnFileCreate ?? [],
|
|
50
|
-
invalidateOnEnvChange: invalidateOnEnvChange ?? new Set(),
|
|
51
|
-
invalidateOnOptionChange: invalidateOnOptionChange ?? new Set(),
|
|
52
|
-
devDeps: devDeps ?? [],
|
|
53
|
-
invalidateOnStartup: invalidateOnStartup ?? false,
|
|
54
|
-
invalidateOnBuild: invalidateOnBuild ?? false
|
|
55
|
-
};
|
|
56
|
-
}
|