@atlaspack/core 2.14.0 → 2.14.1-canary.10

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.
Files changed (89) hide show
  1. package/LICENSE +201 -0
  2. package/lib/AssetGraph.js +521 -0
  3. package/lib/Atlaspack.js +677 -0
  4. package/lib/AtlaspackConfig.js +298 -0
  5. package/lib/AtlaspackConfig.schema.js +103 -0
  6. package/lib/BundleGraph.js +1527 -0
  7. package/lib/CommittedAsset.js +155 -0
  8. package/lib/Dependency.js +136 -0
  9. package/lib/Environment.js +144 -0
  10. package/lib/IdentifierRegistry.js +36 -0
  11. package/lib/InternalConfig.js +56 -0
  12. package/lib/PackagerRunner.js +525 -0
  13. package/lib/ReporterRunner.js +151 -0
  14. package/lib/RequestTracker.js +1178 -0
  15. package/lib/SymbolPropagation.js +618 -0
  16. package/lib/TargetDescriptor.schema.js +118 -0
  17. package/lib/Transformation.js +522 -0
  18. package/lib/UncommittedAsset.js +348 -0
  19. package/lib/Validation.js +203 -0
  20. package/lib/applyRuntimes.js +355 -0
  21. package/lib/assetUtils.js +205 -0
  22. package/lib/atlaspack-v3/AtlaspackV3.js +66 -0
  23. package/lib/atlaspack-v3/NapiWorkerPool.js +71 -0
  24. package/lib/atlaspack-v3/fs.js +39 -0
  25. package/lib/atlaspack-v3/index.js +26 -0
  26. package/lib/atlaspack-v3/jsCallable.js +20 -0
  27. package/lib/atlaspack-v3/worker/compat/asset-symbols.js +197 -0
  28. package/lib/atlaspack-v3/worker/compat/bitflags.js +84 -0
  29. package/lib/atlaspack-v3/worker/compat/dependency.js +44 -0
  30. package/lib/atlaspack-v3/worker/compat/environment.js +57 -0
  31. package/lib/atlaspack-v3/worker/compat/index.js +104 -0
  32. package/lib/atlaspack-v3/worker/compat/mutable-asset.js +164 -0
  33. package/lib/atlaspack-v3/worker/compat/plugin-config.js +78 -0
  34. package/lib/atlaspack-v3/worker/compat/plugin-logger.js +29 -0
  35. package/lib/atlaspack-v3/worker/compat/plugin-options.js +113 -0
  36. package/lib/atlaspack-v3/worker/compat/plugin-tracer.js +12 -0
  37. package/lib/atlaspack-v3/worker/compat/target.js +17 -0
  38. package/lib/atlaspack-v3/worker/index.js +3 -0
  39. package/lib/atlaspack-v3/worker/worker.js +280 -0
  40. package/lib/constants.js +21 -0
  41. package/lib/dumpGraphToGraphViz.js +206 -0
  42. package/lib/index.js +70 -0
  43. package/lib/loadAtlaspackPlugin.js +110 -0
  44. package/lib/loadDotEnv.js +54 -0
  45. package/lib/projectPath.js +112 -0
  46. package/lib/public/Asset.js +259 -0
  47. package/lib/public/Bundle.js +236 -0
  48. package/lib/public/BundleGraph.js +279 -0
  49. package/lib/public/BundleGroup.js +50 -0
  50. package/lib/public/Config.js +202 -0
  51. package/lib/public/Dependency.js +131 -0
  52. package/lib/public/Environment.js +247 -0
  53. package/lib/public/MutableBundleGraph.js +204 -0
  54. package/lib/public/PluginOptions.js +71 -0
  55. package/lib/public/Symbols.js +247 -0
  56. package/lib/public/Target.js +64 -0
  57. package/lib/registerCoreWithSerializer.js +51 -0
  58. package/lib/requests/AssetGraphRequest.js +432 -0
  59. package/lib/requests/AssetGraphRequestRust.js +220 -0
  60. package/lib/requests/AssetRequest.js +132 -0
  61. package/lib/requests/AtlaspackBuildRequest.js +79 -0
  62. package/lib/requests/AtlaspackConfigRequest.js +479 -0
  63. package/lib/requests/BundleGraphRequest.js +485 -0
  64. package/lib/requests/ConfigRequest.js +203 -0
  65. package/lib/requests/DevDepRequest.js +193 -0
  66. package/lib/requests/EntryRequest.js +295 -0
  67. package/lib/requests/PackageRequest.js +88 -0
  68. package/lib/requests/PathRequest.js +357 -0
  69. package/lib/requests/TargetRequest.js +1179 -0
  70. package/lib/requests/ValidationRequest.js +66 -0
  71. package/lib/requests/WriteBundleRequest.js +252 -0
  72. package/lib/requests/WriteBundlesRequest.js +167 -0
  73. package/lib/requests/asset-graph-diff.js +128 -0
  74. package/lib/requests/asset-graph-dot.js +131 -0
  75. package/lib/resolveOptions.js +265 -0
  76. package/lib/serializerCore.browser.js +29 -0
  77. package/lib/summarizeRequest.js +55 -0
  78. package/lib/types.js +35 -0
  79. package/lib/utils.js +160 -0
  80. package/lib/worker.js +184 -0
  81. package/package.json +20 -19
  82. package/src/loadAtlaspackPlugin.js +5 -65
  83. package/test/AtlaspackConfig.test.js +0 -165
  84. package/test/fixtures/plugins/node_modules/atlaspack-transformer-bad-engines/index.js +0 -7
  85. package/test/fixtures/plugins/node_modules/atlaspack-transformer-bad-engines/package.json +0 -7
  86. package/test/fixtures/plugins/node_modules/atlaspack-transformer-bad-parcel-engines/index.js +0 -7
  87. package/test/fixtures/plugins/node_modules/atlaspack-transformer-bad-parcel-engines/package.json +0 -7
  88. package/test/fixtures/plugins/node_modules/atlaspack-transformer-no-engines/index.js +0 -7
  89. package/test/fixtures/plugins/node_modules/atlaspack-transformer-no-engines/package.json +0 -4
