@atlaspack/core 2.13.2-dev.3689 → 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.
Files changed (85) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/package.json +20 -20
  3. package/src/Atlaspack.js +3 -2
  4. package/src/atlaspack-v3/AtlaspackV3.js +25 -9
  5. package/src/requests/WriteBundlesRequest.js +31 -22
  6. package/LICENSE +0 -201
  7. package/lib/AssetGraph.js +0 -521
  8. package/lib/Atlaspack.js +0 -676
  9. package/lib/AtlaspackConfig.js +0 -298
  10. package/lib/AtlaspackConfig.schema.js +0 -103
  11. package/lib/BundleGraph.js +0 -1527
  12. package/lib/CommittedAsset.js +0 -155
  13. package/lib/Dependency.js +0 -136
  14. package/lib/Environment.js +0 -144
  15. package/lib/IdentifierRegistry.js +0 -36
  16. package/lib/InternalConfig.js +0 -56
  17. package/lib/PackagerRunner.js +0 -525
  18. package/lib/ReporterRunner.js +0 -151
  19. package/lib/RequestTracker.js +0 -1178
  20. package/lib/SymbolPropagation.js +0 -618
  21. package/lib/TargetDescriptor.schema.js +0 -118
  22. package/lib/Transformation.js +0 -522
  23. package/lib/UncommittedAsset.js +0 -348
  24. package/lib/Validation.js +0 -203
  25. package/lib/applyRuntimes.js +0 -355
  26. package/lib/assetUtils.js +0 -205
  27. package/lib/atlaspack-v3/AtlaspackV3.js +0 -57
  28. package/lib/atlaspack-v3/NapiWorkerPool.js +0 -71
  29. package/lib/atlaspack-v3/fs.js +0 -39
  30. package/lib/atlaspack-v3/index.js +0 -26
  31. package/lib/atlaspack-v3/jsCallable.js +0 -20
  32. package/lib/atlaspack-v3/worker/compat/asset-symbols.js +0 -197
  33. package/lib/atlaspack-v3/worker/compat/bitflags.js +0 -84
  34. package/lib/atlaspack-v3/worker/compat/dependency.js +0 -44
  35. package/lib/atlaspack-v3/worker/compat/environment.js +0 -57
  36. package/lib/atlaspack-v3/worker/compat/index.js +0 -104
  37. package/lib/atlaspack-v3/worker/compat/mutable-asset.js +0 -164
  38. package/lib/atlaspack-v3/worker/compat/plugin-config.js +0 -78
  39. package/lib/atlaspack-v3/worker/compat/plugin-logger.js +0 -29
  40. package/lib/atlaspack-v3/worker/compat/plugin-options.js +0 -113
  41. package/lib/atlaspack-v3/worker/compat/plugin-tracer.js +0 -12
  42. package/lib/atlaspack-v3/worker/compat/target.js +0 -17
  43. package/lib/atlaspack-v3/worker/index.js +0 -3
  44. package/lib/atlaspack-v3/worker/worker.js +0 -280
  45. package/lib/constants.js +0 -21
  46. package/lib/dumpGraphToGraphViz.js +0 -206
  47. package/lib/index.js +0 -70
  48. package/lib/loadAtlaspackPlugin.js +0 -115
  49. package/lib/loadDotEnv.js +0 -54
  50. package/lib/projectPath.js +0 -112
  51. package/lib/public/Asset.js +0 -259
  52. package/lib/public/Bundle.js +0 -236
  53. package/lib/public/BundleGraph.js +0 -279
  54. package/lib/public/BundleGroup.js +0 -50
  55. package/lib/public/Config.js +0 -202
  56. package/lib/public/Dependency.js +0 -131
  57. package/lib/public/Environment.js +0 -247
  58. package/lib/public/MutableBundleGraph.js +0 -204
  59. package/lib/public/PluginOptions.js +0 -71
  60. package/lib/public/Symbols.js +0 -247
  61. package/lib/public/Target.js +0 -64
  62. package/lib/registerCoreWithSerializer.js +0 -51
  63. package/lib/requests/AssetGraphRequest.js +0 -432
  64. package/lib/requests/AssetGraphRequestRust.js +0 -220
  65. package/lib/requests/AssetRequest.js +0 -132
  66. package/lib/requests/AtlaspackBuildRequest.js +0 -79
  67. package/lib/requests/AtlaspackConfigRequest.js +0 -479
  68. package/lib/requests/BundleGraphRequest.js +0 -485
  69. package/lib/requests/ConfigRequest.js +0 -203
  70. package/lib/requests/DevDepRequest.js +0 -193
  71. package/lib/requests/EntryRequest.js +0 -295
  72. package/lib/requests/PackageRequest.js +0 -88
  73. package/lib/requests/PathRequest.js +0 -357
  74. package/lib/requests/TargetRequest.js +0 -1179
  75. package/lib/requests/ValidationRequest.js +0 -66
  76. package/lib/requests/WriteBundleRequest.js +0 -252
  77. package/lib/requests/WriteBundlesRequest.js +0 -153
  78. package/lib/requests/asset-graph-diff.js +0 -128
  79. package/lib/requests/asset-graph-dot.js +0 -131
  80. package/lib/resolveOptions.js +0 -265
  81. package/lib/serializerCore.browser.js +0 -29
  82. package/lib/summarizeRequest.js +0 -55
  83. package/lib/types.js +0 -35
  84. package/lib/utils.js +0 -160
  85. 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,115 +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
