@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.
Files changed (87) 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 +24 -8
  5. package/src/loadAtlaspackPlugin.js +26 -71
  6. package/src/projectPath.js +14 -1
  7. package/src/requests/WriteBundlesRequest.js +31 -22
  8. package/LICENSE +0 -201
  9. package/lib/AssetGraph.js +0 -521
  10. package/lib/Atlaspack.js +0 -676
  11. package/lib/AtlaspackConfig.js +0 -298
  12. package/lib/AtlaspackConfig.schema.js +0 -103
  13. package/lib/BundleGraph.js +0 -1527
  14. package/lib/CommittedAsset.js +0 -155
  15. package/lib/Dependency.js +0 -136
  16. package/lib/Environment.js +0 -144
  17. package/lib/IdentifierRegistry.js +0 -36
  18. package/lib/InternalConfig.js +0 -56
  19. package/lib/PackagerRunner.js +0 -525
  20. package/lib/ReporterRunner.js +0 -151
  21. package/lib/RequestTracker.js +0 -1178
  22. package/lib/SymbolPropagation.js +0 -618
  23. package/lib/TargetDescriptor.schema.js +0 -118
  24. package/lib/Transformation.js +0 -522
  25. package/lib/UncommittedAsset.js +0 -348
  26. package/lib/Validation.js +0 -203
  27. package/lib/applyRuntimes.js +0 -355
  28. package/lib/assetUtils.js +0 -205
  29. package/lib/atlaspack-v3/AtlaspackV3.js +0 -57
  30. package/lib/atlaspack-v3/NapiWorkerPool.js +0 -71
  31. package/lib/atlaspack-v3/fs.js +0 -39
  32. package/lib/atlaspack-v3/index.js +0 -26
  33. package/lib/atlaspack-v3/jsCallable.js +0 -20
  34. package/lib/atlaspack-v3/worker/compat/asset-symbols.js +0 -197
  35. package/lib/atlaspack-v3/worker/compat/bitflags.js +0 -84
  36. package/lib/atlaspack-v3/worker/compat/dependency.js +0 -44
  37. package/lib/atlaspack-v3/worker/compat/environment.js +0 -57
  38. package/lib/atlaspack-v3/worker/compat/index.js +0 -104
  39. package/lib/atlaspack-v3/worker/compat/mutable-asset.js +0 -164
  40. package/lib/atlaspack-v3/worker/compat/plugin-config.js +0 -78
  41. package/lib/atlaspack-v3/worker/compat/plugin-logger.js +0 -29
  42. package/lib/atlaspack-v3/worker/compat/plugin-options.js +0 -113
  43. package/lib/atlaspack-v3/worker/compat/plugin-tracer.js +0 -12
  44. package/lib/atlaspack-v3/worker/compat/target.js +0 -17
  45. package/lib/atlaspack-v3/worker/index.js +0 -3
  46. package/lib/atlaspack-v3/worker/worker.js +0 -280
  47. package/lib/constants.js +0 -21
  48. package/lib/dumpGraphToGraphViz.js +0 -206
  49. package/lib/index.js +0 -70
  50. package/lib/loadAtlaspackPlugin.js +0 -136
  51. package/lib/loadDotEnv.js +0 -54
  52. package/lib/projectPath.js +0 -94
  53. package/lib/public/Asset.js +0 -259
  54. package/lib/public/Bundle.js +0 -236
  55. package/lib/public/BundleGraph.js +0 -279
  56. package/lib/public/BundleGroup.js +0 -50
  57. package/lib/public/Config.js +0 -202
  58. package/lib/public/Dependency.js +0 -131
  59. package/lib/public/Environment.js +0 -247
  60. package/lib/public/MutableBundleGraph.js +0 -204
  61. package/lib/public/PluginOptions.js +0 -71
  62. package/lib/public/Symbols.js +0 -247
  63. package/lib/public/Target.js +0 -64
  64. package/lib/registerCoreWithSerializer.js +0 -51
  65. package/lib/requests/AssetGraphRequest.js +0 -432
  66. package/lib/requests/AssetGraphRequestRust.js +0 -220
  67. package/lib/requests/AssetRequest.js +0 -132
  68. package/lib/requests/AtlaspackBuildRequest.js +0 -79
  69. package/lib/requests/AtlaspackConfigRequest.js +0 -479
  70. package/lib/requests/BundleGraphRequest.js +0 -485
  71. package/lib/requests/ConfigRequest.js +0 -203
  72. package/lib/requests/DevDepRequest.js +0 -193
  73. package/lib/requests/EntryRequest.js +0 -295
  74. package/lib/requests/PackageRequest.js +0 -88
  75. package/lib/requests/PathRequest.js +0 -357
  76. package/lib/requests/TargetRequest.js +0 -1179
  77. package/lib/requests/ValidationRequest.js +0 -66
  78. package/lib/requests/WriteBundleRequest.js +0 -252
  79. package/lib/requests/WriteBundlesRequest.js +0 -153
  80. package/lib/requests/asset-graph-diff.js +0 -128
  81. package/lib/requests/asset-graph-dot.js +0 -131
  82. package/lib/resolveOptions.js +0 -265
  83. package/lib/serializerCore.browser.js +0 -29
  84. package/lib/summarizeRequest.js +0 -55
  85. package/lib/types.js +0 -35
  86. package/lib/utils.js +0 -160
  87. package/lib/worker.js +0 -184