package/lib/worker.js ADDED
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.childInit = childInit;
7
+ exports.clearWorkerBuildCaches = clearWorkerBuildCaches;
8
+ exports.invalidateRequireCache = invalidateRequireCache;
9
+ exports.ping = ping;
10
+ exports.runPackage = runPackage;
11
+ exports.runTransform = runTransform;
12
+ exports.runValidate = runValidate;
13
+ function _utils() {
14
+ const data = require("@atlaspack/utils");
15
+ _utils = function () {
16
+ return data;
17
+ };
18
+ return data;
19
+ }
20
+ function _assert() {
21
+ const data = _interopRequireDefault(require("assert"));
22
+ _assert = function () {
23
+ return data;
24
+ };
25
+ return data;
26
+ }
27
+ function _nullthrows() {
28
+ const data = _interopRequireDefault(require("nullthrows"));
29
+ _nullthrows = function () {
30
+ return data;
31
+ };
32
+ return data;
33
+ }
34
+ var _BundleGraph = _interopRequireDefault(require("./BundleGraph"));
35
+ var _Transformation = _interopRequireDefault(require("./Transformation"));
36
+ var _ReporterRunner = require("./ReporterRunner");
37
+ var _PackagerRunner = _interopRequireDefault(require("./PackagerRunner"));
38
+ var _Validation = _interopRequireDefault(require("./Validation"));
39
+ var _AtlaspackConfig = require("./AtlaspackConfig");
40
+ var _registerCoreWithSerializer = require("./registerCoreWithSerializer");
41
+ function _buildCache() {
42
+ const data = require("@atlaspack/build-cache");
43
+ _buildCache = function () {
44
+ return data;
45
+ };
46
+ return data;
47
+ }
48
+ function _sourceMap() {
49
+ const data = require("@parcel/source-map");
50
+ _sourceMap = function () {
51
+ return data;
52
+ };
53
+ return data;
54
+ }
55
+ function _rust() {
56
+ const data = require("@atlaspack/rust");
57
+ _rust = function () {
58
+ return data;
59
+ };
60
+ return data;
61
+ }
62
+ function _workers() {
63
+ const data = _interopRequireDefault(require("@atlaspack/workers"));
64
+ _workers = function () {
65
+ return data;
66
+ };
67
+ return data;
68
+ }
69
+ function _featureFlags() {
70
+ const data = require("@atlaspack/feature-flags");
71
+ _featureFlags = function () {
72
+ return data;
73
+ };
74
+ return data;
75
+ }
76
+ require("@atlaspack/cache");
77
+ require("@atlaspack/package-manager");
78
+ require("@atlaspack/fs");
79
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
80
+ // register with serializer
81
+ // $FlowFixMe
82
+ if (process.env.ATLASPACK_BUILD_REPL && process.browser) {
83
+ /* eslint-disable import/no-extraneous-dependencies, monorepo/no-internal-import */
84
+ require('@atlaspack/repl/src/atlaspack/BrowserPackageManager.js');
85
+ // $FlowFixMe
86
+ require('@atlaspack/repl/src/atlaspack/ExtendedMemoryFS.js');
87
+ /* eslint-enable import/no-extraneous-dependencies, monorepo/no-internal-import */
88
+ }
89
+
90
+ (0, _registerCoreWithSerializer.registerCoreWithSerializer)();
91
+
92
+ // Remove the workerApi type from the TransformationOpts and ValidationOpts types:
93
+ // https://github.com/facebook/flow/issues/2835
94
+ // TODO: this should eventually be replaced by an in memory cache layer
95
+ let atlaspackConfigCache = new Map();
96
+ function loadOptions(ref, workerApi) {
97
+ return (0, _nullthrows().default)(workerApi.getSharedReference(ref
98
+ // $FlowFixMe
99
+ ));
100
+ }
101
+
102
+ async function loadConfig(cachePath, options) {
103
+ let config = atlaspackConfigCache.get(cachePath);
104
+ if (config && config.options === options) {
105
+ return config;
106
+ }
107
+ let processedConfig = (0, _nullthrows().default)(await options.cache.get(cachePath));
108
+ config = new _AtlaspackConfig.AtlaspackConfig(processedConfig, options);
109
+ atlaspackConfigCache.set(cachePath, config);
110
+ (0, _featureFlags().setFeatureFlags)(options.featureFlags);
111
+ return config;
112
+ }
113
+ function clearWorkerBuildCaches() {
114
+ _utils().loadConfig.clear();
115
+ (0, _buildCache().clearBuildCaches)();
116
+ }
117
+ async function runTransform(workerApi, opts) {
118
+ let {
119
+ optionsRef,
120
+ configCachePath,
121
+ ...rest
122
+ } = opts;
123
+ let options = loadOptions(optionsRef, workerApi);
124
+ let config = await loadConfig(configCachePath, options);
125
+ return new _Transformation.default({
126
+ workerApi,
127
+ options,
128
+ config,
129
+ ...rest
130
+ }).run();
131
+ }
132
+ async function runValidate(workerApi, opts) {
133
+ let {
134
+ optionsRef,
135
+ configCachePath,
136
+ ...rest
137
+ } = opts;
138
+ let options = loadOptions(optionsRef, workerApi);
139
+ let config = await loadConfig(configCachePath, options);
140
+ return new _Validation.default({
141
+ workerApi,
142
+ report: _ReporterRunner.reportWorker.bind(null, workerApi),
143
+ options,
144
+ config,
145
+ ...rest
146
+ }).run();
147
+ }
148
+ async function runPackage(workerApi, {
149
+ bundle,
150
+ bundleGraphReference,
151
+ configCachePath,
152
+ optionsRef,
153
+ previousDevDeps,
154
+ invalidDevDeps,
155
+ previousInvalidations
156
+ }) {
157
+ let bundleGraph = workerApi.getSharedReference(bundleGraphReference);
158
+ (0, _assert().default)(bundleGraph instanceof _BundleGraph.default);
159
+ let options = loadOptions(optionsRef, workerApi);
160
+ let atlaspackConfig = await loadConfig(configCachePath, options);
161
+ let runner = new _PackagerRunner.default({
162
+ config: atlaspackConfig,
163
+ options,
164
+ report: _workers().default.isWorker() ? _ReporterRunner.reportWorker.bind(null, workerApi) : _ReporterRunner.report,
165
+ previousDevDeps,
166
+ previousInvalidations
167
+ });
168
+ return runner.run(bundleGraph, bundle, invalidDevDeps);
169
+ }
170
+ async function childInit() {
171
+ await _sourceMap().init;
172
+ await (_rust().init === null || _rust().init === void 0 ? void 0 : (0, _rust().init)());
173
+ }
174
+ const PKG_RE = /node_modules[/\\]((?:@[^/\\]+[/\\][^/\\]+)|[^/\\]+)(?!.*[/\\]node_modules[/\\])/;
175
+ function invalidateRequireCache() {
176
+ throw new Error('invalidateRequireCache is only for tests');
177
+ }
178
+
179
+ /**
180
+ * This is used to wait until workers are responding to messages.
181
+ */
182
+ function ping() {
183
+ return true;
184
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/core",
3
- "version": "2.14.0",
3
+ "version": "2.14.1-canary.10+3b66d6b4b",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -20,22 +20,22 @@
20
20
  "check-ts": "tsc --noEmit index.d.ts"
21
21
  },