-
45
- // Config packages can reference plugins, but cannot contain other plugins within them.
46
- // This forces every published plugin to be published separately so they can be mixed and matched if needed.
47
- if (resolveFrom.includes(NODE_MODULES) && pluginName.startsWith('.')) {
48
- let configContents = await options.inputFS.readFile(configPath, 'utf8');
49
- throw new (_diagnostic().default)({
50
- diagnostic: {
51
- message: (0, _diagnostic().md)`Local plugins are not supported in Atlaspack config packages. Please publish "${pluginName}" as a separate npm package.`,
52
- origin: '@atlaspack/core',
53
- codeFrames: keyPath ? [{
54
- filePath: configPath,
55
- language: 'json5',
56
- code: configContents,
57
- codeHighlights: (0, _diagnostic().generateJSONCodeHighlights)(configContents, [{
58
- key: keyPath,
59
- type: 'value'
60
- }])
61
- }] : undefined
62
- }
63
- });
64
- }
65
- let resolved, pkg;
66
- try {
67
- ({
68
- resolved,
69
- pkg
70
- } = await options.packageManager.resolve(pluginName, resolveFrom, {
71
- shouldAutoInstall: options.shouldAutoInstall
72
- }));
73
- } catch (err) {
74
- if (err.code !== 'MODULE_NOT_FOUND') {
75
- throw err;
76
- }
77
- let configContents = await options.inputFS.readFile(configPath, 'utf8');
78
- let alternatives = await (0, _utils().findAlternativeNodeModules)(options.inputFS, pluginName, _path().default.dirname(resolveFrom));
79
- throw new (_diagnostic().default)({
80
- diagnostic: {
81
- message: (0, _diagnostic().md)`Cannot find Atlaspack plugin "${pluginName}"`,
82
- origin: '@atlaspack/core',
83
- codeFrames: keyPath ? [{
84
- filePath: configPath,
85
- language: 'json5',
86
- code: configContents,
87
- codeHighlights: (0, _diagnostic().generateJSONCodeHighlights)(configContents, [{
88
- key: keyPath,
89
- type: 'value',
90
- message: (0, _diagnostic().md)`Cannot find module "${pluginName}"${alternatives[0] ? `, did you mean "${alternatives[0]}"?` : ''}`
91
- }])
92
- }] : undefined
93
- }
94
- });
95
- }
96
-
97
- // Remove plugin version compatiblility validation in canary builds as they don't use semver
98
-
99
- let plugin = await options.packageManager.require(pluginName, resolveFrom, {
100
- shouldAutoInstall: options.shouldAutoInstall
101
- });
102
- plugin = plugin.default ? plugin.default : plugin;
103
- if (!plugin) {
104
- throw new Error(`Plugin ${pluginName} has no exports.`);
105
- }
106
- plugin = plugin[CONFIG];
107
- if (!plugin) {
108
- throw new Error(`Plugin ${pluginName} is not a valid Atlaspack plugin, should export an instance of a Atlaspack plugin ex. "export default new Reporter({ ... })".`);
109
- }
110
- return {
111
- plugin,
112
- version: (0, _nullthrows().default)(pkg).version,
113
- resolveFrom: (0, _projectPath.toProjectPath)(options.projectRoot, resolveFrom)
114
- };
115
- }
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
- }
@@ -1,112 +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 _featureFlags() {
26
- const data = require("@atlaspack/feature-flags");
27
- _featureFlags = function () {
28
- return data;
29
- };
30
- return data;
31
- }
32
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
- /**
34
- * A path that's relative to the project root.
35
- */
36
- /**
37
- * Converts a file path to a project-relative path.
38
- *
39
- * @param projectRoot - The project root.
40
- * @param p - The file path to convert.
41
- * @returns The project path.
42
- */
43
- function toProjectPath_(projectRoot, p) {
44
- // If the file path is not provided, then treat it as though it is already from the project root
45
- if (p == null) {
46
- return p;
47
- }
48
-
49
- // If the file path is already relative and it does not begin with '.', then treat the path as if it
50
- // is already from the project root. This prevents relative paths from being processed twice,
51
- // most often within `toInternalSourceLocation` when handling loc types from symbols and asset
52
- // dependencies.
53
- if (p[0] !== '.' && !_path().default.isAbsolute(p)) {
54
- return p;
55
- }
56
-
57
- // If the file is outside the project root, store an absolute path rather than a relative one.
58
- // This way if the project root is moved, the file references still work. Accessing files outside
59
- // the project root is not portable anyway.
60
- let relative = (0, _utils().relativePath)(projectRoot, p, false);
61
- if (relative.startsWith('..')) {
62
- // e.g given projectRoot = '/Users/monorepo/project' and p = '/Users/monorepo/other-project/src/index.js' --> relative = '../other-project/src/index.js'
63
- if ((0, _featureFlags().getFeatureFlagValue)('patchProjectPaths')) {
64
- return relative;
65
- }
66
- return process.platform === 'win32' ? (0, _utils().normalizeSeparators)(p) : p;
67
- }
68
- return relative;
69
- }
70
- const toProjectPath = exports.toProjectPath = toProjectPath_;
71
- function fromProjectPath_(projectRoot, p) {
72
- if (p == null) {
73
- return null;
74
- }
75
-
76
- // Project paths use normalized unix separators, so we only need to
77
- // convert them on Windows.
78
- let projectPath = process.platform === 'win32' ? _path().default.normalize(p) : p;
79
-
80
- // If the path is absolute (e.g. outside the project root), just return it.
81
- if (_path().default.isAbsolute(projectPath)) {
82
- return projectPath;
83
- }
84
-
85
- // Add separator if needed. Doing this manunally is much faster than path.join.
86
- if (projectRoot[projectRoot.length - 1] !== _path().default.sep) {
87
- return projectRoot + _path().default.sep + projectPath;
88
- }
89
- return projectRoot + projectPath;
90
- }
91
- const fromProjectPath = exports.fromProjectPath = fromProjectPath_;
92
-
93
- /**
94
- * Returns a path relative to the project root. This should be used when computing cache keys
95
- */
96
- function fromProjectPathRelative(p) {
97
- return p;
98
- }
99
-
100
- /**
101
- * This function should be avoided, it doesn't change the actual value.
102
- */
103
- function toProjectPathUnsafe(p) {
104
- return p;
105
- }
106
-
107
- /**
108
- * Joins a project root with relative paths (similar to `path.join`)
109
- */
110
- function joinProjectPath(a, ...b) {
111
- return _path().default.posix.join(a, ...b);
112
- }