@atlaspack/core 2.12.1-canary.3426 → 2.12.1-canary.3428
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/lib/AssetGraph.js +1 -2
- package/lib/Atlaspack.js +1 -1
- package/lib/Dependency.js +46 -1
- package/lib/Environment.js +12 -2
- package/lib/Transformation.js +1 -15
- package/lib/UncommittedAsset.js +4 -4
- package/lib/Validation.js +1 -13
- package/lib/assetUtils.js +9 -3
- package/lib/atlaspack-v3/worker/worker.js +84 -8
- package/lib/requests/AssetGraphRequestRust.js +26 -13
- package/lib/requests/BundleGraphRequest.js +19 -0
- package/lib/requests/asset-graph-diff.js +128 -0
- package/package.json +18 -16
- package/src/AssetGraph.js +1 -1
- package/src/Atlaspack.js +2 -2
- package/src/CommittedAsset.js +1 -1
- package/src/Dependency.js +50 -12
- package/src/Environment.js +13 -15
- package/src/Transformation.js +1 -9
- package/src/UncommittedAsset.js +6 -6
- package/src/Validation.js +1 -7
- package/src/assetUtils.js +12 -19
- package/src/atlaspack-v3/jsCallable.js +4 -0
- package/src/atlaspack-v3/worker/worker.js +125 -7
- package/src/requests/AssetGraphRequestRust.js +26 -11
- package/src/requests/BundleGraphRequest.js +18 -0
- package/src/requests/asset-graph-diff.js +145 -0
- package/test/AssetGraph.test.js +23 -9
- package/test/BundleGraph.test.js +8 -3
- package/test/Dependency.test.js +21 -0
- package/test/Environment.test.js +16 -5
- package/test/InternalAsset.test.js +8 -2
- package/test/PublicAsset.test.js +6 -2
- package/test/PublicMutableBundleGraph.test.js +9 -4
- package/test/SymbolPropagation.test.js +1 -0
- package/test/TargetRequest.test.js +25 -25
package/lib/AssetGraph.js
CHANGED
|
@@ -189,8 +189,7 @@ class AssetGraph extends _graph().ContentGraph {
|
|
|
189
189
|
// The passed project path is ignored in this case, because there is no `loc`
|
|
190
190
|
(0, _Dependency.createDependency)('', {
|
|
191
191
|
specifier: (0, _projectPath.fromProjectPathRelative)(entry.filePath),
|
|
192
|
-
specifierType: '
|
|
193
|
-
// ???
|
|
192
|
+
specifierType: 'url',
|
|
194
193
|
pipeline: target.pipeline,
|
|
195
194
|
target: target,
|
|
196
195
|
env: target.env,
|
package/lib/Atlaspack.js
CHANGED
|
@@ -192,11 +192,11 @@ class Atlaspack {
|
|
|
192
192
|
}
|
|
193
193
|
});
|
|
194
194
|
}
|
|
195
|
+
(0, _featureFlags().setFeatureFlags)(resolvedOptions.featureFlags);
|
|
195
196
|
let {
|
|
196
197
|
config
|
|
197
198
|
} = await (0, _AtlaspackConfigRequest.loadAtlaspackConfig)(resolvedOptions);
|
|
198
199
|
this.#config = new _AtlaspackConfig.default(config, resolvedOptions);
|
|
199
|
-
(0, _featureFlags().setFeatureFlags)(resolvedOptions.featureFlags);
|
|
200
200
|
if (this.#initialOptions.workerFarm) {
|
|
201
201
|
if (this.#initialOptions.workerFarm.ending) {
|
|
202
202
|
throw new Error('Supplied WorkerFarm is ending');
|
package/lib/Dependency.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createDependency = createDependency;
|
|
7
|
+
exports.createDependencyId = createDependencyId;
|
|
7
8
|
exports.mergeDependencies = mergeDependencies;
|
|
8
9
|
function _rust() {
|
|
9
10
|
const data = require("@atlaspack/rust");
|
|
@@ -15,8 +16,52 @@ function _rust() {
|
|
|
15
16
|
var _types = require("./types");
|
|
16
17
|
var _utils = require("./utils");
|
|
17
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
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
+
function createDependencyId({
|
|
28
|
+
sourceAssetId,
|
|
29
|
+
specifier,
|
|
30
|
+
env,
|
|
31
|
+
target,
|
|
32
|
+
pipeline,
|
|
33
|
+
specifierType,
|
|
34
|
+
bundleBehavior,
|
|
35
|
+
priority,
|
|
36
|
+
packageConditions
|
|
37
|
+
}) {
|
|
38
|
+
(0, _assert().default)(typeof specifierType === 'string');
|
|
39
|
+
(0, _assert().default)(typeof priority === 'string' || priority == null);
|
|
40
|
+
const params = {
|
|
41
|
+
sourceAssetId,
|
|
42
|
+
specifier,
|
|
43
|
+
env,
|
|
44
|
+
target,
|
|
45
|
+
pipeline,
|
|
46
|
+
specifierType: _types.SpecifierType[specifierType],
|
|
47
|
+
bundleBehavior,
|
|
48
|
+
priority: priority ? _types.Priority[priority] : _types.Priority.sync,
|
|
49
|
+
packageConditions
|
|
50
|
+
};
|
|
51
|
+
return (0, _rust().createDependencyId)(params);
|
|
52
|
+
}
|
|
18
53
|
function createDependency(projectRoot, opts) {
|
|
19
|
-
let id = opts.id || (
|
|
54
|
+
let id = opts.id || createDependencyId({
|
|
55
|
+
bundleBehavior: opts.bundleBehavior,
|
|
56
|
+
env: opts.env,
|
|
57
|
+
packageConditions: opts.packageConditions,
|
|
58
|
+
pipeline: opts.pipeline,
|
|
59
|
+
priority: opts.priority,
|
|
60
|
+
sourceAssetId: opts.sourceAssetId,
|
|
61
|
+
specifier: opts.specifier,
|
|
62
|
+
specifierType: opts.specifierType,
|
|
63
|
+
target: opts.target
|
|
64
|
+
});
|
|
20
65
|
let dep = {
|
|
21
66
|
id,
|
|
22
67
|
specifier: opts.specifier,
|
package/lib/Environment.js
CHANGED
|
@@ -105,7 +105,7 @@ function createEnvironment({
|
|
|
105
105
|
loc
|
|
106
106
|
};
|
|
107
107
|
res.id = getEnvironmentHash(res);
|
|
108
|
-
return res;
|
|
108
|
+
return Object.freeze(res);
|
|
109
109
|
}
|
|
110
110
|
function mergeEnvironments(projectRoot, a, b) {
|
|
111
111
|
// If merging the same object, avoid copying.
|
|
@@ -124,5 +124,15 @@ function mergeEnvironments(projectRoot, a, b) {
|
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
126
|
function getEnvironmentHash(env) {
|
|
127
|
-
return (0, _rust().
|
|
127
|
+
return (0, _rust().createEnvironmentId)({
|
|
128
|
+
context: env.context,
|
|
129
|
+
engines: env.engines,
|
|
130
|
+
includeNodeModules: env.includeNodeModules,
|
|
131
|
+
outputFormat: env.outputFormat,
|
|
132
|
+
sourceType: env.sourceType,
|
|
133
|
+
isLibrary: env.isLibrary,
|
|
134
|
+
shouldOptimize: env.shouldOptimize,
|
|
135
|
+
shouldScopeHoist: env.shouldScopeHoist,
|
|
136
|
+
sourceMap: env.sourceMap
|
|
137
|
+
});
|
|
128
138
|
}
|
package/lib/Transformation.js
CHANGED
|
@@ -46,13 +46,6 @@ function _utils() {
|
|
|
46
46
|
};
|
|
47
47
|
return data;
|
|
48
48
|
}
|
|
49
|
-
function _rust() {
|
|
50
|
-
const data = require("@atlaspack/rust");
|
|
51
|
-
_rust = function () {
|
|
52
|
-
return data;
|
|
53
|
-
};
|
|
54
|
-
return data;
|
|
55
|
-
}
|
|
56
49
|
var _Dependency = require("./Dependency");
|
|
57
50
|
var _AtlaspackConfig = _interopRequireDefault(require("./AtlaspackConfig"));
|
|
58
51
|
var _PathRequest = require("./requests/PathRequest");
|
|
@@ -181,16 +174,9 @@ class Transformation {
|
|
|
181
174
|
|
|
182
175
|
// Prefer `isSource` originating from the AssetRequest.
|
|
183
176
|
|
|
184
|
-
// If the transformer request passed code, use a hash in addition
|
|
185
|
-
// to the filename as the base for the id to ensure it is unique.
|
|
186
|
-
let idBase = (0, _projectPath.fromProjectPathRelative)(filePath);
|
|
187
|
-
if (code != null) {
|
|
188
|
-
idBase += (0, _rust().hashString)(code);
|
|
189
|
-
}
|
|
190
177
|
return new _UncommittedAsset.default({
|
|
191
|
-
idBase,
|
|
192
178
|
value: (0, _assetUtils.createAsset)(this.options.projectRoot, {
|
|
193
|
-
|
|
179
|
+
code,
|
|
194
180
|
filePath,
|
|
195
181
|
isSource: isSourceOverride ?? summarizedIsSource,
|
|
196
182
|
type: _path().default.extname((0, _projectPath.fromProjectPathRelative)(filePath)).slice(1),
|
package/lib/UncommittedAsset.js
CHANGED
|
@@ -56,7 +56,7 @@ class UncommittedAsset {
|
|
|
56
56
|
mapBuffer,
|
|
57
57
|
ast,
|
|
58
58
|
isASTDirty,
|
|
59
|
-
|
|
59
|
+
code,
|
|
60
60
|
invalidations
|
|
61
61
|
}) {
|
|
62
62
|
this.value = value;
|
|
@@ -65,7 +65,7 @@ class UncommittedAsset {
|
|
|
65
65
|
this.mapBuffer = mapBuffer;
|
|
66
66
|
this.ast = ast;
|
|
67
67
|
this.isASTDirty = isASTDirty || false;
|
|
68
|
-
this.
|
|
68
|
+
this.code = code;
|
|
69
69
|
this.invalidations = invalidations || (0, _utils2.createInvalidations)();
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -289,7 +289,7 @@ class UncommittedAsset {
|
|
|
289
289
|
let content = result.content ?? null;
|
|
290
290
|
let asset = new UncommittedAsset({
|
|
291
291
|
value: (0, _assetUtils.createAsset)(this.options.projectRoot, {
|
|
292
|
-
|
|
292
|
+
code: this.code,
|
|
293
293
|
filePath: this.value.filePath,
|
|
294
294
|
type: result.type,
|
|
295
295
|
bundleBehavior: result.bundleBehavior ?? (this.value.bundleBehavior == null ? null : _types.BundleBehaviorNames[this.value.bundleBehavior]),
|
|
@@ -323,7 +323,7 @@ class UncommittedAsset {
|
|
|
323
323
|
ast: result.ast,
|
|
324
324
|
isASTDirty: result.ast === this.ast ? this.isASTDirty : true,
|
|
325
325
|
mapBuffer: result.map ? result.map.toBuffer() : null,
|
|
326
|
-
|
|
326
|
+
code: this.code,
|
|
327
327
|
invalidations: this.invalidations
|
|
328
328
|
});
|
|
329
329
|
let dependencies = result.dependencies;
|
package/lib/Validation.js
CHANGED
|
@@ -46,13 +46,6 @@ function _profiler() {
|
|
|
46
46
|
};
|
|
47
47
|
return data;
|
|
48
48
|
}
|
|
49
|
-
function _rust() {
|
|
50
|
-
const data = require("@atlaspack/rust");
|
|
51
|
-
_rust = function () {
|
|
52
|
-
return data;
|
|
53
|
-
};
|
|
54
|
-
return data;
|
|
55
|
-
}
|
|
56
49
|
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); }
|
|
57
50
|
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; }
|
|
58
51
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -188,14 +181,9 @@ class Validation {
|
|
|
188
181
|
} = await (0, _summarizeRequest.default)(this.options.inputFS, {
|
|
189
182
|
filePath: (0, _projectPath.fromProjectPath)(this.options.projectRoot, request.filePath)
|
|
190
183
|
});
|
|
191
|
-
|
|
192
|
-
// If the transformer request passed code rather than a filename,
|
|
193
|
-
// use a hash as the base for the id to ensure it is unique.
|
|
194
|
-
let idBase = code != null ? (0, _rust().hashString)(code) : (0, _projectPath.fromProjectPathRelative)(filePath);
|
|
195
184
|
return new _UncommittedAsset.default({
|
|
196
|
-
idBase,
|
|
197
185
|
value: (0, _assetUtils.createAsset)(this.options.projectRoot, {
|
|
198
|
-
|
|
186
|
+
code,
|
|
199
187
|
filePath: filePath,
|
|
200
188
|
isSource,
|
|
201
189
|
type: _path().default.extname((0, _projectPath.fromProjectPathRelative)(filePath)).slice(1),
|
package/lib/assetUtils.js
CHANGED
|
@@ -61,9 +61,15 @@ function _profiler() {
|
|
|
61
61
|
}
|
|
62
62
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
63
63
|
function createAssetIdFromOptions(options) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
return (0, _rust().createAssetId)({
|
|
65
|
+
env: options.env,
|
|
66
|
+
filePath: options.filePath,
|
|
67
|
+
code: options.code,
|
|
68
|
+
pipeline: options.pipeline,
|
|
69
|
+
query: options.query,
|
|
70
|
+
uniqueKey: options.uniqueKey,
|
|
71
|
+
fileType: options.type
|
|
72
|
+
});
|
|
67
73
|
}
|
|
68
74
|
function createAsset(projectRoot, options) {
|
|
69
75
|
return {
|
|
@@ -33,11 +33,82 @@ function _module() {
|
|
|
33
33
|
return data;
|
|
34
34
|
}
|
|
35
35
|
var _compat = require("./compat");
|
|
36
|
+
var _jsCallable = require("../jsCallable");
|
|
36
37
|
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); }
|
|
37
38
|
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; }
|
|
38
39
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
39
40
|
const CONFIG = Symbol.for('parcel-plugin-config');
|
|
40
41
|
class AtlaspackWorker {
|
|
42
|
+
#resolvers;
|
|
43
|
+
constructor() {
|
|
44
|
+
this.#resolvers = new Map();
|
|
45
|
+
}
|
|
46
|
+
loadPlugin = (0, _jsCallable.jsCallable)(async ({
|
|
47
|
+
kind,
|
|
48
|
+
specifier,
|
|
49
|
+
resolveFrom
|
|
50
|
+
}) => {
|
|
51
|
+
let customRequire = _module().createRequire(resolveFrom);
|
|
52
|
+
let resolvedPath = customRequire.resolve(specifier);
|
|
53
|
+
// $FlowFixMe
|
|
54
|
+
let resolvedModule = await import(resolvedPath);
|
|
55
|
+
switch (kind) {
|
|
56
|
+
case 'resolver':
|
|
57
|
+
this.#resolvers.set(specifier, resolvedModule.default[CONFIG]);
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
runResolverResolve = (0, _jsCallable.jsCallable)(async ({
|
|
62
|
+
key,
|
|
63
|
+
dependency,
|
|
64
|
+
specifier
|
|
65
|
+
}) => {
|
|
66
|
+
const resolver = this.#resolvers.get(key);
|
|
67
|
+
if (!resolver) {
|
|
68
|
+
throw new Error('Resolver not found');
|
|
69
|
+
}
|
|
70
|
+
const result = await resolver.resolve({
|
|
71
|
+
specifier,
|
|
72
|
+
dependency,
|
|
73
|
+
get options() {
|
|
74
|
+
throw new Error('TODO: Resolver.resolve.options');
|
|
75
|
+
},
|
|
76
|
+
get logger() {
|
|
77
|
+
throw new Error('TODO: Resolver.resolve.logger');
|
|
78
|
+
},
|
|
79
|
+
get tracer() {
|
|
80
|
+
throw new Error('TODO: Resolver.resolve.tracer');
|
|
81
|
+
},
|
|
82
|
+
get pipeline() {
|
|
83
|
+
throw new Error('TODO: Resolver.resolve.pipeline');
|
|
84
|
+
},
|
|
85
|
+
get config() {
|
|
86
|
+
throw new Error('TODO: Resolver.resolve.config');
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
if (!result) {
|
|
90
|
+
return {
|
|
91
|
+
invalidations: [],
|
|
92
|
+
resolution: {
|
|
93
|
+
type: 'unresolved'
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
invalidations: [],
|
|
99
|
+
resolution: {
|
|
100
|
+
type: 'resolved',
|
|
101
|
+
filePath: result.filePath || '',
|
|
102
|
+
canDefer: result.canDefer || false,
|
|
103
|
+
sideEffects: result.sideEffects || false,
|
|
104
|
+
code: result.code || undefined,
|
|
105
|
+
meta: result.meta || undefined,
|
|
106
|
+
pipeline: result.pipeline || undefined,
|
|
107
|
+
priority: result.priority && PriorityMap[result.priority],
|
|
108
|
+
query: result.query && result.query.toString()
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
});
|
|
41
112
|
ping() {
|
|
42
113
|
// console.log('Hi');
|
|
43
114
|
}
|
|
@@ -47,24 +118,24 @@ class AtlaspackWorker {
|
|
|
47
118
|
options,
|
|
48
119
|
asset
|
|
49
120
|
}) {
|
|
50
|
-
|
|
51
|
-
|
|
121
|
+
const customRequire = _module().createRequire(resolveFrom);
|
|
122
|
+
const resolvedPath = customRequire.resolve(specifier);
|
|
52
123
|
// $FlowFixMe
|
|
53
|
-
|
|
54
|
-
|
|
124
|
+
const transformerModule = await import(resolvedPath);
|
|
125
|
+
const transformer = transformerModule.default.default[CONFIG];
|
|
55
126
|
let assetCompat = new _compat.AssetCompat(asset, options);
|
|
56
127
|
try {
|
|
57
128
|
if (transformer.parse) {
|
|
58
129
|
// $FlowFixMe
|
|
59
|
-
|
|
130
|
+
const ast = await transformer.parse({
|
|
60
131
|
asset: assetCompat
|
|
61
|
-
});
|
|
132
|
+
}); // missing "config"
|
|
62
133
|
// $FlowFixMe
|
|
63
134
|
assetCompat.setAST(ast);
|
|
64
135
|
}
|
|
65
136
|
|
|
66
137
|
// $FlowFixMe
|
|
67
|
-
|
|
138
|
+
const result = await transformer.transform({
|
|
68
139
|
// $FlowFixMe
|
|
69
140
|
asset: assetCompat,
|
|
70
141
|
options,
|
|
@@ -97,4 +168,9 @@ class AtlaspackWorker {
|
|
|
97
168
|
}
|
|
98
169
|
}
|
|
99
170
|
exports.AtlaspackWorker = AtlaspackWorker;
|
|
100
|
-
napi().registerWorker(_worker_threads().workerData.tx_worker, new AtlaspackWorker());
|
|
171
|
+
napi().registerWorker(_worker_threads().workerData.tx_worker, new AtlaspackWorker());
|
|
172
|
+
const PriorityMap = {
|
|
173
|
+
sync: 0,
|
|
174
|
+
parallel: 1,
|
|
175
|
+
lazy: 2
|
|
176
|
+
};
|
|
@@ -86,13 +86,11 @@ function getAssetGraph(serializedGraph, options) {
|
|
|
86
86
|
...symbol
|
|
87
87
|
}) {
|
|
88
88
|
let jsSymbol = {
|
|
89
|
-
local: symbol.local,
|
|
90
|
-
loc: symbol.loc
|
|
89
|
+
local: symbol.local ?? undefined,
|
|
90
|
+
loc: symbol.loc ?? undefined,
|
|
91
|
+
meta: undefined,
|
|
92
|
+
isWeak: symbol.isWeak
|
|
91
93
|
};
|
|
92
|
-
if (symbol.isWeak) {
|
|
93
|
-
// $FlowFixMe
|
|
94
|
-
jsSymbol.isWeak = symbol.isWeak;
|
|
95
|
-
}
|
|
96
94
|
if (symbol.exported) {
|
|
97
95
|
// $FlowFixMe
|
|
98
96
|
jsSymbol.exported = symbol.exported;
|
|
@@ -105,11 +103,8 @@ function getAssetGraph(serializedGraph, options) {
|
|
|
105
103
|
}
|
|
106
104
|
return [exported, jsSymbol];
|
|
107
105
|
}
|
|
106
|
+
|
|
108
107
|
// See crates/atlaspack_core/src/types/environment.rs
|
|
109
|
-
let sourceTypeLookup = {
|
|
110
|
-
'0': 'module',
|
|
111
|
-
'1': 'script'
|
|
112
|
-
};
|
|
113
108
|
let cachedAssets = new Map();
|
|
114
109
|
let changedAssets = new Map();
|
|
115
110
|
let entry = 0;
|
|
@@ -144,10 +139,23 @@ function getAssetGraph(serializedGraph, options) {
|
|
|
144
139
|
asset.meta.id = id;
|
|
145
140
|
asset = {
|
|
146
141
|
...asset,
|
|
142
|
+
uniqueKey: asset.uniqueKey ?? undefined,
|
|
143
|
+
pipeline: asset.pipeline ?? undefined,
|
|
144
|
+
range: asset.range ?? undefined,
|
|
145
|
+
resolveFrom: asset.resolveFrom ?? undefined,
|
|
146
|
+
target: asset.target ?? undefined,
|
|
147
|
+
plugin: asset.plugin ?? undefined,
|
|
148
|
+
query: asset.query ?? undefined,
|
|
149
|
+
configPath: asset.configPath ?? undefined,
|
|
150
|
+
configKeyPath: asset.configKeyPath ?? undefined,
|
|
151
|
+
isLargeBlob: asset.isLargeBlob ?? false,
|
|
152
|
+
isSource: asset.isSource ?? false,
|
|
153
|
+
sourcePath: asset.sourcePath ?? undefined,
|
|
147
154
|
env: {
|
|
148
155
|
...asset.env,
|
|
156
|
+
loc: asset.env.loc ?? undefined,
|
|
149
157
|
id: getEnvId(asset.env),
|
|
150
|
-
sourceType:
|
|
158
|
+
sourceType: asset.env.sourceType
|
|
151
159
|
},
|
|
152
160
|
bundleBehavior: asset.bundleBehavior === 255 ? null : asset.bundleBehavior,
|
|
153
161
|
committed: true,
|
|
@@ -175,15 +183,20 @@ function getAssetGraph(serializedGraph, options) {
|
|
|
175
183
|
env: {
|
|
176
184
|
...dependency.env,
|
|
177
185
|
id: getEnvId(dependency.env),
|
|
178
|
-
sourceType:
|
|
186
|
+
sourceType: dependency.env.sourceType,
|
|
187
|
+
loc: dependency.env.loc ?? undefined
|
|
179
188
|
},
|
|
189
|
+
pipeline: dependency.pipeline ?? undefined,
|
|
190
|
+
range: dependency.range ?? undefined,
|
|
191
|
+
resolveFrom: dependency.resolveFrom ?? undefined,
|
|
192
|
+
target: dependency.target ?? undefined,
|
|
180
193
|
bundleBehavior: dependency.bundleBehavior === 255 ? null : dependency.bundleBehavior,
|
|
181
194
|
contentKey: id,
|
|
182
195
|
loc: dependency.loc ? {
|
|
183
196
|
...dependency.loc,
|
|
184
197
|
filePath: (0, _projectPath.toProjectPath)(options.projectRoot, dependency.loc.filePath)
|
|
185
198
|
} : undefined,
|
|
186
|
-
sourcePath: dependency.sourcePath ? (0, _projectPath.toProjectPath)(options.projectRoot, dependency.sourcePath) :
|
|
199
|
+
sourcePath: dependency.sourcePath ? (0, _projectPath.toProjectPath)(options.projectRoot, dependency.sourcePath) : undefined,
|
|
187
200
|
symbols:
|
|
188
201
|
// Dependency.symbols are always set to an empty map when scope hoisting
|
|
189
202
|
// is enabled. Some tests will fail if this is not the case. We should
|
|
@@ -109,6 +109,25 @@ function createBundleGraphRequest(input) {
|
|
|
109
109
|
} = await api.runRequest(request, {
|
|
110
110
|
force: options.shouldBuildLazily && requestedAssetIds.size > 0
|
|
111
111
|
});
|
|
112
|
+
|
|
113
|
+
// if (input.rustAtlaspack && process.env.NATIVE_COMPARE === 'true') {
|
|
114
|
+
// let {assetGraph: jsAssetGraph} = await api.runRequest(
|
|
115
|
+
// createAssetGraphRequestJS({
|
|
116
|
+
// name: 'Main',
|
|
117
|
+
// entries: options.entries,
|
|
118
|
+
// optionsRef,
|
|
119
|
+
// shouldBuildLazily: options.shouldBuildLazily,
|
|
120
|
+
// lazyIncludes: options.lazyIncludes,
|
|
121
|
+
// lazyExcludes: options.lazyExcludes,
|
|
122
|
+
// requestedAssetIds,
|
|
123
|
+
// }),
|
|
124
|
+
// {
|
|
125
|
+
// force: true,
|
|
126
|
+
// },
|
|
127
|
+
// );
|
|
128
|
+
// require('./asset-graph-diff.js')(jsAssetGraph, assetGraph);
|
|
129
|
+
// }
|
|
130
|
+
|
|
112
131
|
measurement && measurement.end();
|
|
113
132
|
(0, _utils2.assertSignalNotAborted)(signal);
|
|
114
133
|
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _default() {
|
|
4
|
+
const data = _interopRequireDefault(require("rfdc/default"));
|
|
5
|
+
_default = function () {
|
|
6
|
+
return data;
|
|
7
|
+
};
|
|
8
|
+
return data;
|
|
9
|
+
}
|
|
10
|
+
function _jestDiff() {
|
|
11
|
+
const data = require("jest-diff");
|
|
12
|
+
_jestDiff = function () {
|
|
13
|
+
return data;
|
|
14
|
+
};
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
var _AssetGraph = _interopRequireDefault(require("../AssetGraph"));
|
|
18
|
+
var _projectPath = require("../projectPath");
|
|
19
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
+
/* eslint-disable no-console */ // $FlowFixMe
|
|
21
|
+
// $FlowFixMe
|
|
22
|
+
function filterNode(node) {
|
|
23
|
+
let clone = (0, _default().default)(node);
|
|
24
|
+
|
|
25
|
+
// Clean up anything you don't want to see in the diff
|
|
26
|
+
// delete clone.id;
|
|
27
|
+
delete clone.value.id;
|
|
28
|
+
delete clone.value.meta.id;
|
|
29
|
+
delete clone.value.sourceAssetId;
|
|
30
|
+
delete clone.value.env.id;
|
|
31
|
+
delete clone.value.isEsm;
|
|
32
|
+
delete clone.value.shouldWrap;
|
|
33
|
+
delete clone.value.contentKey;
|
|
34
|
+
delete clone.value.placeholder;
|
|
35
|
+
delete clone.value.code;
|
|
36
|
+
delete clone.value.hasCjsExports;
|
|
37
|
+
delete clone.value.staticExports;
|
|
38
|
+
delete clone.value.isConstantModule;
|
|
39
|
+
delete clone.value.hasNodeReplacements;
|
|
40
|
+
delete clone.value.stats;
|
|
41
|
+
delete clone.value.astKey;
|
|
42
|
+
delete clone.value.astGenerator;
|
|
43
|
+
delete clone.value.dependencies;
|
|
44
|
+
return clone;
|
|
45
|
+
}
|
|
46
|
+
function compactDeep(obj, ignoredPatterns = [], currentPath = '$') {
|
|
47
|
+
if (obj instanceof Map) {
|
|
48
|
+
const copy = {};
|
|
49
|
+
Array.from(obj.entries()).forEach(([k, v]) => {
|
|
50
|
+
if (v != null) {
|
|
51
|
+
copy[k] = compactDeep(v, ignoredPatterns, `${currentPath}.${k}`);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return copy;
|
|
55
|
+
} else if (Array.isArray(obj)) {
|
|
56
|
+
return obj.map(v => compactDeep(v, ignoredPatterns, `${currentPath}[]`));
|
|
57
|
+
} else if (typeof obj === 'object') {
|
|
58
|
+
const copy = {};
|
|
59
|
+
Object.entries(obj ?? {}).forEach(([key, value]) => {
|
|
60
|
+
const path = `${currentPath}.${key}`;
|
|
61
|
+
if (ignoredPatterns.some(pattern => path.includes(pattern))) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
// Equivalent false == null
|
|
65
|
+
if (key === 'isWeak' && value === false) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (value != null) {
|
|
69
|
+
copy[key] = compactDeep(value, ignoredPatterns, path);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return copy;
|
|
73
|
+
} else if (obj != null) {
|
|
74
|
+
return obj;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function assetGraphDiff(jsAssetGraph, rustAssetGraph) {
|
|
78
|
+
const getNodes = graph => {
|
|
79
|
+
let nodes = {};
|
|
80
|
+
graph.traverse(nodeId => {
|
|
81
|
+
let node = graph.getNode(nodeId) ?? null;
|
|
82
|
+
if (!node) return;
|
|
83
|
+
if (node.type === 'dependency') {
|
|
84
|
+
let sourcePath = node.value.sourcePath ?? (0, _projectPath.toProjectPath)('', 'entry');
|
|
85
|
+
nodes[`dep:${(0, _projectPath.fromProjectPathRelative)(sourcePath)}:${node.value.specifier}`] = filterNode(node);
|
|
86
|
+
} else if (node.type === 'asset') {
|
|
87
|
+
nodes[`asset:${(0, _projectPath.fromProjectPathRelative)(node.value.filePath)}`] = filterNode(node);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
return nodes;
|
|
91
|
+
};
|
|
92
|
+
const jsNodes = getNodes(jsAssetGraph);
|
|
93
|
+
const rustNodes = getNodes(rustAssetGraph);
|
|
94
|
+
const all = new Set([...Object.keys(jsNodes), ...Object.keys(rustNodes)]);
|
|
95
|
+
const missing = [];
|
|
96
|
+
const extra = [];
|
|
97
|
+
for (const key of all.keys()) {
|
|
98
|
+
if (process.env.NATIVE_COMPARE !== 'true') {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
let jsNode = jsNodes[key];
|
|
102
|
+
let rustNode = rustNodes[key];
|
|
103
|
+
if (!rustNode) {
|
|
104
|
+
missing.push(key);
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (!jsNode) {
|
|
108
|
+
extra.push(key);
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
console.log(key);
|
|
112
|
+
const ignoredPatterns = [
|
|
113
|
+
// ignored because we don't copy the environment ID back from rust
|
|
114
|
+
// in the target value
|
|
115
|
+
'$.value.target.env.id',
|
|
116
|
+
// ignore asset.mapKey because we don't do persistence on rust yet
|
|
117
|
+
'$.value.mapKey',
|
|
118
|
+
// ignore this because it's just the output hash. We don't need to compute
|
|
119
|
+
// this yet
|
|
120
|
+
'$.value.outputHash',
|
|
121
|
+
// ignore correspondingRequest from all nodes
|
|
122
|
+
'$.correspondingRequest'];
|
|
123
|
+
console.log((0, _jestDiff().diff)(compactDeep(rustNode, ignoredPatterns), compactDeep(jsNode, ignoredPatterns)));
|
|
124
|
+
}
|
|
125
|
+
console.log('Missing', missing);
|
|
126
|
+
console.log('Extra', extra);
|
|
127
|
+
}
|
|
128
|
+
module.exports = assetGraphDiff;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/core",
|
|
3
|
-
"version": "2.12.1-canary.
|
|
3
|
+
"version": "2.12.1-canary.3428+a36723bdd",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -20,20 +20,20 @@
|
|
|
20
20
|
"check-ts": "tsc --noEmit index.d.ts"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@atlaspack/cache": "2.12.1-canary.
|
|
24
|
-
"@atlaspack/diagnostic": "2.12.1-canary.
|
|
25
|
-
"@atlaspack/events": "2.12.1-canary.
|
|
26
|
-
"@atlaspack/feature-flags": "2.12.1-canary.
|
|
27
|
-
"@atlaspack/fs": "2.12.1-canary.
|
|
28
|
-
"@atlaspack/graph": "3.2.1-canary.
|
|
29
|
-
"@atlaspack/logger": "2.12.1-canary.
|
|
30
|
-
"@atlaspack/package-manager": "2.12.1-canary.
|
|
31
|
-
"@atlaspack/plugin": "2.12.1-canary.
|
|
32
|
-
"@atlaspack/profiler": "2.12.1-canary.
|
|
33
|
-
"@atlaspack/rust": "2.12.1-canary.
|
|
34
|
-
"@atlaspack/types": "2.12.1-canary.
|
|
35
|
-
"@atlaspack/utils": "2.12.1-canary.
|
|
36
|
-
"@atlaspack/workers": "2.12.1-canary.
|
|
23
|
+
"@atlaspack/cache": "2.12.1-canary.3428+a36723bdd",
|
|
24
|
+
"@atlaspack/diagnostic": "2.12.1-canary.3428+a36723bdd",
|
|
25
|
+
"@atlaspack/events": "2.12.1-canary.3428+a36723bdd",
|
|
26
|
+
"@atlaspack/feature-flags": "2.12.1-canary.3428+a36723bdd",
|
|
27
|
+
"@atlaspack/fs": "2.12.1-canary.3428+a36723bdd",
|
|
28
|
+
"@atlaspack/graph": "3.2.1-canary.3428+a36723bdd",
|
|
29
|
+
"@atlaspack/logger": "2.12.1-canary.3428+a36723bdd",
|
|
30
|
+
"@atlaspack/package-manager": "2.12.1-canary.3428+a36723bdd",
|
|
31
|
+
"@atlaspack/plugin": "2.12.1-canary.3428+a36723bdd",
|
|
32
|
+
"@atlaspack/profiler": "2.12.1-canary.3428+a36723bdd",
|
|
33
|
+
"@atlaspack/rust": "2.12.1-canary.3428+a36723bdd",
|
|
34
|
+
"@atlaspack/types": "2.12.1-canary.3428+a36723bdd",
|
|
35
|
+
"@atlaspack/utils": "2.12.1-canary.3428+a36723bdd",
|
|
36
|
+
"@atlaspack/workers": "2.12.1-canary.3428+a36723bdd",
|
|
37
37
|
"@mischnic/json-sourcemap": "^0.1.0",
|
|
38
38
|
"@parcel/source-map": "^2.1.1",
|
|
39
39
|
"base-x": "^3.0.8",
|
|
@@ -50,10 +50,12 @@
|
|
|
50
50
|
"@atlaspack/babel-register": "2.12.0",
|
|
51
51
|
"@types/node": ">= 18",
|
|
52
52
|
"graphviz": "^0.0.9",
|
|
53
|
+
"jest-diff": "*",
|
|
54
|
+
"rfdc": "1",
|
|
53
55
|
"tempy": "^0.2.1"
|
|
54
56
|
},
|
|
55
57
|
"browser": {
|
|
56
58
|
"./src/serializerCore.js": "./src/serializerCore.browser.js"
|
|
57
59
|
},
|
|
58
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "a36723bdd944adb8243fa61102923c6811a63001"
|
|
59
61
|
}
|
package/src/AssetGraph.js
CHANGED
|
@@ -227,7 +227,7 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
|
|
|
227
227
|
// The passed project path is ignored in this case, because there is no `loc`
|
|
228
228
|
createDependency('', {
|
|
229
229
|
specifier: fromProjectPathRelative(entry.filePath),
|
|
230
|
-
specifierType: '
|
|
230
|
+
specifierType: 'url',
|
|
231
231
|
pipeline: target.pipeline,
|
|
232
232
|
target: target,
|
|
233
233
|
env: target.env,
|
package/src/Atlaspack.js
CHANGED
|
@@ -152,11 +152,11 @@ export default class Atlaspack {
|
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
+
setFeatureFlags(resolvedOptions.featureFlags);
|
|
156
|
+
|
|
155
157
|
let {config} = await loadAtlaspackConfig(resolvedOptions);
|
|
156
158
|
this.#config = new AtlaspackConfig(config, resolvedOptions);
|
|
157
159
|
|
|
158
|
-
setFeatureFlags(resolvedOptions.featureFlags);
|
|
159
|
-
|
|
160
160
|
if (this.#initialOptions.workerFarm) {
|
|
161
161
|
if (this.#initialOptions.workerFarm.ending) {
|
|
162
162
|
throw new Error('Supplied WorkerFarm is ending');
|