22
22
  "dependencies": {
23
+ "@atlaspack/build-cache": "2.13.3-canary.10+3b66d6b4b",
24
+ "@atlaspack/cache": "2.13.3-canary.10+3b66d6b4b",
25
+ "@atlaspack/diagnostic": "2.14.1-canary.10+3b66d6b4b",
26
+ "@atlaspack/events": "2.14.1-canary.10+3b66d6b4b",
27
+ "@atlaspack/feature-flags": "2.14.1-canary.10+3b66d6b4b",
28
+ "@atlaspack/fs": "2.14.1-canary.10+3b66d6b4b",
29
+ "@atlaspack/graph": "3.4.1-canary.10+3b66d6b4b",
30
+ "@atlaspack/logger": "2.14.1-canary.10+3b66d6b4b",
31
+ "@atlaspack/package-manager": "2.14.1-canary.10+3b66d6b4b",
32
+ "@atlaspack/plugin": "2.14.1-canary.10+3b66d6b4b",
33
+ "@atlaspack/profiler": "2.14.1-canary.10+3b66d6b4b",
34
+ "@atlaspack/rust": "3.0.1-canary.10+3b66d6b4b",
35
+ "@atlaspack/types": "2.14.1-canary.10+3b66d6b4b",
36
+ "@atlaspack/utils": "2.14.1-canary.10+3b66d6b4b",
37
+ "@atlaspack/workers": "2.14.1-canary.10+3b66d6b4b",
23
38
  "@mischnic/json-sourcemap": "^0.1.0",
24
- "@atlaspack/build-cache": "2.13.2",
25
- "@atlaspack/cache": "2.13.2",
26
- "@atlaspack/diagnostic": "2.14.0",
27
- "@atlaspack/events": "2.14.0",
28
- "@atlaspack/feature-flags": "2.14.0",
29
- "@atlaspack/fs": "2.14.0",
30
- "@atlaspack/graph": "3.4.0",
31
- "@atlaspack/logger": "2.14.0",
32
- "@atlaspack/package-manager": "2.14.0",
33
- "@atlaspack/plugin": "2.14.0",
34
- "@atlaspack/profiler": "2.14.0",
35
- "@atlaspack/rust": "3.0.0",
36
- "@atlaspack/types": "2.14.0",
37
- "@atlaspack/utils": "2.14.0",
38
- "@atlaspack/workers": "2.14.0",
39
39
  "@parcel/source-map": "^2.1.1",
40
40
  "base-x": "^3.0.8",
41
41
  "browserslist": "^4.6.6",
@@ -50,9 +50,9 @@
50
50
  "devDependencies": {
51
51
  "@atlaspack/babel-register": "2.14.0",
52
52
  "@types/node": ">= 18",
53
- "rfdc": "1",
54
- "jest-diff": "*",
55
53
  "graphviz": "^0.0.9",
54
+ "jest-diff": "*",
55
+ "rfdc": "1",
56
56
  "tempy": "^0.2.1"
57
57
  },
58
58
  "exports": {
@@ -66,5 +66,6 @@
66
66
  "browser": {
67
67
  "./src/serializerCore.js": "./src/serializerCore.browser.js"
68
68
  },
69
- "type": "commonjs"
69
+ "type": "commonjs",
70
+ "gitHead": "3b66d6b4bfd652ab3b41e86aacf3e47d39cd5a70"
70
71
  }
@@ -3,16 +3,13 @@ import type {FilePath, PackageName, Semver} from '@atlaspack/types';
3
3
  import type {AtlaspackOptions} from './types';
4
4
 
5
5
  import path from 'path';
6
- import semver from 'semver';
7
- import logger from '@atlaspack/logger';
8
6
  import nullthrows from 'nullthrows';
9
7
  import ThrowableDiagnostic, {
10
8
  generateJSONCodeHighlights,
11
9
  md,
12
10
  } from '@atlaspack/diagnostic';
13
- import {findAlternativeNodeModules, resolveConfig} from '@atlaspack/utils';
11
+ import {findAlternativeNodeModules} from '@atlaspack/utils';
14
12
  import {type ProjectPath, toProjectPath} from './projectPath';
15
- import {version as ATLASPACK_VERSION} from '../package.json';
16
13
 
17
14
  const NODE_MODULES = `${path.sep}node_modules${path.sep}`;
18
15
  const CONFIG = Symbol.for('parcel-plugin-config');
@@ -56,13 +53,11 @@ export default async function loadPlugin<T>(
56
53
  });