@@ -1,298 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.AtlaspackConfig = void 0;
7
- function _diagnostic() {
8
- const data = _interopRequireWildcard(require("@atlaspack/diagnostic"));
9
- _diagnostic = function () {
10
- return data;
11
- };
12
- return data;
13
- }
14
- function _json() {
15
- const data = _interopRequireDefault(require("json5"));
16
- _json = function () {
17
- return data;
18
- };
19
- return data;
20
- }
21
- function _utils() {
22
- const data = require("@atlaspack/utils");
23
- _utils = function () {
24
- return data;
25
- };
26
- return data;
27
- }
28
- function _path() {
29
- const data = require("path");
30
- _path = function () {
31
- return data;
32
- };
33
- return data;
34
- }
35
- var _loadAtlaspackPlugin = _interopRequireDefault(require("./loadAtlaspackPlugin"));
36
- var _projectPath = require("./projectPath");
37
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }
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; }
40
- class AtlaspackConfig {
41
- constructor(config, options) {
42
- this.options = options;
43
- this.filePath = config.filePath;
44
- this.resolvers = config.resolvers || [];
45
- this.transformers = config.transformers || {};
46
- this.runtimes = config.runtimes || [];
47
- this.bundler = config.bundler;
48
- this.namers = config.namers || [];
49
- this.packagers = config.packagers || {};
50
- this.optimizers = config.optimizers || {};
51
- this.compressors = config.compressors || {};
52
- this.reporters = config.reporters || [];
53
- this.validators = config.validators || {};
54
- this.pluginCache = new Map();
55
- this.regexCache = new Map();
56
- }
57
- static deserialize(serialized) {
58
- return new AtlaspackConfig(serialized.config, serialized.options);
59
- }
60
- getConfig() {
61
- return {
62
- filePath: this.filePath,
63
- resolvers: this.resolvers,
64
- transformers: this.transformers,
65
- validators: this.validators,
66
- runtimes: this.runtimes,
67
- bundler: this.bundler,
68
- namers: this.namers,
69
- packagers: this.packagers,
70
- optimizers: this.optimizers,
71
- compressors: this.compressors,
72
- reporters: this.reporters
73
- };
74
- }
75
- serialize() {
76
- return {
77
- $$raw: false,
78
- config: this.getConfig(),
79
- options: this.options
80
- };
81
- }
82
- _loadPlugin(node) {
83
- let plugin = this.pluginCache.get(node.packageName);
84
- if (plugin) {
85
- return plugin;
86
- }
87
- plugin = (0, _loadAtlaspackPlugin.default)(node.packageName, (0, _projectPath.fromProjectPath)(this.options.projectRoot, node.resolveFrom), node.keyPath, this.options);
88
- this.pluginCache.set(node.packageName, plugin);
89
- return plugin;
90
- }
91
- async loadPlugin(node) {
92
- let plugin = await this._loadPlugin(node);
93
- return {
94
- ...plugin,
95
- name: node.packageName,
96
- keyPath: node.keyPath
97
- };
98
- }
99
- invalidatePlugin(packageName) {
100
- this.pluginCache.delete(packageName);
101
- }
102
- loadPlugins(plugins) {
103
- return Promise.all(plugins.map(p => this.loadPlugin(p)));
104
- }
105
- async getResolvers() {
106
- if (this.resolvers.length === 0) {
107
- throw await this.missingPluginError(this.resolvers, 'No resolver plugins specified in .parcelrc config', '/resolvers');
108
- }
109
- return this.loadPlugins(this.resolvers);
110
- }
111
- _getValidatorNodes(filePath) {
112
- let validators = this.matchGlobMapPipelines(filePath, this.validators) || [];
113
- return validators;
114
- }
115
- getValidatorNames(filePath) {
116
- let validators = this._getValidatorNodes(filePath);
117
- return validators.map(v => v.packageName);
118
- }
119
- getValidators(filePath) {
120
- let validators = this._getValidatorNodes(filePath);
121
- return this.loadPlugins(validators);
122
- }
123
- getNamedPipelines() {
124
- return Object.keys(this.transformers).filter(glob => glob.includes(':')).map(glob => glob.split(':')[0]);
125
- }
126
- async getTransformers(filePath, pipeline, allowEmpty) {
127
- let transformers = this.matchGlobMapPipelines(filePath, this.transformers, pipeline);
128
- if (!transformers || transformers.length === 0) {
129
- if (allowEmpty) {
130
- return [];
131
- }
132
- throw await this.missingPluginError(this.transformers, (0, _diagnostic().md)`No transformers found for __${(0, _projectPath.fromProjectPathRelative)(filePath)}__` + (pipeline != null ? ` with pipeline: '${pipeline}'` : '') + '.', '/transformers');
133
- }
134
- return this.loadPlugins(transformers);
135
- }
136
- async getBundler() {
137
- if (!this.bundler) {
138
- throw await this.missingPluginError([], 'No bundler specified in .parcelrc config', '/bundler');
139
- }
140
- return this.loadPlugin(this.bundler);
141
- }
142
- async getNamers() {
143
- if (this.namers.length === 0) {
144
- throw await this.missingPluginError(this.namers, 'No namer plugins specified in .parcelrc config', '/namers');
145
- }
146
- return this.loadPlugins(this.namers);
147
- }
148
- getRuntimes() {
149
- if (!this.runtimes) {
150
- return Promise.resolve([]);
151
- }
152
- return this.loadPlugins(this.runtimes);
153
- }
154
- async getPackager(filePath) {
155
- let packager = this.matchGlobMap((0, _projectPath.toProjectPathUnsafe)(filePath), this.packagers);
156
- if (!packager) {
157
- throw await this.missingPluginError(this.packagers, (0, _diagnostic().md)`No packager found for __${filePath}__.`, '/packagers');
158
- }
159
- return this.loadPlugin(packager);
160
- }
161
- _getOptimizerNodes(filePath, pipeline) {
162
- // If a pipeline is specified, but it doesn't exist in the optimizers config, ignore it.
163
- // Pipelines for bundles come from their entry assets, so the pipeline likely exists in transformers.
164
- if (pipeline) {
165
- let prefix = pipeline + ':';
166
- if (!Object.keys(this.optimizers).some(glob => glob.startsWith(prefix))) {
167
- pipeline = null;
168
- }
169
- }
170
- return this.matchGlobMapPipelines((0, _projectPath.toProjectPathUnsafe)(filePath), this.optimizers, pipeline) ?? [];
171
- }
172
- getOptimizerNames(filePath, pipeline) {
173
- let optimizers = this._getOptimizerNodes(filePath, pipeline);
174
- return optimizers.map(o => o.packageName);
175
- }
176
- getOptimizers(filePath, pipeline) {
177
- let optimizers = this._getOptimizerNodes(filePath, pipeline);
178
- if (optimizers.length === 0) {
179
- return Promise.resolve([]);
180
- }
181
- return this.loadPlugins(optimizers);
182
- }
183
- async getCompressors(filePath) {
184
- let compressors = this.matchGlobMapPipelines((0, _projectPath.toProjectPathUnsafe)(filePath), this.compressors) ?? [];
185
- if (compressors.length === 0) {
186
- throw await this.missingPluginError(this.compressors, (0, _diagnostic().md)`No compressors found for __${filePath}__.`, '/compressors');
187
- }
188
- return this.loadPlugins(compressors);
189
- }
190
- getReporters() {
191
- return this.loadPlugins(this.reporters);
192
- }
193
- isGlobMatch(projectPath, pattern, pipeline) {
194
- // glob's shouldn't be dependant on absolute paths anyway
195
- let filePath = (0, _projectPath.fromProjectPathRelative)(projectPath);
196
- let [patternPipeline, patternGlob] = pattern.split(':');
197
- if (!patternGlob) {
198
- patternGlob = patternPipeline;
199
- patternPipeline = null;
200
- }
201
- let re = this.regexCache.get(patternGlob);
202
- if (!re) {
203
- re = (0, _utils().globToRegex)(patternGlob, {
204
- dot: true,
205
- nocase: true
206
- });
207
- this.regexCache.set(patternGlob, re);
208
- }
209
- return (pipeline === patternPipeline || !pipeline && !patternPipeline) && (re.test(filePath) || re.test((0, _path().basename)(filePath)));
210
- }
211
- matchGlobMap(filePath, globMap) {
212
- for (let pattern in globMap) {
213
- if (this.isGlobMatch(filePath, pattern)) {
214
- return globMap[pattern];
215
- }
216
- }
217
- return null;
218
- }
219
- matchGlobMapPipelines(filePath, globMap, pipeline) {
220
- let matches = [];
221
- if (pipeline) {
222
- // If a pipeline is requested, a the glob needs to match exactly
223
- let exactMatch;
224
- for (let pattern in globMap) {
225
- if (this.isGlobMatch(filePath, pattern, pipeline)) {
226
- exactMatch = globMap[pattern];
227
- break;
228
- }
229
- }
230
- if (!exactMatch) {
231
- return [];
232
- } else {
233
- matches.push(exactMatch);
234
- }
235
- }
236
- for (let pattern in globMap) {
237
- if (this.isGlobMatch(filePath, pattern)) {
238
- matches.push(globMap[pattern]);
239
- }
240
- }
241
- let flatten = () => {
242
- let pipeline = matches.shift() || [];
243
- let spreadIndex = pipeline.indexOf('...');
244
- if (spreadIndex >= 0) {
245
- pipeline = [...pipeline.slice(0, spreadIndex), ...flatten(), ...pipeline.slice(spreadIndex + 1)];
246
- }
247
- if (pipeline.includes('...')) {
248
- throw new Error('Only one spread parameter can be included in a config pipeline');
249
- }
250
- return pipeline;
251
- };
252
- let res = flatten();
253
- // $FlowFixMe afaik this should work
254
- return res;
255
- }
256
- async missingPluginError(plugins, message, key) {
257
- let configsWithPlugin;
258
- if (Array.isArray(plugins)) {
259
- configsWithPlugin = new Set(getConfigPaths(this.options, plugins));
260
- } else {
261
- configsWithPlugin = new Set(Object.keys(plugins).flatMap(k => Array.isArray(plugins[k]) ? getConfigPaths(this.options, plugins[k]) : [getConfigPath(this.options, plugins[k])]));
262
- }
263
- if (configsWithPlugin.size === 0) {
264
- configsWithPlugin.add((0, _projectPath.fromProjectPath)(this.options.projectRoot, this.filePath));
265
- }
266
- let seenKey = false;
267
- let codeFrames = await Promise.all([...configsWithPlugin].map(async filePath => {
268
- let configContents = await this.options.inputFS.readFile(filePath, 'utf8');
269
- if (!_json().default.parse(configContents)[key.slice(1)]) {
270
- key = '';
271
- } else {
272
- seenKey = true;
273
- }
274
- return {
275
- filePath,
276
- code: configContents,
277
- codeHighlights: (0, _diagnostic().generateJSONCodeHighlights)(configContents, [{
278
- key
279
- }])
280
- };
281
- }));
282
- return new (_diagnostic().default)({
283
- diagnostic: {
284
- message,
285
- origin: '@atlaspack/core',
286
- codeFrames,
287
- hints: !seenKey ? ['Try extending __@atlaspack/config-default__'] : []
288
- }
289
- });
290
- }
291
- }
292
- exports.AtlaspackConfig = AtlaspackConfig;
293
- function getConfigPaths(options, nodes) {
294
- return nodes.map(node => node !== '...' ? getConfigPath(options, node) : null).filter(Boolean);
295
- }
296
- function getConfigPath(options, node) {
297
- return (0, _projectPath.fromProjectPath)(options.projectRoot, node.resolveFrom);
298
- }
@@ -1,103 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- exports.validatePackageName = validatePackageName;
8
- // Parcel validates plugin package names due to:
9
- //
10
- // * https://github.com/parcel-bundler/parcel/issues/3397#issuecomment-521353931
11
- //
12
- // Ultimately:
13
- //
14
- // * We do not care about package names
15
- // * Validation makes interop between parcel/atlaspack confusing.
16
- //
17
- function validatePackageName() {}
18
- const validatePluginName = (pluginType, key) => {
19
- return val => {
20
- // allow plugin spread...
21
- if (val === '...') return;
22
- try {
23
- validatePackageName(val, pluginType, key);
24
- } catch (e) {
25
- return e.message;
26
- }
27
- };
28
- };
29
- const validateExtends = val => {
30
- // allow relative paths...
31
- if (val.startsWith('.')) return;
32
- try {
33
- validatePackageName(val, 'config', 'extends');
34
- } catch (e) {
35
- return e.message;
36
- }
37
- };
38
- const pipelineSchema = (pluginType, key) => {
39
- return {
40
- type: 'array',
41
- items: {
42
- type: 'string',
43
- __validate: validatePluginName(pluginType, key)
44
- }
45
- };
46
- };
47
- const mapPipelineSchema = (pluginType, key) => {
48
- return {
49
- type: 'object',
50
- properties: {},
51
- additionalProperties: pipelineSchema(pluginType, key)
52
- };
53
- };
54
- const mapStringSchema = (pluginType, key) => {
55
- return {
56
- type: 'object',
57
- properties: {},
58
- additionalProperties: {
59
- type: 'string',
60
- __validate: validatePluginName(pluginType, key)
61
- }
62
- };
63
- };
64
- var _default = exports.default = {
65
- type: 'object',
66
- properties: {
67
- $schema: {
68
- type: 'string'
69
- },
70
- extends: {
71
- oneOf: [{
72
- type: 'string',
73
- __validate: validateExtends
74
- }, {
75
- type: 'array',
76
- items: {
77
- type: 'string',
78
- __validate: validateExtends
79
- }
80
- }]
81
- },
82
- bundler: {
83
- type: 'string',
84
- __validate: validatePluginName('bundler', 'bundler')
85
- },
86
- resolvers: pipelineSchema('resolver', 'resolvers'),
87
- transformers: mapPipelineSchema('transformer', 'transformers'),
88
- validators: mapPipelineSchema('validator', 'validators'),
89
- namers: pipelineSchema('namer', 'namers'),
90
- packagers: mapStringSchema('packager', 'packagers'),
91
- optimizers: mapPipelineSchema('optimizer', 'optimizers'),
92
- compressors: mapPipelineSchema('compressor', 'compressors'),
93
- reporters: pipelineSchema('reporter', 'reporters'),
94
- runtimes: pipelineSchema('runtime', 'runtimes'),
95
- filePath: {
96
- type: 'string'
97
- },
98
- resolveFrom: {
99
- type: 'string'
100
- }
101
- },
102
- additionalProperties: false
103
- };