@atlaspack/core 2.13.2-dev.3682 → 2.14.0
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/CHANGELOG.md +61 -0
- package/package.json +20 -20
- package/src/Atlaspack.js +3 -2
- package/src/atlaspack-v3/AtlaspackV3.js +24 -8
- package/src/loadAtlaspackPlugin.js +26 -71
- package/src/projectPath.js +14 -1
- package/src/requests/WriteBundlesRequest.js +31 -22
- package/LICENSE +0 -201
- package/lib/AssetGraph.js +0 -521
- package/lib/Atlaspack.js +0 -676
- package/lib/AtlaspackConfig.js +0 -298
- package/lib/AtlaspackConfig.schema.js +0 -103
- package/lib/BundleGraph.js +0 -1527
- package/lib/CommittedAsset.js +0 -155
- package/lib/Dependency.js +0 -136
- package/lib/Environment.js +0 -144
- package/lib/IdentifierRegistry.js +0 -36
- package/lib/InternalConfig.js +0 -56
- package/lib/PackagerRunner.js +0 -525
- package/lib/ReporterRunner.js +0 -151
- package/lib/RequestTracker.js +0 -1178
- package/lib/SymbolPropagation.js +0 -618
- package/lib/TargetDescriptor.schema.js +0 -118
- package/lib/Transformation.js +0 -522
- package/lib/UncommittedAsset.js +0 -348
- package/lib/Validation.js +0 -203
- package/lib/applyRuntimes.js +0 -355
- package/lib/assetUtils.js +0 -205
- package/lib/atlaspack-v3/AtlaspackV3.js +0 -57
- package/lib/atlaspack-v3/NapiWorkerPool.js +0 -71
- package/lib/atlaspack-v3/fs.js +0 -39
- package/lib/atlaspack-v3/index.js +0 -26
- package/lib/atlaspack-v3/jsCallable.js +0 -20
- package/lib/atlaspack-v3/worker/compat/asset-symbols.js +0 -197
- package/lib/atlaspack-v3/worker/compat/bitflags.js +0 -84
- package/lib/atlaspack-v3/worker/compat/dependency.js +0 -44
- package/lib/atlaspack-v3/worker/compat/environment.js +0 -57
- package/lib/atlaspack-v3/worker/compat/index.js +0 -104
- package/lib/atlaspack-v3/worker/compat/mutable-asset.js +0 -164
- package/lib/atlaspack-v3/worker/compat/plugin-config.js +0 -78
- package/lib/atlaspack-v3/worker/compat/plugin-logger.js +0 -29
- package/lib/atlaspack-v3/worker/compat/plugin-options.js +0 -113
- package/lib/atlaspack-v3/worker/compat/plugin-tracer.js +0 -12
- package/lib/atlaspack-v3/worker/compat/target.js +0 -17
- package/lib/atlaspack-v3/worker/index.js +0 -3
- package/lib/atlaspack-v3/worker/worker.js +0 -280
- package/lib/constants.js +0 -21
- package/lib/dumpGraphToGraphViz.js +0 -206
- package/lib/index.js +0 -70
- package/lib/loadAtlaspackPlugin.js +0 -136
- package/lib/loadDotEnv.js +0 -54
- package/lib/projectPath.js +0 -94
- package/lib/public/Asset.js +0 -259
- package/lib/public/Bundle.js +0 -236
- package/lib/public/BundleGraph.js +0 -279
- package/lib/public/BundleGroup.js +0 -50
- package/lib/public/Config.js +0 -202
- package/lib/public/Dependency.js +0 -131
- package/lib/public/Environment.js +0 -247
- package/lib/public/MutableBundleGraph.js +0 -204
- package/lib/public/PluginOptions.js +0 -71
- package/lib/public/Symbols.js +0 -247
- package/lib/public/Target.js +0 -64
- package/lib/registerCoreWithSerializer.js +0 -51
- package/lib/requests/AssetGraphRequest.js +0 -432
- package/lib/requests/AssetGraphRequestRust.js +0 -220
- package/lib/requests/AssetRequest.js +0 -132
- package/lib/requests/AtlaspackBuildRequest.js +0 -79
- package/lib/requests/AtlaspackConfigRequest.js +0 -479
- package/lib/requests/BundleGraphRequest.js +0 -485
- package/lib/requests/ConfigRequest.js +0 -203
- package/lib/requests/DevDepRequest.js +0 -193
- package/lib/requests/EntryRequest.js +0 -295
- package/lib/requests/PackageRequest.js +0 -88
- package/lib/requests/PathRequest.js +0 -357
- package/lib/requests/TargetRequest.js +0 -1179
- package/lib/requests/ValidationRequest.js +0 -66
- package/lib/requests/WriteBundleRequest.js +0 -252
- package/lib/requests/WriteBundlesRequest.js +0 -153
- package/lib/requests/asset-graph-diff.js +0 -128
- package/lib/requests/asset-graph-dot.js +0 -131
- package/lib/resolveOptions.js +0 -265
- package/lib/serializerCore.browser.js +0 -29
- package/lib/summarizeRequest.js +0 -55
- package/lib/types.js +0 -35
- package/lib/utils.js +0 -160
- package/lib/worker.js +0 -184
package/lib/constants.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.VALID = exports.STARTUP = exports.OPTION_CHANGE = exports.INITIAL_BUILD = exports.HASH_REF_REGEX = exports.HASH_REF_PREFIX = exports.HASH_REF_HASH_LEN = exports.FILE_UPDATE = exports.FILE_DELETE = exports.FILE_CREATE = exports.ERROR = exports.ENV_CHANGE = exports.ATLASPACK_VERSION = void 0;
|
|
7
|
-
var _package = require("../package.json");
|
|
8
|
-
// $FlowFixMe
|
|
9
|
-
const ATLASPACK_VERSION = exports.ATLASPACK_VERSION = _package.version;
|
|
10
|
-
const HASH_REF_PREFIX = exports.HASH_REF_PREFIX = 'HASH_REF_';
|
|
11
|
-
const HASH_REF_HASH_LEN = exports.HASH_REF_HASH_LEN = 16;
|
|
12
|
-
const HASH_REF_REGEX = exports.HASH_REF_REGEX = new RegExp(`${HASH_REF_PREFIX}\\w{${HASH_REF_HASH_LEN}}`, 'g');
|
|
13
|
-
const VALID = exports.VALID = 0;
|
|
14
|
-
const INITIAL_BUILD = exports.INITIAL_BUILD = 1 << 0;
|
|
15
|
-
const FILE_CREATE = exports.FILE_CREATE = 1 << 1;
|
|
16
|
-
const FILE_UPDATE = exports.FILE_UPDATE = 1 << 2;
|
|
17
|
-
const FILE_DELETE = exports.FILE_DELETE = 1 << 3;
|
|
18
|
-
const ENV_CHANGE = exports.ENV_CHANGE = 1 << 4;
|
|
19
|
-
const OPTION_CHANGE = exports.OPTION_CHANGE = 1 << 5;
|
|
20
|
-
const STARTUP = exports.STARTUP = 1 << 6;
|
|
21
|
-
const ERROR = exports.ERROR = 1 << 7;
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = dumpGraphToGraphViz;
|
|
7
|
-
var _BundleGraph = require("./BundleGraph");
|
|
8
|
-
var _RequestTracker = require("./RequestTracker");
|
|
9
|
-
function _path() {
|
|
10
|
-
const data = _interopRequireDefault(require("path"));
|
|
11
|
-
_path = function () {
|
|
12
|
-
return data;
|
|
13
|
-
};
|
|
14
|
-
return data;
|
|
15
|
-
}
|
|
16
|
-
function _graph() {
|
|
17
|
-
const data = require("@atlaspack/graph");
|
|
18
|
-
_graph = function () {
|
|
19
|
-
return data;
|
|
20
|
-
};
|
|
21
|
-
return data;
|
|
22
|
-
}
|
|
23
|
-
var _projectPath = require("./projectPath");
|
|
24
|
-
var _types = require("./types");
|
|
25
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
26
|
-
const COLORS = {
|
|
27
|
-
root: 'gray',
|
|
28
|
-
asset: 'green',
|
|
29
|
-
dependency: 'orange',
|
|
30
|
-
transformer_request: 'cyan',
|
|
31
|
-
file: 'gray',
|
|
32
|
-
default: 'white'
|
|
33
|
-
};
|
|
34
|
-
const TYPE_COLORS = {
|
|
35
|
-
// bundle graph
|
|
36
|
-
bundle: 'blue',
|
|
37
|
-
contains: 'grey',
|
|
38
|
-
internal_async: 'orange',
|
|
39
|
-
references: 'red',
|
|
40
|
-
sibling: 'green',
|
|
41
|
-
// asset graph
|
|
42
|
-
// request graph
|
|
43
|
-
invalidated_by_create: 'green',
|
|
44
|
-
invalidated_by_create_above: 'orange',
|
|
45
|
-
invalidate_by_update: 'cyan',
|
|
46
|
-
invalidated_by_delete: 'red'
|
|
47
|
-
};
|
|
48
|
-
async function dumpGraphToGraphViz(graph, name, edgeTypes) {
|
|
49
|
-
var _globalThis$ATLASPACK;
|
|
50
|
-
if ("production" === 'production' && !process.env.ATLASPACK_BUILD_REPL) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
let mode = process.env.ATLASPACK_BUILD_REPL ? // $FlowFixMe
|
|
54
|
-
(_globalThis$ATLASPACK = globalThis.ATLASPACK_DUMP_GRAPHVIZ) === null || _globalThis$ATLASPACK === void 0 ? void 0 : _globalThis$ATLASPACK.mode : process.env.ATLASPACK_DUMP_GRAPHVIZ;
|
|
55
|
-
|
|
56
|
-
// $FlowFixMe[invalid-compare]
|
|
57
|
-
if (mode == null || mode == false) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
let detailedSymbols = mode === 'symbols';
|
|
61
|
-
let GraphVizGraph = require('graphviz/lib/deps/graph').Graph;
|
|
62
|
-
let g = new GraphVizGraph(null, 'G');
|
|
63
|
-
g.type = 'digraph';
|
|
64
|
-
// $FlowFixMe
|
|
65
|
-
for (let [id, node] of graph.nodes.entries()) {
|
|
66
|
-
if (node == null) continue;
|
|
67
|
-
let n = g.addNode(nodeId(id));
|
|
68
|
-
// $FlowFixMe default is fine. Not every type needs to be in the map.
|
|
69
|
-
n.set('color', COLORS[node.type || 'default']);
|
|
70
|
-
n.set('shape', 'box');
|
|
71
|
-
n.set('style', 'filled');
|
|
72
|
-
let label;
|
|
73
|
-
if (typeof node === 'string') {
|
|
74
|
-
label = node;
|
|
75
|
-
} else if (node.assets) {
|
|
76
|
-
label = `(${nodeId(id)}), (assetIds: ${[...node.assets].map(a => {
|
|
77
|
-
let arr = a.filePath.split('/');
|
|
78
|
-
return arr[arr.length - 1];
|
|
79
|
-
}).join(', ')}) (sourceBundles: ${[...node.sourceBundles].join(', ')}) (bb ${node.bundleBehavior ?? 'none'})`;
|
|
80
|
-
} else if (node.type) {
|
|
81
|
-
label = `[${(0, _graph().fromNodeId)(id)}] ${node.type || 'No Type'}: [${node.id}]: `;
|
|
82
|
-
if (node.type === 'dependency') {
|
|
83
|
-
label += node.value.specifier;
|
|
84
|
-
let parts = [];
|
|
85
|
-
if (node.value.priority !== _types.Priority.sync) {
|
|
86
|
-
var _Object$entries$find;
|
|
87
|
-
parts.push((_Object$entries$find = Object.entries(_types.Priority).find(([, v]) => v === node.value.priority)) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[0]);
|
|
88
|
-
}
|
|
89
|
-
if (node.value.isOptional) parts.push('optional');
|
|
90
|
-
if (node.value.specifierType === _types.SpecifierType.url) parts.push('url');
|
|
91
|
-
if (node.hasDeferred) parts.push('deferred');
|
|
92
|
-
if (node.deferred) parts.push('deferred');
|
|
93
|
-
if (node.excluded) parts.push('excluded');
|
|
94
|
-
if (parts.length) label += ' (' + parts.join(', ') + ')';
|
|
95
|
-
if (node.value.env) label += ` (${getEnvDescription(node.value.env)})`;
|
|
96
|
-
let depSymbols = node.value.symbols;
|
|
97
|
-
if (detailedSymbols) {
|
|
98
|
-
if (depSymbols) {
|
|
99
|
-
if (depSymbols.size) {
|
|
100
|
-
label += '\\nsymbols: ' + [...depSymbols].map(([e, {
|
|
101
|
-
local
|
|
102
|
-
}]) => [e, local]).join(';');
|
|
103
|
-
}
|
|
104
|
-
let weakSymbols = [...depSymbols].filter(([, {
|
|
105
|
-
isWeak
|
|
106
|
-
}]) => isWeak).map(([s]) => s);
|
|
107
|
-
if (weakSymbols.length) {
|
|
108
|
-
label += '\\nweakSymbols: ' + weakSymbols.join(',');
|
|
109
|
-
}
|
|
110
|
-
if (node.usedSymbolsUp.size > 0) {
|
|
111
|
-
label += '\\nusedSymbolsUp: ' + [...node.usedSymbolsUp].map(([s, sAsset]) => sAsset ? `${s}(${sAsset.asset}.${sAsset.symbol ?? ''})` : sAsset === null ? `${s}(external)` : `${s}(ambiguous)`).join(',');
|
|
112
|
-
}
|
|
113
|
-
if (node.usedSymbolsDown.size > 0) {
|
|
114
|
-
label += '\\nusedSymbolsDown: ' + [...node.usedSymbolsDown].join(',');
|
|
115
|
-
}
|
|
116
|
-
// if (node.usedSymbolsDownDirty) label += '\\nusedSymbolsDownDirty';
|
|
117
|
-
// if (node.usedSymbolsUpDirtyDown)
|
|
118
|
-
// label += '\\nusedSymbolsUpDirtyDown';
|
|
119
|
-
// if (node.usedSymbolsUpDirtyUp) label += '\\nusedSymbolsUpDirtyUp';
|
|
120
|
-
} else {
|
|
121
|
-
label += '\\nsymbols: cleared';
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
} else if (node.type === 'asset') {
|
|
125
|
-
label += _path().default.basename((0, _projectPath.fromProjectPathRelative)(node.value.filePath)) + '#' + node.value.type;
|
|
126
|
-
if (detailedSymbols) {
|
|
127
|
-
if (!node.value.symbols) {
|
|
128
|
-
label += '\\nsymbols: cleared';
|
|
129
|
-
} else if (node.value.symbols.size) {
|
|
130
|
-
label += '\\nsymbols: ' + [...node.value.symbols].map(([e, {
|
|
131
|
-
local
|
|
132
|
-
}]) => [e, local]).join(';');
|
|
133
|
-
}
|
|
134
|
-
if (node.usedSymbols.size) {
|
|
135
|
-
label += '\\nusedSymbols: ' + [...node.usedSymbols].join(',');
|
|
136
|
-
}
|
|
137
|
-
// if (node.usedSymbolsDownDirty) label += '\\nusedSymbolsDownDirty';
|
|
138
|
-
// if (node.usedSymbolsUpDirty) label += '\\nusedSymbolsUpDirty';
|
|
139
|
-
} else {
|
|
140
|
-
label += '\\nsymbols: cleared';
|
|
141
|
-
}
|
|
142
|
-
} else if (node.type === 'asset_group') {
|
|
143
|
-
if (node.deferred) label += '(deferred)';
|
|
144
|
-
} else if (node.type === 'file') {
|
|
145
|
-
label += _path().default.basename(node.id);
|
|
146
|
-
} else if (node.type === 'transformer_request') {
|
|
147
|
-
label += _path().default.basename(node.value.filePath) + ` (${getEnvDescription(node.value.env)})`;
|
|
148
|
-
} else if (node.type === 'bundle') {
|
|
149
|
-
let parts = [];
|
|
150
|
-
if (node.value.needsStableName) parts.push('stable name');
|
|
151
|
-
parts.push(node.value.name);
|
|
152
|
-
parts.push('bb:' + (node.value.bundleBehavior ?? 'null'));
|
|
153
|
-
if (node.value.isPlaceholder) parts.push('placeholder');
|
|
154
|
-
if (parts.length) label += ' (' + parts.join(', ') + ')';
|
|
155
|
-
if (node.value.env) label += ` (${getEnvDescription(node.value.env)})`;
|
|
156
|
-
} else if (node.type === 'request') {
|
|
157
|
-
label = node.requestType + ':' + node.id;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
n.set('label', label);
|
|
161
|
-
}
|
|
162
|
-
let edgeNames;
|
|
163
|
-
if (edgeTypes) {
|
|
164
|
-
edgeNames = Object.fromEntries(Object.entries(edgeTypes).map(([k, v]) => [v, k]));
|
|
165
|
-
}
|
|
166
|
-
for (let edge of graph.getAllEdges()) {
|
|
167
|
-
let gEdge = g.addEdge(nodeId(edge.from), nodeId(edge.to));
|
|
168
|
-
let color = null;
|
|
169
|
-
if (edge.type != 1 && edgeNames) {
|
|
170
|
-
color = TYPE_COLORS[edgeNames[edge.type]];
|
|
171
|
-
}
|
|
172
|
-
if (color != null) {
|
|
173
|
-
gEdge.set('color', color);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
if (process.env.ATLASPACK_BUILD_REPL) {
|
|
177
|
-
var _globalThis$ATLASPACK2;
|
|
178
|
-
// $FlowFixMe
|
|
179
|
-
(_globalThis$ATLASPACK2 = globalThis.ATLASPACK_DUMP_GRAPHVIZ) === null || _globalThis$ATLASPACK2 === void 0 || _globalThis$ATLASPACK2.call(globalThis, name, g.to_dot());
|
|
180
|
-
} else {
|
|
181
|
-
const tempy = require('tempy');
|
|
182
|
-
let tmp = tempy.file({
|
|
183
|
-
name: `parcel-${name}.png`
|
|
184
|
-
});
|
|
185
|
-
await g.output('png', tmp);
|
|
186
|
-
// eslint-disable-next-line no-console
|
|
187
|
-
console.log('Dumped', tmp);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
function nodeId(id) {
|
|
191
|
-
// $FlowFixMe
|
|
192
|
-
return `node${id}`;
|
|
193
|
-
}
|
|
194
|
-
function getEnvDescription(env) {
|
|
195
|
-
let description;
|
|
196
|
-
if (typeof env.engines.browsers === 'string') {
|
|
197
|
-
description = `${env.context}: ${env.engines.browsers}`;
|
|
198
|
-
} else if (Array.isArray(env.engines.browsers)) {
|
|
199
|
-
description = `${env.context}: ${env.engines.browsers.join(', ')}`;
|
|
200
|
-
} else if (env.engines.node) {
|
|
201
|
-
description = `node: ${env.engines.node}`;
|
|
202
|
-
} else if (env.engines.electron) {
|
|
203
|
-
description = `electron: ${env.engines.electron}`;
|
|
204
|
-
}
|
|
205
|
-
return description ?? '';
|
|
206
|
-
}
|
package/lib/index.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _exportNames = {
|
|
7
|
-
Atlaspack: true,
|
|
8
|
-
Parcel: true,
|
|
9
|
-
BuildError: true,
|
|
10
|
-
createWorkerFarm: true,
|
|
11
|
-
INTERNAL_RESOLVE: true,
|
|
12
|
-
INTERNAL_TRANSFORM: true
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "Atlaspack", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function () {
|
|
17
|
-
return _Atlaspack.default;
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
Object.defineProperty(exports, "BuildError", {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
get: function () {
|
|
23
|
-
return _Atlaspack.BuildError;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
Object.defineProperty(exports, "INTERNAL_RESOLVE", {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
get: function () {
|
|
29
|
-
return _Atlaspack.INTERNAL_RESOLVE;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
Object.defineProperty(exports, "INTERNAL_TRANSFORM", {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _Atlaspack.INTERNAL_TRANSFORM;
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
Object.defineProperty(exports, "Parcel", {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
get: function () {
|
|
41
|
-
return _Atlaspack.default;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
Object.defineProperty(exports, "createWorkerFarm", {
|
|
45
|
-
enumerable: true,
|
|
46
|
-
get: function () {
|
|
47
|
-
return _Atlaspack.createWorkerFarm;
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
Object.defineProperty(exports, "default", {
|
|
51
|
-
enumerable: true,
|
|
52
|
-
get: function () {
|
|
53
|
-
return _Atlaspack.default;
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
var _Atlaspack = _interopRequireWildcard(require("./Atlaspack"));
|
|
57
|
-
var _atlaspackV = require("./atlaspack-v3");
|
|
58
|
-
Object.keys(_atlaspackV).forEach(function (key) {
|
|
59
|
-
if (key === "default" || key === "__esModule") return;
|
|
60
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
61
|
-
if (key in exports && exports[key] === _atlaspackV[key]) return;
|
|
62
|
-
Object.defineProperty(exports, key, {
|
|
63
|
-
enumerable: true,
|
|
64
|
-
get: function () {
|
|
65
|
-
return _atlaspackV[key];
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
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
|
-
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; }
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = loadPlugin;
|
|
7
|
-
function _path() {
|
|
8
|
-
const data = _interopRequireDefault(require("path"));
|
|
9
|
-
_path = function () {
|
|
10
|
-
return data;
|
|
11
|
-
};
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
|
-
function _nullthrows() {
|
|
15
|
-
const data = _interopRequireDefault(require("nullthrows"));
|
|
16
|
-
_nullthrows = function () {
|
|
17
|
-
return data;
|
|
18
|
-
};
|
|
19
|
-
return data;
|
|
20
|
-
}
|
|
21
|
-
function _diagnostic() {
|
|
22
|
-
const data = _interopRequireWildcard(require("@atlaspack/diagnostic"));
|
|
23
|
-
_diagnostic = function () {
|
|
24
|
-
return data;
|
|
25
|
-
};
|
|
26
|
-
return data;
|
|
27
|
-
}
|
|
28
|
-
function _utils() {
|
|
29
|
-
const data = require("@atlaspack/utils");
|
|
30
|
-
_utils = function () {
|
|
31
|
-
return data;
|
|
32
|
-
};
|
|
33
|
-
return data;
|
|
34
|
-
}
|
|
35
|
-
var _projectPath = require("./projectPath");
|
|
36
|
-
var _package = require("../package.json");
|
|
37
|
-
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
|
-
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
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
40
|
-
const NODE_MODULES = `${_path().default.sep}node_modules${_path().default.sep}`;
|
|
41
|
-
const CONFIG = Symbol.for('parcel-plugin-config');
|
|
42
|
-
async function loadPlugin(pluginName, configPath, keyPath, options) {
|
|
43
|
-
let resolveFrom = configPath;
|
|
44
|
-
if (resolveFrom.includes(NODE_MODULES)) {
|
|
45
|
-
var _configPkg$config$dep;
|
|
46
|
-
// Config packages can reference plugins, but cannot contain other plugins within them.
|
|
47
|
-
// This forces every published plugin to be published separately so they can be mixed and matched if needed.
|
|
48
|
-
if (pluginName.startsWith('.')) {
|
|
49
|
-
let configContents = await options.inputFS.readFile(configPath, 'utf8');
|
|
50
|
-
throw new (_diagnostic().default)({
|
|
51
|
-
diagnostic: {
|
|
52
|
-
message: (0, _diagnostic().md)`Local plugins are not supported in Atlaspack config packages. Please publish "${pluginName}" as a separate npm package.`,
|
|
53
|
-
origin: '@atlaspack/core',
|
|
54
|
-
codeFrames: keyPath ? [{
|
|
55
|
-
filePath: configPath,
|
|
56
|
-
language: 'json5',
|
|
57
|
-
code: configContents,
|
|
58
|
-
codeHighlights: (0, _diagnostic().generateJSONCodeHighlights)(configContents, [{
|
|
59
|
-
key: keyPath,
|
|
60
|
-
type: 'value'
|
|
61
|
-
}])
|
|
62
|
-
}] : undefined
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
let configPkg = await (0, _utils().loadConfig)(options.inputFS, resolveFrom, ['package.json'], options.projectRoot);
|
|
67
|
-
if (configPkg != null && ((_configPkg$config$dep = configPkg.config.dependencies) === null || _configPkg$config$dep === void 0 ? void 0 : _configPkg$config$dep[pluginName]) == null) {
|
|
68
|
-
let contents = await options.inputFS.readFile(configPkg.files[0].filePath, 'utf8');
|
|
69
|
-
throw new (_diagnostic().default)({
|
|
70
|
-
diagnostic: {
|
|
71
|
-
message: (0, _diagnostic().md)`Could not determine version of ${pluginName} in ${_path().default.relative(process.cwd(), resolveFrom)}. Include it in "dependencies".`,
|
|
72
|
-
origin: '@atlaspack/core',
|
|
73
|
-
codeFrames: configPkg.config.dependencies ? [{
|
|
74
|
-
filePath: configPkg.files[0].filePath,
|
|
75
|
-
language: 'json5',
|
|
76
|
-
code: contents,
|
|
77
|
-
codeHighlights: (0, _diagnostic().generateJSONCodeHighlights)(contents, [{
|
|
78
|
-
key: '/dependencies',
|
|
79
|
-
type: 'key'
|
|
80
|
-
}])
|
|
81
|
-
}] : undefined
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
let resolved, pkg;
|
|
87
|
-
try {
|
|
88
|
-
({
|
|
89
|
-
resolved,
|
|
90
|
-
pkg
|
|
91
|
-
} = await options.packageManager.resolve(pluginName, resolveFrom, {
|
|
92
|
-
shouldAutoInstall: options.shouldAutoInstall
|
|
93
|
-
}));
|
|
94
|
-
} catch (err) {
|
|
95
|
-
if (err.code !== 'MODULE_NOT_FOUND') {
|
|
96
|
-
throw err;
|
|
97
|
-
}
|
|
98
|
-
let configContents = await options.inputFS.readFile(configPath, 'utf8');
|
|
99
|
-
let alternatives = await (0, _utils().findAlternativeNodeModules)(options.inputFS, pluginName, _path().default.dirname(resolveFrom));
|
|
100
|
-
throw new (_diagnostic().default)({
|
|
101
|
-
diagnostic: {
|
|
102
|
-
message: (0, _diagnostic().md)`Cannot find Atlaspack plugin "${pluginName}"`,
|
|
103
|
-
origin: '@atlaspack/core',
|
|
104
|
-
codeFrames: keyPath ? [{
|
|
105
|
-
filePath: configPath,
|
|
106
|
-
language: 'json5',
|
|
107
|
-
code: configContents,
|
|
108
|
-
codeHighlights: (0, _diagnostic().generateJSONCodeHighlights)(configContents, [{
|
|
109
|
-
key: keyPath,
|
|
110
|
-
type: 'value',
|
|
111
|
-
message: (0, _diagnostic().md)`Cannot find module "${pluginName}"${alternatives[0] ? `, did you mean "${alternatives[0]}"?` : ''}`
|
|
112
|
-
}])
|
|
113
|
-
}] : undefined
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// Remove plugin version compatiblility validation in canary builds as they don't use semver
|
|
119
|
-
|
|
120
|
-
let plugin = await options.packageManager.require(pluginName, resolveFrom, {
|
|
121
|
-
shouldAutoInstall: options.shouldAutoInstall
|
|
122
|
-
});
|
|
123
|
-
plugin = plugin.default ? plugin.default : plugin;
|
|
124
|
-
if (!plugin) {
|
|
125
|
-
throw new Error(`Plugin ${pluginName} has no exports.`);
|
|
126
|
-
}
|
|
127
|
-
plugin = plugin[CONFIG];
|
|
128
|
-
if (!plugin) {
|
|
129
|
-
throw new Error(`Plugin ${pluginName} is not a valid Atlaspack plugin, should export an instance of a Atlaspack plugin ex. "export default new Reporter({ ... })".`);
|
|
130
|
-
}
|
|
131
|
-
return {
|
|
132
|
-
plugin,
|
|
133
|
-
version: (0, _nullthrows().default)(pkg).version,
|
|
134
|
-
resolveFrom: (0, _projectPath.toProjectPath)(options.projectRoot, resolveFrom)
|
|
135
|
-
};
|
|
136
|
-
}
|
package/lib/loadDotEnv.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = loadEnv;
|
|
7
|
-
function _utils() {
|
|
8
|
-
const data = require("@atlaspack/utils");
|
|
9
|
-
_utils = function () {
|
|
10
|
-
return data;
|
|
11
|
-
};
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
|
-
function _dotenv() {
|
|
15
|
-
const data = _interopRequireDefault(require("dotenv"));
|
|
16
|
-
_dotenv = function () {
|
|
17
|
-
return data;
|
|
18
|
-
};
|
|
19
|
-
return data;
|
|
20
|
-
}
|
|
21
|
-
function _dotenvExpand() {
|
|
22
|
-
const data = _interopRequireDefault(require("dotenv-expand"));
|
|
23
|
-
_dotenvExpand = function () {
|
|
24
|
-
return data;
|
|
25
|
-
};
|
|
26
|
-
return data;
|
|
27
|
-
}
|
|
28
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
|
-
async function loadEnv(env, fs, filePath, projectRoot) {
|
|
30
|
-
const NODE_ENV = env.NODE_ENV ?? 'development';
|
|
31
|
-
const dotenvFiles = ['.env',
|
|
32
|
-
// Don't include `.env.local` for `test` environment
|
|
33
|
-
// since normally you expect tests to produce the same
|
|
34
|
-
// results for everyone
|
|
35
|
-
NODE_ENV === 'test' ? null : '.env.local', `.env.${NODE_ENV}`, `.env.${NODE_ENV}.local`].filter(Boolean);
|
|
36
|
-
let envs = await Promise.all(dotenvFiles.map(async dotenvFile => {
|
|
37
|
-
const envPath = await (0, _utils().resolveConfig)(fs, filePath, [dotenvFile], projectRoot);
|
|
38
|
-
if (envPath == null) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// `ignoreProcessEnv` prevents dotenv-expand from writing values into `process.env`:
|
|
43
|
-
// https://github.com/motdotla/dotenv-expand/blob/ddb73d02322fe8522b4e05b73e1c1ad24ea7c14a/lib/main.js#L5
|
|
44
|
-
let output = (0, _dotenvExpand().default)({
|
|
45
|
-
parsed: _dotenv().default.parse(await fs.readFile(envPath)),
|
|
46
|
-
ignoreProcessEnv: true
|
|
47
|
-
});
|
|
48
|
-
if (output.error != null) {
|
|
49
|
-
throw output.error;
|
|
50
|
-
}
|
|
51
|
-
return output.parsed;
|
|
52
|
-
}));
|
|
53
|
-
return Object.assign({}, ...envs);
|
|
54
|
-
}
|
package/lib/projectPath.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.fromProjectPath = void 0;
|
|
7
|
-
exports.fromProjectPathRelative = fromProjectPathRelative;
|
|
8
|
-
exports.joinProjectPath = joinProjectPath;
|
|
9
|
-
exports.toProjectPath = void 0;
|
|
10
|
-
exports.toProjectPathUnsafe = toProjectPathUnsafe;
|
|
11
|
-
function _path() {
|
|
12
|
-
const data = _interopRequireDefault(require("path"));
|
|
13
|
-
_path = function () {
|
|
14
|
-
return data;
|
|
15
|
-
};
|
|
16
|
-
return data;
|
|
17
|
-
}
|
|
18
|
-
function _utils() {
|
|
19
|
-
const data = require("@atlaspack/utils");
|
|
20
|
-
_utils = function () {
|
|
21
|
-
return data;
|
|
22
|
-
};
|
|
23
|
-
return data;
|
|
24
|
-
}
|
|
25
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
26
|
-
/**
|
|
27
|
-
* A path that's relative to the project root.
|
|
28
|
-
*/
|
|
29
|
-
function toProjectPath_(projectRoot, p) {
|
|
30
|
-
// If the file path is not provided, then treat it as though it is already from the project root
|
|
31
|
-
if (p == null) {
|
|
32
|
-
return p;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// If the file path is already relative and it does not begin with . then treat the path as if it
|
|
36
|
-
// is already from the project root. This prevents relative paths from being processed twice,
|
|
37
|
-
// most often within `toInternalSourceLocation` when handling loc types from symbols and asset
|
|
38
|
-
// dependencies.
|
|
39
|
-
if (p[0] !== '.' && !_path().default.isAbsolute(p)) {
|
|
40
|
-
return p;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// If the file is outside the project root, store an absolute path rather than a relative one.
|
|
44
|
-
// This way if the project root is moved, the file references still work. Accessing files outside
|
|
45
|
-
// the project root is not portable anyway.
|
|
46
|
-
let relative = (0, _utils().relativePath)(projectRoot, p, false);
|
|
47
|
-
if (relative.startsWith('..')) {
|
|
48
|
-
return process.platform === 'win32' ? (0, _utils().normalizeSeparators)(p) : p;
|
|
49
|
-
}
|
|
50
|
-
return relative;
|
|
51
|
-
}
|
|
52
|
-
const toProjectPath = exports.toProjectPath = toProjectPath_;
|
|
53
|
-
function fromProjectPath_(projectRoot, p) {
|
|
54
|
-
if (p == null) {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Project paths use normalized unix separators, so we only need to
|
|
59
|
-
// convert them on Windows.
|
|
60
|
-
let projectPath = process.platform === 'win32' ? _path().default.normalize(p) : p;
|
|
61
|
-
|
|
62
|
-
// If the path is absolute (e.g. outside the project root), just return it.
|
|
63
|
-
if (_path().default.isAbsolute(projectPath)) {
|
|
64
|
-
return projectPath;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Add separator if needed. Doing this manunally is much faster than path.join.
|
|
68
|
-
if (projectRoot[projectRoot.length - 1] !== _path().default.sep) {
|
|
69
|
-
return projectRoot + _path().default.sep + projectPath;
|
|
70
|
-
}
|
|
71
|
-
return projectRoot + projectPath;
|
|
72
|
-
}
|
|
73
|
-
const fromProjectPath = exports.fromProjectPath = fromProjectPath_;
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Returns a path relative to the project root. This should be used when computing cache keys
|
|
77
|
-
*/
|
|
78
|
-
function fromProjectPathRelative(p) {
|
|
79
|
-
return p;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* This function should be avoided, it doesn't change the actual value.
|
|
84
|
-
*/
|
|
85
|
-
function toProjectPathUnsafe(p) {
|
|
86
|
-
return p;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Joins a project root with relative paths (similar to `path.join`)
|
|
91
|
-
*/
|
|
92
|
-
function joinProjectPath(a, ...b) {
|
|
93
|
-
return _path().default.posix.join(a, ...b);
|
|
94
|
-
}
|