57
54
  }
58
55
 
59
- let resolved, pkg;
56
+ let pkg;
60
57
  try {
61
- ({resolved, pkg} = await options.packageManager.resolve(
62
- pluginName,
63
- resolveFrom,
64
- {shouldAutoInstall: options.shouldAutoInstall},
65
- ));
58
+ ({pkg} = await options.packageManager.resolve(pluginName, resolveFrom, {
59
+ shouldAutoInstall: options.shouldAutoInstall,
60
+ }));
66
61
  } catch (err) {
67
62
  if (err.code !== 'MODULE_NOT_FOUND') {
68
63
  throw err;
@@ -102,61 +97,6 @@ export default async function loadPlugin<T>(
102
97
  });
103
98
  }
104
99
 
105
- // Remove plugin version compatiblility validation in canary builds as they don't use semver
106
- if (!process.env.SKIP_PLUGIN_COMPATIBILITY_CHECK) {
107
- if (!pluginName.startsWith('.')) {
108
- // Validate the plugin engines field
109
- let key = 'atlaspack';
110
- let atlaspackVersionRange;
111
- if (pkg?.engines?.atlaspack) {
112
- atlaspackVersionRange = pkg.engines.atlaspack;
113
- } else if (pkg?.engines?.parcel) {
114
- key = 'parcel';
115
- atlaspackVersionRange = pkg.engines.parcel;
116
- }
117
-
118
- if (!atlaspackVersionRange) {
119
- logger.warn({
120
- origin: '@atlaspack/core',
121
- message: `The plugin "${pluginName}" needs to specify a \`package.json#engines.atlaspack\` field with the supported Atlaspack version range.`,
122
- });
123
- }
124
-
125
- if (
126
- atlaspackVersionRange &&
127
- !semver.satisfies(ATLASPACK_VERSION, atlaspackVersionRange)
128
- ) {
129
- let pkgFile = nullthrows(
130
- await resolveConfig(
131
- options.inputFS,
132
- resolved,
133
- ['package.json'],
134
- options.projectRoot,
135
- ),
136
- );
137
- let pkgContents = await options.inputFS.readFile(pkgFile, 'utf8');
138
- throw new ThrowableDiagnostic({
139
- diagnostic: {
140
- message: md`The plugin "${pluginName}" is not compatible with the current version of Atlaspack. Requires "${atlaspackVersionRange}" but the current version is "${ATLASPACK_VERSION}".`,
141
- origin: '@atlaspack/core',
142
- codeFrames: [
143
- {
144
- filePath: pkgFile,
145
- language: 'json5',
146
- code: pkgContents,
147
- codeHighlights: generateJSONCodeHighlights(pkgContents, [
148
- {
149
- key: `/engines/${key}`,
150
- },
151
- ]),
152
- },
153
- ],
154
- },
155
- });
156
- }
157
- }
158
- }
159
-
160
100
  let plugin = await options.packageManager.require(pluginName, resolveFrom, {
161
101
  shouldAutoInstall: options.shouldAutoInstall,
162
102
  });
