@atlaspack/core 2.14.1-dev.10 → 2.14.1-dev.15
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/loadAtlaspackPlugin.js +1 -6
- package/package.json +17 -17
- package/src/loadAtlaspackPlugin.js +5 -65
- package/test/AtlaspackConfig.test.js +0 -165
- package/test/fixtures/plugins/node_modules/atlaspack-transformer-bad-engines/index.js +0 -7
- package/test/fixtures/plugins/node_modules/atlaspack-transformer-bad-engines/package.json +0 -7
- package/test/fixtures/plugins/node_modules/atlaspack-transformer-bad-parcel-engines/index.js +0 -7
- package/test/fixtures/plugins/node_modules/atlaspack-transformer-bad-parcel-engines/package.json +0 -7
- package/test/fixtures/plugins/node_modules/atlaspack-transformer-no-engines/index.js +0 -7
- package/test/fixtures/plugins/node_modules/atlaspack-transformer-no-engines/package.json +0 -4
|
@@ -33,7 +33,6 @@ function _utils() {
|
|
|
33
33
|
return data;
|
|
34
34
|
}
|
|
35
35
|
var _projectPath = require("./projectPath");
|
|
36
|
-
var _package = require("../package.json");
|
|
37
36
|
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); }
|
|
38
37
|
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; }
|
|
39
38
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -62,10 +61,9 @@ async function loadPlugin(pluginName, configPath, keyPath, options) {
|
|
|
62
61
|
}
|
|
63
62
|
});
|
|
64
63
|
}
|
|
65
|
-
let
|
|
64
|
+
let pkg;
|
|
66
65
|
try {
|
|
67
66
|
({
|
|
68
|
-
resolved,
|
|
69
67
|
pkg
|
|
70
68
|
} = await options.packageManager.resolve(pluginName, resolveFrom, {
|
|
71
69
|
shouldAutoInstall: options.shouldAutoInstall
|
|
@@ -93,9 +91,6 @@ async function loadPlugin(pluginName, configPath, keyPath, options) {
|
|
|
93
91
|
}
|
|
94
92
|
});
|
|
95
93
|
}
|
|
96
|
-
|
|
97
|
-
// Remove plugin version compatiblility validation in canary builds as they don't use semver
|
|
98
|
-
|
|
99
94
|
let plugin = await options.packageManager.require(pluginName, resolveFrom, {
|
|
100
95
|
shouldAutoInstall: options.shouldAutoInstall
|
|
101
96
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/core",
|
|
3
|
-
"version": "2.14.1-dev.
|
|
3
|
+
"version": "2.14.1-dev.15+30b65feb9",
|
|
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.13.3-dev.
|
|
24
|
-
"@atlaspack/cache": "2.13.3-dev.
|
|
25
|
-
"@atlaspack/diagnostic": "2.14.1-dev.
|
|
26
|
-
"@atlaspack/events": "2.14.1-dev.
|
|
27
|
-
"@atlaspack/feature-flags": "2.14.1-dev.
|
|
28
|
-
"@atlaspack/fs": "2.14.1-dev.
|
|
29
|
-
"@atlaspack/graph": "3.4.1-dev.
|
|
30
|
-
"@atlaspack/logger": "2.14.1-dev.
|
|
31
|
-
"@atlaspack/package-manager": "2.14.1-dev.
|
|
32
|
-
"@atlaspack/plugin": "2.14.1-dev.
|
|
33
|
-
"@atlaspack/profiler": "2.14.1-dev.
|
|
34
|
-
"@atlaspack/rust": "3.0.1-dev.
|
|
35
|
-
"@atlaspack/types": "2.14.1-dev.
|
|
36
|
-
"@atlaspack/utils": "2.14.1-dev.
|
|
37
|
-
"@atlaspack/workers": "2.14.1-dev.
|
|
23
|
+
"@atlaspack/build-cache": "2.13.3-dev.15+30b65feb9",
|
|
24
|
+
"@atlaspack/cache": "2.13.3-dev.15+30b65feb9",
|
|
25
|
+
"@atlaspack/diagnostic": "2.14.1-dev.15+30b65feb9",
|
|
26
|
+
"@atlaspack/events": "2.14.1-dev.15+30b65feb9",
|
|
27
|
+
"@atlaspack/feature-flags": "2.14.1-dev.15+30b65feb9",
|
|
28
|
+
"@atlaspack/fs": "2.14.1-dev.15+30b65feb9",
|
|
29
|
+
"@atlaspack/graph": "3.4.1-dev.15+30b65feb9",
|
|
30
|
+
"@atlaspack/logger": "2.14.1-dev.15+30b65feb9",
|
|
31
|
+
"@atlaspack/package-manager": "2.14.1-dev.15+30b65feb9",
|
|
32
|
+
"@atlaspack/plugin": "2.14.1-dev.15+30b65feb9",
|
|
33
|
+
"@atlaspack/profiler": "2.14.1-dev.15+30b65feb9",
|
|
34
|
+
"@atlaspack/rust": "3.0.1-dev.15+30b65feb9",
|
|
35
|
+
"@atlaspack/types": "2.14.1-dev.15+30b65feb9",
|
|
36
|
+
"@atlaspack/utils": "2.14.1-dev.15+30b65feb9",
|
|
37
|
+
"@atlaspack/workers": "2.14.1-dev.15+30b65feb9",
|
|
38
38
|
"@mischnic/json-sourcemap": "^0.1.0",
|
|
39
39
|
"@parcel/source-map": "^2.1.1",
|
|
40
40
|
"base-x": "^3.0.8",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"./src/serializerCore.js": "./src/serializerCore.browser.js"
|
|
68
68
|
},
|
|
69
69
|
"type": "commonjs",
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "30b65feb98113722e721c7cdee547765d195b65a"
|
|
71
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
|
|
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
|
|
56
|
+
let pkg;
|
|
60
57
|
try {
|
|
61
|
-
({
|
|
62
|
-
|
|
63
|
-
|
|
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,
|