@atlaspack/core 2.12.1-canary.3533 → 2.12.1-canary.3535

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.
@@ -204,10 +204,10 @@ class BundleGraph {
204
204
  // Asset is in the same bundle
205
205
  return [asset, []];
206
206
  }
207
- const resolvedAsync = (0, _nullthrows().default)(this.#graph.resolveAsyncDependency(dep, (0, _Bundle.bundleToInternalBundle)(bundle)));
207
+ const resolvedAsync = (0, _nullthrows().default)(this.#graph.resolveAsyncDependency(dep, (0, _Bundle.bundleToInternalBundle)(bundle)), `Failed to load depenendency for '${dep.specifier}' specifier from '${String(dep.sourcePath)}'`);
208
208
  if ((resolvedAsync === null || resolvedAsync === void 0 ? void 0 : resolvedAsync.type) === 'asset') {
209
209
  // Single bundle to load dynamically
210
- return [resolvedAsync.value, [this.#createBundle((0, _nullthrows().default)(this.#graph.getReferencedBundle(dep, (0, _Bundle.bundleToInternalBundle)(bundle))), this.#graph, this.#options)]];
210
+ return [resolvedAsync.value, [this.#createBundle((0, _nullthrows().default)(this.#graph.getReferencedBundle(dep, (0, _Bundle.bundleToInternalBundle)(bundle)), `Failed to load referenced bundle for '${dep.specifier}' specifier from '${String(dep.sourcePath)}'`), this.#graph, this.#options)]];
211
211
  } else {
212
212
  // Bundle group means we have multiple bundles to load first
213
213
  return [this.#graph.getAssetById(resolvedAsync.value.entryAssetId), this.#graph.getBundlesInBundleGroup(resolvedAsync.value).map(b => this.#createBundle(b, this.#graph, this.#options))];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/core",
3
- "version": "2.12.1-canary.3533+6e85f4328",
3
+ "version": "2.12.1-canary.3535+66c8cd01b",
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.3533+6e85f4328",
24
- "@atlaspack/cache": "2.12.1-canary.3533+6e85f4328",
25
- "@atlaspack/diagnostic": "2.12.1-canary.3533+6e85f4328",
26
- "@atlaspack/events": "2.12.1-canary.3533+6e85f4328",
27
- "@atlaspack/feature-flags": "2.12.1-canary.3533+6e85f4328",
28
- "@atlaspack/fs": "2.12.1-canary.3533+6e85f4328",
29
- "@atlaspack/graph": "3.2.1-canary.3533+6e85f4328",
30
- "@atlaspack/logger": "2.12.1-canary.3533+6e85f4328",
31
- "@atlaspack/package-manager": "2.12.1-canary.3533+6e85f4328",
32
- "@atlaspack/plugin": "2.12.1-canary.3533+6e85f4328",
33
- "@atlaspack/profiler": "2.12.1-canary.3533+6e85f4328",
34
- "@atlaspack/rust": "2.12.1-canary.3533+6e85f4328",
35
- "@atlaspack/types": "2.12.1-canary.3533+6e85f4328",
36
- "@atlaspack/utils": "2.12.1-canary.3533+6e85f4328",
37
- "@atlaspack/workers": "2.12.1-canary.3533+6e85f4328",
23
+ "@atlaspack/build-cache": "2.12.1-canary.3535+66c8cd01b",
24
+ "@atlaspack/cache": "2.12.1-canary.3535+66c8cd01b",
25
+ "@atlaspack/diagnostic": "2.12.1-canary.3535+66c8cd01b",
26
+ "@atlaspack/events": "2.12.1-canary.3535+66c8cd01b",
27
+ "@atlaspack/feature-flags": "2.12.1-canary.3535+66c8cd01b",
28
+ "@atlaspack/fs": "2.12.1-canary.3535+66c8cd01b",
29
+ "@atlaspack/graph": "3.2.1-canary.3535+66c8cd01b",
30
+ "@atlaspack/logger": "2.12.1-canary.3535+66c8cd01b",
31
+ "@atlaspack/package-manager": "2.12.1-canary.3535+66c8cd01b",
32
+ "@atlaspack/plugin": "2.12.1-canary.3535+66c8cd01b",
33
+ "@atlaspack/profiler": "2.12.1-canary.3535+66c8cd01b",
34
+ "@atlaspack/rust": "2.12.1-canary.3535+66c8cd01b",
35
+ "@atlaspack/types": "2.12.1-canary.3535+66c8cd01b",
36
+ "@atlaspack/utils": "2.12.1-canary.3535+66c8cd01b",
37
+ "@atlaspack/workers": "2.12.1-canary.3535+66c8cd01b",
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": "6e85f4328ee2bce3b5882dc00a56d61e27a070a9"
69
+ "gitHead": "66c8cd01ba7f6e6d22b84933083865b826b605cd"
70
70
  }
@@ -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.parcel field in the plugin's package.json
177
- let parcelVersionRange = pkg && pkg.engines && pkg.engines.parcel;
178
- if (!parcelVersionRange) {
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.parcel\` field with the supported Atlaspack version range.`,
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
- parcelVersionRange &&
187
- !semver.satisfies(ATLASPACK_VERSION, parcelVersionRange)
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 "${parcelVersionRange}" but the current version is "${ATLASPACK_VERSION}".`,
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: '/engines/parcel',
217
+ key: `/engines/${key}`,
210
218
  },
211
219
  ]),
212
220
  },
@@ -378,6 +378,9 @@ export default class BundleGraph<TBundle: IBundle>
378
378
  dep,
379
379
  bundleToInternalBundle(bundle),
380
380
  ),
381
+ `Failed to load depenendency for '${
382
+ dep.specifier
383
+ }' specifier from '${String(dep.sourcePath)}'`,
381
384
  );
382
385
  if (resolvedAsync?.type === 'asset') {
383
386
  // Single bundle to load dynamically
@@ -390,6 +393,9 @@ export default class BundleGraph<TBundle: IBundle>
390
393
  dep,
391
394
  bundleToInternalBundle(bundle),
392
395
  ),
396
+ `Failed to load referenced bundle for '${
397
+ dep.specifier
398
+ }' specifier from '${String(dep.sourcePath)}'`,
393
399
  ),
394
400
  this.#graph,
395
401
  this.#options,
@@ -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.parcel field in package.json', async () => {
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(__dirname, 'fixtures', 'plugins', '.parcelrc'),
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: 'parcel-transformer-no-engines',
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: 'parcel-transformer-no-engines',
156
+ packageName: 'atlaspack-transformer-no-engines',
156
157
  resolveFrom: configFilePath,
157
158
  keyPath: '/transformers/*.js/0',
158
159
  });
159
- assert(plugin);
160
- assert.equal(typeof plugin.transform, 'function');
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 "parcel-transformer-no-engines" needs to specify a `package.json#engines.parcel` field with the supported Atlaspack version range.',
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(__dirname, 'fixtures', 'plugins', '.parcelrc'),
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 parcelVersion = require('../package.json').version;
248
+ let atlaspackVersion = require('../package.json').version;
194
249
  let pkgJSON = path.join(
195
- __dirname,
196
- 'fixtures',
197
- 'plugins',
250
+ projectRoot,
198
251
  'node_modules',
199
- 'parcel-transformer-bad-engines',
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: 'parcel-transformer-bad-engines',
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 "parcel-transformer-bad-engines" is not compatible with the current version of Atlaspack. Requires "5.x" but the current version is "${parcelVersion}".`,
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
  {
@@ -1,7 +1,4 @@
1
1
  {
2
2
  "name": "parcel-config-local",
3
- "version": "1.0.0",
4
- "engines": {
5
- "parcel": "2.x"
6
- }
3
+ "version": "1.0.0"
7
4
  }
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "atlaspack-transformer-bad-engines",
3
+ "version": "1.0.0",
4
+ "engines": {
5
+ "atlaspack": "1.x"
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "atlaspack-transformer-bad-parcel-engines",
3
+ "version": "1.0.0",
4
+ "engines": {
5
+ "parcel": "1.x"
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+ const {Transformer} = require('@atlaspack/plugin');
2
+
3
+ module.exports = new Transformer({
4
+ transform(asset) {
5
+ return [asset];
6
+ }
7
+ });
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "atlaspack-transformer-no-engines",
3
+ "version": "1.0.0"
4
+ }
@@ -1,7 +0,0 @@
1
- {
2
- "name": "parcel-transformer-bad-engines",
3
- "version": "1.0.0",
4
- "engines": {
5
- "parcel": "5.x"
6
- }
7
- }
@@ -1,4 +0,0 @@
1
- {
2
- "name": "parcel-transformer-no-engines",
3
- "version": "1.0.0"
4
- }