@atlaspack/core 2.12.1-canary.3534 → 2.12.1-canary.3536
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/Atlaspack.js +9 -3
- package/lib/requests/AssetGraphRequestRust.js +1 -0
- package/package.json +17 -17
- package/src/Atlaspack.js +12 -3
- package/src/loadAtlaspackPlugin.js +16 -8
- package/src/requests/AssetGraphRequestRust.js +3 -0
- package/test/AtlaspackConfig.test.js +77 -24
- package/test/fixtures/local-plugin-config-pkg/node_modules/parcel-config-local/package.json +1 -4
- package/test/fixtures/plugins/node_modules/atlaspack-transformer-bad-engines/package.json +7 -0
- package/test/fixtures/plugins/node_modules/atlaspack-transformer-bad-parcel-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/plugins/node_modules/parcel-transformer-bad-engines/package.json +0 -7
- package/test/fixtures/plugins/node_modules/parcel-transformer-no-engines/package.json +0 -4
- /package/test/fixtures/plugins/node_modules/{parcel-transformer-bad-engines → atlaspack-transformer-bad-engines}/index.js +0 -0
- /package/test/fixtures/plugins/node_modules/{parcel-transformer-no-engines → atlaspack-transformer-bad-parcel-engines}/index.js +0 -0
package/lib/Atlaspack.js
CHANGED
|
@@ -563,6 +563,7 @@ class Atlaspack {
|
|
|
563
563
|
*/
|
|
564
564
|
async unstable_buildAssetGraph(writeToCache = true) {
|
|
565
565
|
await this._init();
|
|
566
|
+
const origin = '@atlaspack/core';
|
|
566
567
|
const input = {
|
|
567
568
|
optionsRef: this.#optionsRef,
|
|
568
569
|
name: 'Main',
|
|
@@ -572,19 +573,24 @@ class Atlaspack {
|
|
|
572
573
|
lazyExcludes: [],
|
|
573
574
|
requestedAssetIds: this.#requestedAssetIds
|
|
574
575
|
};
|
|
576
|
+
const start = Date.now();
|
|
575
577
|
const result = await this.#requestTracker.runRequest(this.rustAtlaspack != null ? (0, _AssetGraphRequestRust.createAssetGraphRequestRust)(this.rustAtlaspack)(input) : (0, _AssetGraphRequest.default)(input), {
|
|
576
578
|
force: true
|
|
577
579
|
});
|
|
580
|
+
const duration = Date.now() - start;
|
|
578
581
|
_logger().default.info({
|
|
579
|
-
message:
|
|
582
|
+
message: `Done building asset graph in ${duration / 1000}s!`,
|
|
583
|
+
origin
|
|
580
584
|
});
|
|
581
585
|
if (writeToCache) {
|
|
582
586
|
_logger().default.info({
|
|
583
|
-
message: 'Write request tracker to cache'
|
|
587
|
+
message: 'Write request tracker to cache',
|
|
588
|
+
origin
|
|
584
589
|
});
|
|
585
590
|
await this.writeRequestTrackerToCache();
|
|
586
591
|
_logger().default.info({
|
|
587
|
-
message: 'Done writing request tracker to cache'
|
|
592
|
+
message: 'Done writing request tracker to cache',
|
|
593
|
+
origin
|
|
588
594
|
});
|
|
589
595
|
}
|
|
590
596
|
return result;
|
|
@@ -48,6 +48,7 @@ function createAssetGraphRequestRust(rustAtlaspack) {
|
|
|
48
48
|
let serializedAssetGraph;
|
|
49
49
|
try {
|
|
50
50
|
serializedAssetGraph = await rustAtlaspack.buildAssetGraph();
|
|
51
|
+
serializedAssetGraph.nodes = serializedAssetGraph.nodes.flatMap(node => JSON.parse(node));
|
|
51
52
|
} catch (err) {
|
|
52
53
|
throw new (_diagnostic().default)({
|
|
53
54
|
diagnostic: err
|
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.3536+e6d31a6a3",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -20,21 +20,21 @@
|
|
|
20
20
|
"check-ts": "tsc --noEmit index.d.ts"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@atlaspack/build-cache": "2.12.1-canary.
|
|
24
|
-
"@atlaspack/cache": "2.12.1-canary.
|
|
25
|
-
"@atlaspack/diagnostic": "2.12.1-canary.
|
|
26
|
-
"@atlaspack/events": "2.12.1-canary.
|
|
27
|
-
"@atlaspack/feature-flags": "2.12.1-canary.
|
|
28
|
-
"@atlaspack/fs": "2.12.1-canary.
|
|
29
|
-
"@atlaspack/graph": "3.2.1-canary.
|
|
30
|
-
"@atlaspack/logger": "2.12.1-canary.
|
|
31
|
-
"@atlaspack/package-manager": "2.12.1-canary.
|
|
32
|
-
"@atlaspack/plugin": "2.12.1-canary.
|
|
33
|
-
"@atlaspack/profiler": "2.12.1-canary.
|
|
34
|
-
"@atlaspack/rust": "2.12.1-canary.
|
|
35
|
-
"@atlaspack/types": "2.12.1-canary.
|
|
36
|
-
"@atlaspack/utils": "2.12.1-canary.
|
|
37
|
-
"@atlaspack/workers": "2.12.1-canary.
|
|
23
|
+
"@atlaspack/build-cache": "2.12.1-canary.3536+e6d31a6a3",
|
|
24
|
+
"@atlaspack/cache": "2.12.1-canary.3536+e6d31a6a3",
|
|
25
|
+
"@atlaspack/diagnostic": "2.12.1-canary.3536+e6d31a6a3",
|
|
26
|
+
"@atlaspack/events": "2.12.1-canary.3536+e6d31a6a3",
|
|
27
|
+
"@atlaspack/feature-flags": "2.12.1-canary.3536+e6d31a6a3",
|
|
28
|
+
"@atlaspack/fs": "2.12.1-canary.3536+e6d31a6a3",
|
|
29
|
+
"@atlaspack/graph": "3.2.1-canary.3536+e6d31a6a3",
|
|
30
|
+
"@atlaspack/logger": "2.12.1-canary.3536+e6d31a6a3",
|
|
31
|
+
"@atlaspack/package-manager": "2.12.1-canary.3536+e6d31a6a3",
|
|
32
|
+
"@atlaspack/plugin": "2.12.1-canary.3536+e6d31a6a3",
|
|
33
|
+
"@atlaspack/profiler": "2.12.1-canary.3536+e6d31a6a3",
|
|
34
|
+
"@atlaspack/rust": "2.12.1-canary.3536+e6d31a6a3",
|
|
35
|
+
"@atlaspack/types": "2.12.1-canary.3536+e6d31a6a3",
|
|
36
|
+
"@atlaspack/utils": "2.12.1-canary.3536+e6d31a6a3",
|
|
37
|
+
"@atlaspack/workers": "2.12.1-canary.3536+e6d31a6a3",
|
|
38
38
|
"@mischnic/json-sourcemap": "^0.1.0",
|
|
39
39
|
"@parcel/source-map": "^2.1.1",
|
|
40
40
|
"base-x": "^3.0.8",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"browser": {
|
|
67
67
|
"./src/serializerCore.js": "./src/serializerCore.browser.js"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "e6d31a6a3698efceb11ebb7b79d7427ec59044f6"
|
|
70
70
|
}
|
package/src/Atlaspack.js
CHANGED
|
@@ -585,6 +585,8 @@ export default class Atlaspack {
|
|
|
585
585
|
writeToCache: boolean = true,
|
|
586
586
|
): Promise<AssetGraphRequestResult> {
|
|
587
587
|
await this._init();
|
|
588
|
+
|
|
589
|
+
const origin = '@atlaspack/core';
|
|
588
590
|
const input = {
|
|
589
591
|
optionsRef: this.#optionsRef,
|
|
590
592
|
name: 'Main',
|
|
@@ -594,6 +596,8 @@ export default class Atlaspack {
|
|
|
594
596
|
lazyExcludes: [],
|
|
595
597
|
requestedAssetIds: this.#requestedAssetIds,
|
|
596
598
|
};
|
|
599
|
+
|
|
600
|
+
const start = Date.now();
|
|
597
601
|
const result = await this.#requestTracker.runRequest(
|
|
598
602
|
this.rustAtlaspack != null
|
|
599
603
|
? createAssetGraphRequestRust(this.rustAtlaspack)(input)
|
|
@@ -601,12 +605,17 @@ export default class Atlaspack {
|
|
|
601
605
|
{force: true},
|
|
602
606
|
);
|
|
603
607
|
|
|
604
|
-
|
|
608
|
+
const duration = Date.now() - start;
|
|
609
|
+
|
|
610
|
+
logger.info({
|
|
611
|
+
message: `Done building asset graph in ${duration / 1000}s!`,
|
|
612
|
+
origin,
|
|
613
|
+
});
|
|
605
614
|
|
|
606
615
|
if (writeToCache) {
|
|
607
|
-
logger.info({message: 'Write request tracker to cache'});
|
|
616
|
+
logger.info({message: 'Write request tracker to cache', origin});
|
|
608
617
|
await this.writeRequestTrackerToCache();
|
|
609
|
-
logger.info({message: 'Done writing request tracker to cache'});
|
|
618
|
+
logger.info({message: 'Done writing request tracker to cache', origin});
|
|
610
619
|
}
|
|
611
620
|
|
|
612
621
|
return result;
|
|
@@ -173,18 +173,26 @@ export default async function loadPlugin<T>(
|
|
|
173
173
|
// Remove plugin version compatiblility validation in canary builds as they don't use semver
|
|
174
174
|
if (!process.env.SKIP_PLUGIN_COMPATIBILITY_CHECK) {
|
|
175
175
|
if (!pluginName.startsWith('.')) {
|
|
176
|
-
// Validate the engines
|
|
177
|
-
let
|
|
178
|
-
|
|
176
|
+
// Validate the plugin engines field
|
|
177
|
+
let key = 'atlaspack';
|
|
178
|
+
let atlaspackVersionRange;
|
|
179
|
+
if (pkg?.engines?.atlaspack) {
|
|
180
|
+
atlaspackVersionRange = pkg.engines.atlaspack;
|
|
181
|
+
} else if (pkg?.engines?.parcel) {
|
|
182
|
+
key = 'parcel';
|
|
183
|
+
atlaspackVersionRange = pkg.engines.parcel;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (!atlaspackVersionRange) {
|
|
179
187
|
logger.warn({
|
|
180
188
|
origin: '@atlaspack/core',
|
|
181
|
-
message: `The plugin "${pluginName}" needs to specify a \`package.json#engines.
|
|
189
|
+
message: `The plugin "${pluginName}" needs to specify a \`package.json#engines.atlaspack\` field with the supported Atlaspack version range.`,
|
|
182
190
|
});
|
|
183
191
|
}
|
|
184
192
|
|
|
185
193
|
if (
|
|
186
|
-
|
|
187
|
-
!semver.satisfies(ATLASPACK_VERSION,
|
|
194
|
+
atlaspackVersionRange &&
|
|
195
|
+
!semver.satisfies(ATLASPACK_VERSION, atlaspackVersionRange)
|
|
188
196
|
) {
|
|
189
197
|
let pkgFile = nullthrows(
|
|
190
198
|
await resolveConfig(
|
|
@@ -197,7 +205,7 @@ export default async function loadPlugin<T>(
|
|
|
197
205
|
let pkgContents = await options.inputFS.readFile(pkgFile, 'utf8');
|
|
198
206
|
throw new ThrowableDiagnostic({
|
|
199
207
|
diagnostic: {
|
|
200
|
-
message: md`The plugin "${pluginName}" is not compatible with the current version of Atlaspack. Requires "${
|
|
208
|
+
message: md`The plugin "${pluginName}" is not compatible with the current version of Atlaspack. Requires "${atlaspackVersionRange}" but the current version is "${ATLASPACK_VERSION}".`,
|
|
201
209
|
origin: '@atlaspack/core',
|
|
202
210
|
codeFrames: [
|
|
203
211
|
{
|
|
@@ -206,7 +214,7 @@ export default async function loadPlugin<T>(
|
|
|
206
214
|
code: pkgContents,
|
|
207
215
|
codeHighlights: generateJSONCodeHighlights(pkgContents, [
|
|
208
216
|
{
|
|
209
|
-
key:
|
|
217
|
+
key: `/engines/${key}`,
|
|
210
218
|
},
|
|
211
219
|
]),
|
|
212
220
|
},
|
|
@@ -42,6 +42,9 @@ export function createAssetGraphRequestRust(
|
|
|
42
42
|
let serializedAssetGraph;
|
|
43
43
|
try {
|
|
44
44
|
serializedAssetGraph = await rustAtlaspack.buildAssetGraph();
|
|
45
|
+
serializedAssetGraph.nodes = serializedAssetGraph.nodes.flatMap(
|
|
46
|
+
(node) => JSON.parse(node),
|
|
47
|
+
);
|
|
45
48
|
} catch (err) {
|
|
46
49
|
throw new ThrowableDiagnostic({
|
|
47
50
|
diagnostic: err,
|
|
@@ -127,12 +127,13 @@ describe('AtlaspackConfig', () => {
|
|
|
127
127
|
});
|
|
128
128
|
|
|
129
129
|
describe('loadPlugin', () => {
|
|
130
|
-
it('should warn if a plugin needs to specify an engines.
|
|
130
|
+
it('should warn if a plugin needs to specify an engines.atlaspack field in package.json', async () => {
|
|
131
131
|
let projectRoot = path.join(__dirname, 'fixtures', 'plugins');
|
|
132
132
|
let configFilePath = toProjectPath(
|
|
133
133
|
projectRoot,
|
|
134
|
-
path.join(
|
|
134
|
+
path.join(projectRoot, '.parcelrc'),
|
|
135
135
|
);
|
|
136
|
+
|
|
136
137
|
let config = new AtlaspackConfig(
|
|
137
138
|
{
|
|
138
139
|
filePath: configFilePath,
|
|
@@ -140,7 +141,7 @@ describe('AtlaspackConfig', () => {
|
|
|
140
141
|
transformers: {
|
|
141
142
|
'*.js': [
|
|
142
143
|
{
|
|
143
|
-
packageName: '
|
|
144
|
+
packageName: 'atlaspack-transformer-no-engines',
|
|
144
145
|
resolveFrom: configFilePath,
|
|
145
146
|
keyPath: '/transformers/*.js/0',
|
|
146
147
|
},
|
|
@@ -152,51 +153,103 @@ describe('AtlaspackConfig', () => {
|
|
|
152
153
|
|
|
153
154
|
let warnStub = sinon.stub(logger, 'warn');
|
|
154
155
|
let {plugin} = await config.loadPlugin({
|
|
155
|
-
packageName: '
|
|
156
|
+
packageName: 'atlaspack-transformer-no-engines',
|
|
156
157
|
resolveFrom: configFilePath,
|
|
157
158
|
keyPath: '/transformers/*.js/0',
|
|
158
159
|
});
|
|
159
|
-
|
|
160
|
-
assert.equal(typeof plugin
|
|
160
|
+
|
|
161
|
+
assert.equal(typeof plugin?.transform, 'function');
|
|
161
162
|
assert(warnStub.calledOnce);
|
|
162
163
|
assert.deepEqual(warnStub.getCall(0).args[0], {
|
|
163
164
|
origin: '@atlaspack/core',
|
|
164
165
|
message:
|
|
165
|
-
'The plugin "
|
|
166
|
+
'The plugin "atlaspack-transformer-no-engines" needs to specify a `package.json#engines.atlaspack` field with the supported Atlaspack version range.',
|
|
166
167
|
});
|
|
167
168
|
warnStub.restore();
|
|
168
169
|
});
|
|
169
170
|
|
|
171
|
+
it('should error if a plugin specifies an invalid engines.atlaspack field in package.json', async () => {
|
|
172
|
+
let projectRoot = path.join(__dirname, 'fixtures', 'plugins');
|
|
173
|
+
let configFilePath = toProjectPath(
|
|
174
|
+
projectRoot,
|
|
175
|
+
path.join(projectRoot, '.parcelrc'),
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
let config = new AtlaspackConfig(
|
|
179
|
+
{
|
|
180
|
+
filePath: configFilePath,
|
|
181
|
+
bundler: undefined,
|
|
182
|
+
transformers: {},
|
|
183
|
+
},
|
|
184
|
+
{...DEFAULT_OPTIONS, projectRoot},
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
// $FlowFixMe[untyped-import]
|
|
188
|
+
let atlaspackVersion = require('../package.json').version;
|
|
189
|
+
let pkgJSON = path.join(
|
|
190
|
+
projectRoot,
|
|
191
|
+
'node_modules',
|
|
192
|
+
'atlaspack-transformer-bad-engines',
|
|
193
|
+
'package.json',
|
|
194
|
+
);
|
|
195
|
+
let code = inputFS.readFileSync(pkgJSON, 'utf8');
|
|
196
|
+
|
|
197
|
+
// $FlowFixMe
|
|
198
|
+
await assert.rejects(
|
|
199
|
+
() =>
|
|
200
|
+
config.loadPlugin({
|
|
201
|
+
packageName: 'atlaspack-transformer-bad-engines',
|
|
202
|
+
resolveFrom: configFilePath,
|
|
203
|
+
keyPath: '/transformers/*.js/0',
|
|
204
|
+
}),
|
|
205
|
+
{
|
|
206
|
+
name: 'Error',
|
|
207
|
+
diagnostics: [
|
|
208
|
+
{
|
|
209
|
+
message: `The plugin "atlaspack-transformer-bad-engines" is not compatible with the current version of Atlaspack. Requires "1.x" but the current version is "${atlaspackVersion}".`,
|
|
210
|
+
origin: '@atlaspack/core',
|
|
211
|
+
codeFrames: [
|
|
212
|
+
{
|
|
213
|
+
filePath: pkgJSON,
|
|
214
|
+
language: 'json5',
|
|
215
|
+
code,
|
|
216
|
+
codeHighlights: [
|
|
217
|
+
{
|
|
218
|
+
start: {line: 5, column: 5},
|
|
219
|
+
end: {line: 5, column: 22},
|
|
220
|
+
message: undefined,
|
|
221
|
+
},
|
|
222
|
+
],
|
|
223
|
+
},
|
|
224
|
+
],
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
},
|
|
228
|
+
);
|
|
229
|
+
});
|
|
230
|
+
|
|
170
231
|
it('should error if a plugin specifies an invalid engines.parcel field in package.json', async () => {
|
|
171
232
|
let projectRoot = path.join(__dirname, 'fixtures', 'plugins');
|
|
172
233
|
let configFilePath = toProjectPath(
|
|
173
234
|
projectRoot,
|
|
174
|
-
path.join(
|
|
235
|
+
path.join(projectRoot, '.parcelrc'),
|
|
175
236
|
);
|
|
237
|
+
|
|
176
238
|
let config = new AtlaspackConfig(
|
|
177
239
|
{
|
|
178
240
|
filePath: configFilePath,
|
|
179
241
|
bundler: undefined,
|
|
180
|
-
transformers: {
|
|
181
|
-
'*.js': [
|
|
182
|
-
{
|
|
183
|
-
packageName: 'parcel-transformer-not-found',
|
|
184
|
-
resolveFrom: configFilePath,
|
|
185
|
-
keyPath: '/transformers/*.js/0',
|
|
186
|
-
},
|
|
187
|
-
],
|
|
188
|
-
},
|
|
242
|
+
transformers: {},
|
|
189
243
|
},
|
|
190
244
|
{...DEFAULT_OPTIONS, projectRoot},
|
|
191
245
|
);
|
|
246
|
+
|
|
192
247
|
// $FlowFixMe[untyped-import]
|
|
193
|
-
let
|
|
248
|
+
let atlaspackVersion = require('../package.json').version;
|
|
194
249
|
let pkgJSON = path.join(
|
|
195
|
-
|
|
196
|
-
'fixtures',
|
|
197
|
-
'plugins',
|
|
250
|
+
projectRoot,
|
|
198
251
|
'node_modules',
|
|
199
|
-
'
|
|
252
|
+
'atlaspack-transformer-bad-parcel-engines',
|
|
200
253
|
'package.json',
|
|
201
254
|
);
|
|
202
255
|
let code = inputFS.readFileSync(pkgJSON, 'utf8');
|
|
@@ -205,7 +258,7 @@ describe('AtlaspackConfig', () => {
|
|
|
205
258
|
await assert.rejects(
|
|
206
259
|
() =>
|
|
207
260
|
config.loadPlugin({
|
|
208
|
-
packageName: '
|
|
261
|
+
packageName: 'atlaspack-transformer-bad-parcel-engines',
|
|
209
262
|
resolveFrom: configFilePath,
|
|
210
263
|
keyPath: '/transformers/*.js/0',
|
|
211
264
|
}),
|
|
@@ -213,7 +266,7 @@ describe('AtlaspackConfig', () => {
|
|
|
213
266
|
name: 'Error',
|
|
214
267
|
diagnostics: [
|
|
215
268
|
{
|
|
216
|
-
message: `The plugin "
|
|
269
|
+
message: `The plugin "atlaspack-transformer-bad-parcel-engines" is not compatible with the current version of Atlaspack. Requires "1.x" but the current version is "${atlaspackVersion}".`,
|
|
217
270
|
origin: '@atlaspack/core',
|
|
218
271
|
codeFrames: [
|
|
219
272
|
{
|
|
File without changes
|