@atlaspack/core 2.14.1-dev.9 → 2.14.1-dev.91
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 +5 -1
- package/lib/BundleGraph.js +4 -1
- package/lib/index.js +9 -1
- package/lib/internal-plugins.js +9 -0
- package/lib/isSuperPackage.js +21 -0
- package/lib/loadAtlaspackPlugin.js +16 -6
- package/lib/public/BundleGraph.js +3 -2
- package/lib/requests/AtlaspackConfigRequest.js +42 -29
- package/lib/rustWorkerThreadDylibHack.js +22 -0
- package/lib/worker.js +8 -8
- package/package.json +17 -17
- package/src/Atlaspack.js +14 -2
- package/src/BundleGraph.js +8 -1
- package/src/index.js +2 -0
- package/src/internal-plugins.js +4 -0
- package/src/isSuperPackage.js +26 -0
- package/src/loadAtlaspackPlugin.js +27 -65
- package/src/public/BundleGraph.js +5 -3
- package/src/requests/AtlaspackConfigRequest.js +76 -31
- package/src/rustWorkerThreadDylibHack.js +18 -0
- package/src/worker.js +8 -7
- 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
package/lib/Atlaspack.js
CHANGED
|
@@ -118,6 +118,7 @@ function _featureFlags() {
|
|
|
118
118
|
var _atlaspackV = require("./atlaspack-v3");
|
|
119
119
|
var _AssetGraphRequest = _interopRequireDefault(require("./requests/AssetGraphRequest"));
|
|
120
120
|
var _AssetGraphRequestRust = require("./requests/AssetGraphRequestRust");
|
|
121
|
+
var _rustWorkerThreadDylibHack = require("./rustWorkerThreadDylibHack");
|
|
121
122
|
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); }
|
|
122
123
|
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; }
|
|
123
124
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -125,7 +126,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
125
126
|
(0, _registerCoreWithSerializer.registerCoreWithSerializer)();
|
|
126
127
|
const INTERNAL_TRANSFORM = exports.INTERNAL_TRANSFORM = Symbol('internal_transform');
|
|
127
128
|
const INTERNAL_RESOLVE = exports.INTERNAL_RESOLVE = Symbol('internal_resolve');
|
|
128
|
-
const WORKER_PATH = exports.WORKER_PATH = _path().default.join(__dirname, 'worker.js');
|
|
129
|
+
const WORKER_PATH = exports.WORKER_PATH = _path().default.join( /*#__ATLASPACK_IGNORE__*/__dirname, 'worker.js');
|
|
129
130
|
class Atlaspack {
|
|
130
131
|
#requestTracker /*: RequestTracker*/;
|
|
131
132
|
#config /*: AtlaspackConfig*/;
|
|
@@ -165,6 +166,9 @@ class Atlaspack {
|
|
|
165
166
|
...this.#initialOptions.featureFlags
|
|
166
167
|
};
|
|
167
168
|
(0, _featureFlags().setFeatureFlags)(featureFlags);
|
|
169
|
+
if ((0, _featureFlags().getFeatureFlag)('enableRustWorkerThreadDylibHack')) {
|
|
170
|
+
(0, _rustWorkerThreadDylibHack.loadRustWorkerThreadDylibHack)();
|
|
171
|
+
}
|
|
168
172
|
await _sourceMap().init;
|
|
169
173
|
await (_rust().init === null || _rust().init === void 0 ? void 0 : (0, _rust().init)());
|
|
170
174
|
this.#disposable = new (_events().Disposable)();
|
package/lib/BundleGraph.js
CHANGED
|
@@ -832,7 +832,10 @@ class BundleGraph {
|
|
|
832
832
|
// If this asset is referenced by any async dependency, it's referenced.
|
|
833
833
|
return true;
|
|
834
834
|
}
|
|
835
|
-
let dependencies = this._graph.getNodeIdsConnectedTo(assetNodeId
|
|
835
|
+
let dependencies = this._graph.getNodeIdsConnectedTo(assetNodeId,
|
|
836
|
+
// TODO: This seems like bug with library builds when assets are present
|
|
837
|
+
// in other files. Guarding the fix for now exclusively for super builds
|
|
838
|
+
process.env.ATLASPACK_SUPER_BUILD === 'true' ? _graph().ALL_EDGE_TYPES : undefined).map(id => (0, _nullthrows().default)(this._graph.getNode(id))).filter(node => node.type === 'dependency').map(node => {
|
|
836
839
|
(0, _assert().default)(node.type === 'dependency');
|
|
837
840
|
return node.value;
|
|
838
841
|
});
|
package/lib/index.js
CHANGED
|
@@ -9,7 +9,8 @@ var _exportNames = {
|
|
|
9
9
|
BuildError: true,
|
|
10
10
|
createWorkerFarm: true,
|
|
11
11
|
INTERNAL_RESOLVE: true,
|
|
12
|
-
INTERNAL_TRANSFORM: true
|
|
12
|
+
INTERNAL_TRANSFORM: true,
|
|
13
|
+
isSuperPackage: true
|
|
13
14
|
};
|
|
14
15
|
Object.defineProperty(exports, "Atlaspack", {
|
|
15
16
|
enumerable: true,
|
|
@@ -53,7 +54,14 @@ Object.defineProperty(exports, "default", {
|
|
|
53
54
|
return _Atlaspack.default;
|
|
54
55
|
}
|
|
55
56
|
});
|
|
57
|
+
Object.defineProperty(exports, "isSuperPackage", {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
get: function () {
|
|
60
|
+
return _isSuperPackage.isSuperPackage;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
56
63
|
var _Atlaspack = _interopRequireWildcard(require("./Atlaspack"));
|
|
64
|
+
var _isSuperPackage = require("./isSuperPackage");
|
|
57
65
|
var _atlaspackV = require("./atlaspack-v3");
|
|
58
66
|
Object.keys(_atlaspackV).forEach(function (key) {
|
|
59
67
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
let fs = require('fs');
|
|
4
|
+
let {
|
|
5
|
+
findAncestorFile
|
|
6
|
+
} = require('@atlaspack/rust');
|
|
7
|
+
let dirname = /*#__ATLASPACK_IGNORE__*/__dirname;
|
|
8
|
+
function isSuperPackage() {
|
|
9
|
+
if (!dirname) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
let packageJson = JSON.parse(fs.readFileSync(findAncestorFile(['package.json'], dirname, '/')));
|
|
13
|
+
return packageJson.name === '@atlaspack/super';
|
|
14
|
+
}
|
|
15
|
+
let result;
|
|
16
|
+
module.exports.isSuperPackage = () => {
|
|
17
|
+
if (result == null) {
|
|
18
|
+
result = isSuperPackage();
|
|
19
|
+
}
|
|
20
|
+
return result;
|
|
21
|
+
};
|
|
@@ -25,6 +25,8 @@ function _diagnostic() {
|
|
|
25
25
|
};
|
|
26
26
|
return data;
|
|
27
27
|
}
|
|
28
|
+
var _package = require("../package.json");
|
|
29
|
+
var _internalPlugins = _interopRequireDefault(require("./internal-plugins"));
|
|
28
30
|
function _utils() {
|
|
29
31
|
const data = require("@atlaspack/utils");
|
|
30
32
|
_utils = function () {
|
|
@@ -33,13 +35,25 @@ function _utils() {
|
|
|
33
35
|
return data;
|
|
34
36
|
}
|
|
35
37
|
var _projectPath = require("./projectPath");
|
|
36
|
-
var _package = require("../package.json");
|
|
37
38
|
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
39
|
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
40
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
40
41
|
const NODE_MODULES = `${_path().default.sep}node_modules${_path().default.sep}`;
|
|
41
42
|
const CONFIG = Symbol.for('parcel-plugin-config');
|
|
42
43
|
async function loadPlugin(pluginName, configPath, keyPath, options) {
|
|
44
|
+
if (_internalPlugins.default && _internalPlugins.default[pluginName]) {
|
|
45
|
+
let plugin = _internalPlugins.default[pluginName]();
|
|
46
|
+
plugin = plugin.default || plugin;
|
|
47
|
+
plugin = plugin[CONFIG];
|
|
48
|
+
if (!plugin) {
|
|
49
|
+
throw new Error(`Plugin ${pluginName} is not a valid Atlaspack plugin, should export an instance of a Atlaspack plugin ex. "export default new Reporter({ ... })".`);
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
plugin,
|
|
53
|
+
version: _package.version,
|
|
54
|
+
resolveFrom: (0, _projectPath.toProjectPathUnsafe)(options.projectRoot)
|
|
55
|
+
};
|
|
56
|
+
}
|
|
43
57
|
let resolveFrom = configPath;
|
|
44
58
|
|
|
45
59
|
// Config packages can reference plugins, but cannot contain other plugins within them.
|
|
@@ -62,10 +76,9 @@ async function loadPlugin(pluginName, configPath, keyPath, options) {
|
|
|
62
76
|
}
|
|
63
77
|
});
|
|
64
78
|
}
|
|
65
|
-
let
|
|
79
|
+
let pkg;
|
|
66
80
|
try {
|
|
67
81
|
({
|
|
68
|
-
resolved,
|
|
69
82
|
pkg
|
|
70
83
|
} = await options.packageManager.resolve(pluginName, resolveFrom, {
|
|
71
84
|
shouldAutoInstall: options.shouldAutoInstall
|
|
@@ -93,9 +106,6 @@ async function loadPlugin(pluginName, configPath, keyPath, options) {
|
|
|
93
106
|
}
|
|
94
107
|
});
|
|
95
108
|
}
|
|
96
|
-
|
|
97
|
-
// Remove plugin version compatiblility validation in canary builds as they don't use semver
|
|
98
|
-
|
|
99
109
|
let plugin = await options.packageManager.require(pluginName, resolveFrom, {
|
|
100
110
|
shouldAutoInstall: options.shouldAutoInstall
|
|
101
111
|
});
|
|
@@ -262,12 +262,13 @@ class BundleGraph {
|
|
|
262
262
|
ifFalseBundles.push(...depToBundles(cond.ifFalseDependency));
|
|
263
263
|
}
|
|
264
264
|
for (let bundle of bundles) {
|
|
265
|
-
const conditions = bundleConditions.get(bundle) ?? new Map();
|
|
265
|
+
const conditions = bundleConditions.get(bundle.id) ?? new Map();
|
|
266
266
|
conditions.set(cond.key, {
|
|
267
|
+
bundle,
|
|
267
268
|
ifTrueBundles,
|
|
268
269
|
ifFalseBundles
|
|
269
270
|
});
|
|
270
|
-
bundleConditions.set(bundle, conditions);
|
|
271
|
+
bundleConditions.set(bundle.id, conditions);
|
|
271
272
|
}
|
|
272
273
|
}
|
|
273
274
|
return bundleConditions;
|
|
@@ -40,7 +40,7 @@ function _diagnostic() {
|
|
|
40
40
|
return data;
|
|
41
41
|
}
|
|
42
42
|
function _json() {
|
|
43
|
-
const data = require("json5");
|
|
43
|
+
const data = _interopRequireDefault(require("json5"));
|
|
44
44
|
_json = function () {
|
|
45
45
|
return data;
|
|
46
46
|
};
|
|
@@ -60,11 +60,13 @@ function _assert() {
|
|
|
60
60
|
};
|
|
61
61
|
return data;
|
|
62
62
|
}
|
|
63
|
+
var _internalPlugins = _interopRequireDefault(require("../internal-plugins"));
|
|
63
64
|
var _AtlaspackConfig = require("../AtlaspackConfig");
|
|
64
65
|
var _AtlaspackConfig2 = _interopRequireDefault(require("../AtlaspackConfig.schema"));
|
|
65
66
|
var _projectPath = require("../projectPath");
|
|
66
67
|
var _RequestTracker = require("../RequestTracker");
|
|
67
68
|
var _utils2 = require("../utils");
|
|
69
|
+
var _isSuperPackage = require("../isSuperPackage");
|
|
68
70
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
69
71
|
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); }
|
|
70
72
|
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; }
|
|
@@ -134,28 +136,36 @@ async function resolveAtlaspackConfig(options) {
|
|
|
134
136
|
let resolveFrom = getResolveFrom(options.inputFS, options.projectRoot);
|
|
135
137
|
let configPath = options.config != null ? (await options.packageManager.resolve(options.config, resolveFrom)).resolved : await (0, _utils().resolveConfig)(options.inputFS, resolveFrom, ['.parcelrc'], options.projectRoot);
|
|
136
138
|
let usedDefault = false;
|
|
137
|
-
|
|
139
|
+
let config, extendedFiles;
|
|
140
|
+
if (configPath == null && options.defaultConfig != null && (0, _isSuperPackage.isSuperPackage)() && options.defaultConfig.endsWith('.js')) {
|
|
138
141
|
usedDefault = true;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
142
|
+
// Load the super package default config
|
|
143
|
+
let result = await processConfigChain(_internalPlugins.default['@atlaspack/config-default'](), options.defaultConfig, options);
|
|
144
|
+
config = result.config;
|
|
145
|
+
extendedFiles = result.extendedFiles;
|
|
146
|
+
} else {
|
|
147
|
+
if (configPath == null && options.defaultConfig != null) {
|
|
148
|
+
usedDefault = true;
|
|
149
|
+
configPath = (await options.packageManager.resolve(options.defaultConfig, resolveFrom)).resolved;
|
|
150
|
+
}
|
|
151
|
+
if (configPath == null) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
let contents;
|
|
155
|
+
try {
|
|
156
|
+
contents = await options.inputFS.readFile(configPath, 'utf8');
|
|
157
|
+
} catch (e) {
|
|
158
|
+
throw new (_diagnostic().default)({
|
|
159
|
+
diagnostic: {
|
|
160
|
+
message: (0, _diagnostic().md)`Could not find parcel config at ${_path().default.relative(options.projectRoot, configPath)}`,
|
|
161
|
+
origin: '@atlaspack/core'
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
let result = await parseAndProcessConfig(configPath, contents, options);
|
|
166
|
+
config = result.config;
|
|
167
|
+
extendedFiles = result.extendedFiles;
|
|
154
168
|
}
|
|
155
|
-
let {
|
|
156
|
-
config,
|
|
157
|
-
extendedFiles
|
|
158
|
-
} = await parseAndProcessConfig(configPath, contents, options);
|
|
159
169
|
if (options.additionalReporters.length > 0) {
|
|
160
170
|
config.reporters = [...options.additionalReporters.map(({
|
|
161
171
|
packageName,
|
|
@@ -179,7 +189,7 @@ function create(config, options) {
|
|
|
179
189
|
async function parseAndProcessConfig(configPath, contents, options) {
|
|
180
190
|
let config;
|
|
181
191
|
try {
|
|
182
|
-
config =
|
|
192
|
+
config = _json().default.parse(contents);
|
|
183
193
|
} catch (e) {
|
|
184
194
|
let pos = {
|
|
185
195
|
line: e.lineNumber,
|
|
@@ -304,13 +314,16 @@ async function processConfigChain(configFile, filePath, options) {
|
|
|
304
314
|
for (let ext of exts) {
|
|
305
315
|
try {
|
|
306
316
|
let key = Array.isArray(configFile.extends) ? `/extends/${i}` : '/extends';
|
|
307
|
-
let
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
317
|
+
let nextConfig;
|
|
318
|
+
if (_internalPlugins.default[ext]) {
|
|
319
|
+
nextConfig = (await processConfigChain(_internalPlugins.default[ext](), /*#__ATLASPACK_IGNORE__*/__dirname, options)).config;
|
|
320
|
+
} else {
|
|
321
|
+
let resolved = await resolveExtends(ext, filePath, key, options);
|
|
322
|
+
extendedFiles.push(resolved);
|
|
323
|
+
let result = await processExtendedConfig(filePath, key, ext, resolved, options);
|
|
324
|
+
extendedFiles = extendedFiles.concat(result.extendedFiles);
|
|
325
|
+
nextConfig = result.config;
|
|
326
|
+
}
|
|
314
327
|
extStartConfig = extStartConfig ? mergeConfigs(extStartConfig, nextConfig) : nextConfig;
|
|
315
328
|
} catch (err) {
|
|
316
329
|
errors.push(err);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.loadRustWorkerThreadDylibHack = loadRustWorkerThreadDylibHack;
|
|
7
|
+
/**
|
|
8
|
+
* This is a workaround for https://github.com/rust-lang/rust/issues/91979
|
|
9
|
+
* when running atlaspack with parcel bindings, it is possible that the parcel
|
|
10
|
+
* dylib will be loaded from a node worker thread, which causes a crash on exit.
|
|
11
|
+
*
|
|
12
|
+
* This is a workaround to ensure that the parcel dylib is loaded in the main
|
|
13
|
+
* thread, which fixes the crash.
|
|
14
|
+
*/
|
|
15
|
+
function loadRustWorkerThreadDylibHack() {
|
|
16
|
+
try {
|
|
17
|
+
// $FlowFixMe
|
|
18
|
+
require('@parcel/rust'); // eslint-disable-line
|
|
19
|
+
} catch (err) {
|
|
20
|
+
/* ignore */
|
|
21
|
+
}
|
|
22
|
+
}
|
package/lib/worker.js
CHANGED
|
@@ -78,15 +78,15 @@ require("@atlaspack/package-manager");
|
|
|
78
78
|
require("@atlaspack/fs");
|
|
79
79
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
80
80
|
// register with serializer
|
|
81
|
+
// Repl builds are currently not enabled
|
|
81
82
|
// $FlowFixMe
|
|
82
|
-
if (process.env.ATLASPACK_BUILD_REPL && process.browser) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
83
|
+
// if (process.env.ATLASPACK_BUILD_REPL && process.browser) {
|
|
84
|
+
// /* eslint-disable import/no-extraneous-dependencies, monorepo/no-internal-import */
|
|
85
|
+
// require('@atlaspack/repl/src/atlaspack/BrowserPackageManager.js');
|
|
86
|
+
// // $FlowFixMe
|
|
87
|
+
// require('@atlaspack/repl/src/atlaspack/ExtendedMemoryFS.js');
|
|
88
|
+
// /* eslint-enable import/no-extraneous-dependencies, monorepo/no-internal-import */
|
|
89
|
+
// }
|
|
90
90
|
(0, _registerCoreWithSerializer.registerCoreWithSerializer)();
|
|
91
91
|
|
|
92
92
|
// Remove the workerApi type from the TransformationOpts and ValidationOpts types:
|
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.91+08020e0e1",
|
|
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.91+08020e0e1",
|
|
24
|
+
"@atlaspack/cache": "2.13.3-dev.91+08020e0e1",
|
|
25
|
+
"@atlaspack/diagnostic": "2.14.1-dev.91+08020e0e1",
|
|
26
|
+
"@atlaspack/events": "2.14.1-dev.91+08020e0e1",
|
|
27
|
+
"@atlaspack/feature-flags": "2.14.1-dev.91+08020e0e1",
|
|
28
|
+
"@atlaspack/fs": "2.14.1-dev.91+08020e0e1",
|
|
29
|
+
"@atlaspack/graph": "3.4.1-dev.91+08020e0e1",
|
|
30
|
+
"@atlaspack/logger": "2.14.1-dev.91+08020e0e1",
|
|
31
|
+
"@atlaspack/package-manager": "2.14.1-dev.91+08020e0e1",
|
|
32
|
+
"@atlaspack/plugin": "2.14.1-dev.91+08020e0e1",
|
|
33
|
+
"@atlaspack/profiler": "2.14.1-dev.91+08020e0e1",
|
|
34
|
+
"@atlaspack/rust": "3.0.1-dev.91+08020e0e1",
|
|
35
|
+
"@atlaspack/types": "2.14.1-dev.91+08020e0e1",
|
|
36
|
+
"@atlaspack/utils": "2.14.1-dev.91+08020e0e1",
|
|
37
|
+
"@atlaspack/workers": "2.14.1-dev.91+08020e0e1",
|
|
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": "08020e0e18819f3e15e74726f9ffa697892f7bfa"
|
|
71
71
|
}
|
package/src/Atlaspack.js
CHANGED
|
@@ -58,17 +58,25 @@ import {
|
|
|
58
58
|
fromProjectPathRelative,
|
|
59
59
|
} from './projectPath';
|
|
60
60
|
import {tracer} from '@atlaspack/profiler';
|
|
61
|
-
import {
|
|
61
|
+
import {
|
|
62
|
+
getFeatureFlag,
|
|
63
|
+
setFeatureFlags,
|
|
64
|
+
DEFAULT_FEATURE_FLAGS,
|
|
65
|
+
} from '@atlaspack/feature-flags';
|
|
62
66
|
import {AtlaspackV3, FileSystemV3} from './atlaspack-v3';
|
|
63
67
|
import createAssetGraphRequestJS from './requests/AssetGraphRequest';
|
|
64
68
|
import {createAssetGraphRequestRust} from './requests/AssetGraphRequestRust';
|
|
65
69
|
import type {AssetGraphRequestResult} from './requests/AssetGraphRequest';
|
|
70
|
+
import {loadRustWorkerThreadDylibHack} from './rustWorkerThreadDylibHack';
|
|
66
71
|
|
|
67
72
|
registerCoreWithSerializer();
|
|
68
73
|
|
|
69
74
|
export const INTERNAL_TRANSFORM: symbol = Symbol('internal_transform');
|
|
70
75
|
export const INTERNAL_RESOLVE: symbol = Symbol('internal_resolve');
|
|
71
|
-
export const WORKER_PATH: string = path.join(
|
|
76
|
+
export const WORKER_PATH: string = path.join(
|
|
77
|
+
/*#__ATLASPACK_IGNORE__*/ __dirname,
|
|
78
|
+
'worker.js',
|
|
79
|
+
);
|
|
72
80
|
|
|
73
81
|
export default class Atlaspack {
|
|
74
82
|
#requestTracker /*: RequestTracker*/;
|
|
@@ -117,6 +125,10 @@ export default class Atlaspack {
|
|
|
117
125
|
};
|
|
118
126
|
setFeatureFlags(featureFlags);
|
|
119
127
|
|
|
128
|
+
if (getFeatureFlag('enableRustWorkerThreadDylibHack')) {
|
|
129
|
+
loadRustWorkerThreadDylibHack();
|
|
130
|
+
}
|
|
131
|
+
|
|
120
132
|
await initSourcemaps;
|
|
121
133
|
await initRust?.();
|
|
122
134
|
|
package/src/BundleGraph.js
CHANGED
|
@@ -1315,7 +1315,14 @@ export default class BundleGraph {
|
|
|
1315
1315
|
}
|
|
1316
1316
|
|
|
1317
1317
|
let dependencies = this._graph
|
|
1318
|
-
.getNodeIdsConnectedTo(
|
|
1318
|
+
.getNodeIdsConnectedTo(
|
|
1319
|
+
assetNodeId,
|
|
1320
|
+
// TODO: This seems like bug with library builds when assets are present
|
|
1321
|
+
// in other files. Guarding the fix for now exclusively for super builds
|
|
1322
|
+
process.env.ATLASPACK_SUPER_BUILD === 'true'
|
|
1323
|
+
? ALL_EDGE_TYPES
|
|
1324
|
+
: undefined,
|
|
1325
|
+
)
|
|
1319
1326
|
.map((id) => nullthrows(this._graph.getNode(id)))
|
|
1320
1327
|
.filter((node) => node.type === 'dependency')
|
|
1321
1328
|
.map((node) => {
|
package/src/index.js
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
let fs = require('fs');
|
|
2
|
+
let {findAncestorFile} = require('@atlaspack/rust');
|
|
3
|
+
|
|
4
|
+
let dirname = /*#__ATLASPACK_IGNORE__*/ __dirname;
|
|
5
|
+
|
|
6
|
+
function isSuperPackage() {
|
|
7
|
+
if (!dirname) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let packageJson = JSON.parse(
|
|
12
|
+
fs.readFileSync(findAncestorFile(['package.json'], dirname, '/')),
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
return packageJson.name === '@atlaspack/super';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let result;
|
|
19
|
+
|
|
20
|
+
module.exports.isSuperPackage = () => {
|
|
21
|
+
if (result == null) {
|
|
22
|
+
result = isSuperPackage();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
@@ -3,16 +3,19 @@ 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';
|
|
14
|
-
import {type ProjectPath, toProjectPath} from './projectPath';
|
|
15
11
|
import {version as ATLASPACK_VERSION} from '../package.json';
|
|
12
|
+
import atlaspackInternalPlugins from './internal-plugins';
|
|
13
|
+
import {findAlternativeNodeModules} from '@atlaspack/utils';
|
|
14
|
+
import {
|
|
15
|
+
type ProjectPath,
|
|
16
|
+
toProjectPath,
|
|
17
|
+
toProjectPathUnsafe,
|
|
18
|
+
} from './projectPath';
|
|
16
19
|
|
|
17
20
|
const NODE_MODULES = `${path.sep}node_modules${path.sep}`;
|
|
18
21
|
const CONFIG = Symbol.for('parcel-plugin-config');
|
|
@@ -27,6 +30,22 @@ export default async function loadPlugin<T>(
|
|
|
27
30
|
version: Semver,
|
|
28
31
|
resolveFrom: ProjectPath,
|
|
29
32
|
|}> {
|
|
33
|
+
if (atlaspackInternalPlugins && atlaspackInternalPlugins[pluginName]) {
|
|
34
|
+
let plugin = atlaspackInternalPlugins[pluginName]();
|
|
35
|
+
plugin = plugin.default || plugin;
|
|
36
|
+
plugin = plugin[CONFIG];
|
|
37
|
+
if (!plugin) {
|
|
38
|
+
throw new Error(
|
|
39
|
+
`Plugin ${pluginName} is not a valid Atlaspack plugin, should export an instance of a Atlaspack plugin ex. "export default new Reporter({ ... })".`,
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
plugin,
|
|
44
|
+
version: ATLASPACK_VERSION,
|
|
45
|
+
resolveFrom: toProjectPathUnsafe(options.projectRoot),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
30
49
|
let resolveFrom = configPath;
|
|
31
50
|
|
|
32
51
|
// Config packages can reference plugins, but cannot contain other plugins within them.
|
|
@@ -56,13 +75,11 @@ export default async function loadPlugin<T>(
|
|
|
56
75
|
});
|
|
57
76
|
}
|
|
58
77
|
|
|
59
|
-
let
|
|
78
|
+
let pkg;
|
|
60
79
|
try {
|
|
61
|
-
({
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
{shouldAutoInstall: options.shouldAutoInstall},
|
|
65
|
-
));
|
|
80
|
+
({pkg} = await options.packageManager.resolve(pluginName, resolveFrom, {
|
|
81
|
+
shouldAutoInstall: options.shouldAutoInstall,
|
|
82
|
+
}));
|
|
66
83
|
} catch (err) {
|
|
67
84
|
if (err.code !== 'MODULE_NOT_FOUND') {
|
|
68
85
|
throw err;
|
|
@@ -102,61 +119,6 @@ export default async function loadPlugin<T>(
|
|
|
102
119
|
});
|
|
103
120
|
}
|
|
104
121
|
|
|
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
122
|
let plugin = await options.packageManager.require(pluginName, resolveFrom, {
|
|
161
123
|
shouldAutoInstall: options.shouldAutoInstall,
|
|
162
124
|
});
|
|
@@ -444,10 +444,11 @@ export default class BundleGraph<TBundle: IBundle>
|
|
|
444
444
|
// be used by a webserver to understand which conditions are used by which bundles,
|
|
445
445
|
// and which bundles those conditions require depending on what they evaluate to.
|
|
446
446
|
getConditionalBundleMapping(): Map<
|
|
447
|
-
|
|
447
|
+
string,
|
|
448
448
|
Map<
|
|
449
449
|
string,
|
|
450
450
|
{|
|
|
451
|
+
bundle: TBundle,
|
|
451
452
|
ifTrueBundles: Array<TBundle>,
|
|
452
453
|
ifFalseBundles: Array<TBundle>,
|
|
453
454
|
|},
|
|
@@ -486,14 +487,15 @@ export default class BundleGraph<TBundle: IBundle>
|
|
|
486
487
|
}
|
|
487
488
|
|
|
488
489
|
for (let bundle of bundles) {
|
|
489
|
-
const conditions = bundleConditions.get(bundle) ?? new Map();
|
|
490
|
+
const conditions = bundleConditions.get(bundle.id) ?? new Map();
|
|
490
491
|
|
|
491
492
|
conditions.set(cond.key, {
|
|
493
|
+
bundle,
|
|
492
494
|
ifTrueBundles,
|
|
493
495
|
ifFalseBundles,
|
|
494
496
|
});
|
|
495
497
|
|
|
496
|
-
bundleConditions.set(bundle, conditions);
|
|
498
|
+
bundleConditions.set(bundle.id, conditions);
|
|
497
499
|
}
|
|
498
500
|
}
|
|
499
501
|
|
|
@@ -30,15 +30,17 @@ import ThrowableDiagnostic, {
|
|
|
30
30
|
md,
|
|
31
31
|
errorToDiagnostic,
|
|
32
32
|
} from '@atlaspack/diagnostic';
|
|
33
|
-
import
|
|
33
|
+
import json5 from 'json5';
|
|
34
34
|
import path from 'path';
|
|
35
35
|
import invariant from 'assert';
|
|
36
36
|
|
|
37
|
+
import atlaspackInternalPlugins from '../internal-plugins';
|
|
37
38
|
import {AtlaspackConfig} from '../AtlaspackConfig';
|
|
38
39
|
import AtlaspackConfigSchema from '../AtlaspackConfig.schema';
|
|
39
40
|
import {toProjectPath} from '../projectPath';
|
|
40
41
|
import {requestTypes} from '../RequestTracker';
|
|
41
42
|
import {optionsProxy} from '../utils';
|
|
43
|
+
import {isSuperPackage} from '../isSuperPackage';
|
|
42
44
|
|
|
43
45
|
type ConfigMap<K, V> = {[K]: V, ...};
|
|
44
46
|
|
|
@@ -159,34 +161,59 @@ export async function resolveAtlaspackConfig(
|
|
|
159
161
|
);
|
|
160
162
|
|
|
161
163
|
let usedDefault = false;
|
|
162
|
-
|
|
164
|
+
let config, extendedFiles;
|
|
165
|
+
|
|
166
|
+
if (
|
|
167
|
+
configPath == null &&
|
|
168
|
+
options.defaultConfig != null &&
|
|
169
|
+
isSuperPackage() &&
|
|
170
|
+
options.defaultConfig.endsWith('.js')
|
|
171
|
+
) {
|
|
163
172
|
usedDefault = true;
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
173
|
+
// Load the super package default config
|
|
174
|
+
let result: AtlaspackConfigChain = await processConfigChain(
|
|
175
|
+
atlaspackInternalPlugins['@atlaspack/config-default'](),
|
|
176
|
+
options.defaultConfig,
|
|
177
|
+
options,
|
|
178
|
+
);
|
|
179
|
+
config = result.config;
|
|
180
|
+
extendedFiles = result.extendedFiles;
|
|
181
|
+
} else {
|
|
182
|
+
if (configPath == null && options.defaultConfig != null) {
|
|
183
|
+
usedDefault = true;
|
|
168
184
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
185
|
+
configPath = (
|
|
186
|
+
await options.packageManager.resolve(options.defaultConfig, resolveFrom)
|
|
187
|
+
).resolved;
|
|
188
|
+
}
|
|
172
189
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
} catch (e) {
|
|
177
|
-
throw new ThrowableDiagnostic({
|
|
178
|
-
diagnostic: {
|
|
179
|
-
message: md`Could not find parcel config at ${path.relative(
|
|
180
|
-
options.projectRoot,
|
|
181
|
-
configPath,
|
|
182
|
-
)}`,
|
|
183
|
-
origin: '@atlaspack/core',
|
|
184
|
-
},
|
|
185
|
-
});
|
|
186
|
-
}
|
|
190
|
+
if (configPath == null) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
187
193
|
|
|
188
|
-
|
|
189
|
-
|
|
194
|
+
let contents;
|
|
195
|
+
try {
|
|
196
|
+
contents = await options.inputFS.readFile(configPath, 'utf8');
|
|
197
|
+
} catch (e) {
|
|
198
|
+
throw new ThrowableDiagnostic({
|
|
199
|
+
diagnostic: {
|
|
200
|
+
message: md`Could not find parcel config at ${path.relative(
|
|
201
|
+
options.projectRoot,
|
|
202
|
+
configPath,
|
|
203
|
+
)}`,
|
|
204
|
+
origin: '@atlaspack/core',
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
let result: AtlaspackConfigChain = await parseAndProcessConfig(
|
|
210
|
+
configPath,
|
|
211
|
+
contents,
|
|
212
|
+
options,
|
|
213
|
+
);
|
|
214
|
+
config = result.config;
|
|
215
|
+
extendedFiles = result.extendedFiles;
|
|
216
|
+
}
|
|
190
217
|
|
|
191
218
|
if (options.additionalReporters.length > 0) {
|
|
192
219
|
config.reporters = [
|
|
@@ -216,7 +243,7 @@ export async function parseAndProcessConfig(
|
|
|
216
243
|
): Promise<AtlaspackConfigChain> {
|
|
217
244
|
let config: RawAtlaspackConfig;
|
|
218
245
|
try {
|
|
219
|
-
config = parse(contents);
|
|
246
|
+
config = json5.parse(contents);
|
|
220
247
|
} catch (e) {
|
|
221
248
|
let pos = {
|
|
222
249
|
line: e.lineNumber,
|
|
@@ -446,11 +473,29 @@ export async function processConfigChain(
|
|
|
446
473
|
let key = Array.isArray(configFile.extends)
|
|
447
474
|
? `/extends/${i}`
|
|
448
475
|
: '/extends';
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
476
|
+
|
|
477
|
+
let nextConfig;
|
|
478
|
+
if (atlaspackInternalPlugins[ext]) {
|
|
479
|
+
nextConfig = (
|
|
480
|
+
await processConfigChain(
|
|
481
|
+
atlaspackInternalPlugins[ext](),
|
|
482
|
+
/*#__ATLASPACK_IGNORE__*/ __dirname,
|
|
483
|
+
options,
|
|
484
|
+
)
|
|
485
|
+
).config;
|
|
486
|
+
} else {
|
|
487
|
+
let resolved = await resolveExtends(ext, filePath, key, options);
|
|
488
|
+
extendedFiles.push(resolved);
|
|
489
|
+
let result = await processExtendedConfig(
|
|
490
|
+
filePath,
|
|
491
|
+
key,
|
|
492
|
+
ext,
|
|
493
|
+
resolved,
|
|
494
|
+
options,
|
|
495
|
+
);
|
|
496
|
+
extendedFiles = extendedFiles.concat(result.extendedFiles);
|
|
497
|
+
nextConfig = result.config;
|
|
498
|
+
}
|
|
454
499
|
extStartConfig = extStartConfig
|
|
455
500
|
? mergeConfigs(extStartConfig, nextConfig)
|
|
456
501
|
: nextConfig;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// @flow strict-local
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This is a workaround for https://github.com/rust-lang/rust/issues/91979
|
|
5
|
+
* when running atlaspack with parcel bindings, it is possible that the parcel
|
|
6
|
+
* dylib will be loaded from a node worker thread, which causes a crash on exit.
|
|
7
|
+
*
|
|
8
|
+
* This is a workaround to ensure that the parcel dylib is loaded in the main
|
|
9
|
+
* thread, which fixes the crash.
|
|
10
|
+
*/
|
|
11
|
+
export function loadRustWorkerThreadDylibHack() {
|
|
12
|
+
try {
|
|
13
|
+
// $FlowFixMe
|
|
14
|
+
require('@parcel/rust'); // eslint-disable-line
|
|
15
|
+
} catch (err) {
|
|
16
|
+
/* ignore */
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/worker.js
CHANGED
|
@@ -32,14 +32,15 @@ import '@atlaspack/cache'; // register with serializer
|
|
|
32
32
|
import '@atlaspack/package-manager';
|
|
33
33
|
import '@atlaspack/fs';
|
|
34
34
|
|
|
35
|
+
// Repl builds are currently not enabled
|
|
35
36
|
// $FlowFixMe
|
|
36
|
-
if (process.env.ATLASPACK_BUILD_REPL && process.browser) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
37
|
+
// if (process.env.ATLASPACK_BUILD_REPL && process.browser) {
|
|
38
|
+
// /* eslint-disable import/no-extraneous-dependencies, monorepo/no-internal-import */
|
|
39
|
+
// require('@atlaspack/repl/src/atlaspack/BrowserPackageManager.js');
|
|
40
|
+
// // $FlowFixMe
|
|
41
|
+
// require('@atlaspack/repl/src/atlaspack/ExtendedMemoryFS.js');
|
|
42
|
+
// /* eslint-enable import/no-extraneous-dependencies, monorepo/no-internal-import */
|
|
43
|
+
// }
|
|
43
44
|
|
|
44
45
|
registerCoreWithSerializer();
|
|
45
46
|
|
|
@@ -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,
|