@@ -3,10 +3,6 @@
3
3
  import assert from 'assert';
4
4
  import path from 'path';
5
5
 
6
- import logger from '@atlaspack/logger';
7
- import {inputFS} from '@atlaspack/test-utils';
8
- import sinon from 'sinon';
9
-
10
6
  import {AtlaspackConfig} from '../src/AtlaspackConfig';
11
7
  import {toProjectPath} from '../src/projectPath';
12
8
  import {parseAndProcessConfig} from '../src/requests/AtlaspackConfigRequest';
@@ -127,167 +123,6 @@ describe('AtlaspackConfig', () => {
127
123
  });
128
124
 
129
125
  describe('loadPlugin', () => {
130
- it('should warn if a plugin needs to specify an engines.atlaspack field in package.json', async () => {
131
- let projectRoot = path.join(__dirname, 'fixtures', 'plugins');
132
- let configFilePath = toProjectPath(
133
- projectRoot,
134
- path.join(projectRoot, '.parcelrc'),
135
- );
136
-
137
- let config = new AtlaspackConfig(
138
- {
139
- filePath: configFilePath,
140
- bundler: undefined,
141
- transformers: {
142
- '*.js': [
143
- {
144
- packageName: 'atlaspack-transformer-no-engines',
145
- resolveFrom: configFilePath,
146
- keyPath: '/transformers/*.js/0',
147
- },
148
- ],
149
- },
150
- },
151
- {...DEFAULT_OPTIONS, projectRoot},
152
- );
153
-
154
- let warnStub = sinon.stub(logger, 'warn');
155
- let {plugin} = await config.loadPlugin({
156
- packageName: 'atlaspack-transformer-no-engines',
157
- resolveFrom: configFilePath,
158
- keyPath: '/transformers/*.js/0',
159
- });
160
-
161
- assert.equal(typeof plugin?.transform, 'function');
162
- assert(warnStub.calledOnce);
163
- assert.deepEqual(warnStub.getCall(0).args[0], {
164
- origin: '@atlaspack/core',
165
- message:
166
- 'The plugin "atlaspack-transformer-no-engines" needs to specify a `package.json#engines.atlaspack` field with the supported Atlaspack version range.',
167
- });
168
- warnStub.restore();
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
-
231
- it('should error if a plugin specifies an invalid engines.parcel field in package.json', async () => {
232
- let projectRoot = path.join(__dirname, 'fixtures', 'plugins');
233
- let configFilePath = toProjectPath(
234
- projectRoot,
235
- path.join(projectRoot, '.parcelrc'),
236
- );
237
-
238
- let config = new AtlaspackConfig(
239
- {
240
- filePath: configFilePath,
241
- bundler: undefined,
242
- transformers: {},
243
- },
244
- {...DEFAULT_OPTIONS, projectRoot},
245
- );
246
-
247
- // $FlowFixMe[untyped-import]
248
- let atlaspackVersion = require('../package.json').version;
249
- let pkgJSON = path.join(
250
- projectRoot,
251
- 'node_modules',
252
- 'atlaspack-transformer-bad-parcel-engines',
253
- 'package.json',
254
- );
255
- let code = inputFS.readFileSync(pkgJSON, 'utf8');
256
-
257
- // $FlowFixMe
258
- await assert.rejects(
259
- () =>
260
- config.loadPlugin({
261
- packageName: 'atlaspack-transformer-bad-parcel-engines',
262
- resolveFrom: configFilePath,
263
- keyPath: '/transformers/*.js/0',
264
- }),
265
- {
266
- name: 'Error',
267
- diagnostics: [
268
- {
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}".`,
270
- origin: '@atlaspack/core',
271
- codeFrames: [
272
- {
273
- filePath: pkgJSON,
274
- language: 'json5',
275
- code,
276
- codeHighlights: [
277
- {
278
- start: {line: 5, column: 5},
279
- end: {line: 5, column: 19},
280
- message: undefined,
281
- },
282
- ],
283
- },
284
- ],
285
- },
286
- ],
287
- },
288
- );
289
- });
290
-
291
126
  it('should error with a codeframe if a plugin is not resolved', async () => {
292
127
  let configFilePath = path.join(
293
128
  __dirname,
@@ -1,7 +0,0 @@
1
- const {Transformer} = require('@atlaspack/plugin');
2
-
3
- module.exports = new Transformer({
4
- transform(asset) {
5
- return [asset];
6
- }
7
- });
@@ -1,7 +0,0 @@
1
- {
2
- "name": "atlaspack-transformer-bad-engines",
3
- "version": "1.0.0",
4
- "engines": {
5
- "atlaspack": "1.x"
6
- }
7
- }
@@ -1,7 +0,0 @@
1
- const {Transformer} = require('@atlaspack/plugin');
2
-
3
- module.exports = new Transformer({
4
- transform(asset) {
5
- return [asset];
6
- }
7
- });
@@ -1,7 +0,0 @@
1
- {
2
- "name": "atlaspack-transformer-bad-parcel-engines",
3
- "version": "1.0.0",
4
- "engines": {
5
- "parcel": "1.x"
6
- }
7
- }
@@ -1,7 +0,0 @@
1
- const {Transformer} = require('@atlaspack/plugin');
2
-
3
- module.exports = new Transformer({
4
- transform(asset) {
5
- return [asset];
6
- }
7
- });
@@ -1,4 +0,0 @@
1
- {
2
- "name": "atlaspack-transformer-no-engines",
3
- "version": "1.0.0"
4
- }