@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
@@ -1,131 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.assetGraphToDot = assetGraphToDot;
7
- exports.getDebugAssetGraphDotOptions = getDebugAssetGraphDotOptions;
8
- exports.getDebugAssetGraphDotPath = getDebugAssetGraphDotPath;
9
- function _path() {
10
- const data = _interopRequireDefault(require("path"));
11
- _path = function () {
12
- return data;
13
- };
14
- return data;
15
- }
16
- var _AssetGraph = _interopRequireDefault(require("../AssetGraph"));
17
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
- /** @description Renders AssetGraph into GraphViz Dot format */
19
- function assetGraphToDot(assetGraph, {
20
- sort = false,
21
- style = true
22
- } = {}) {
23
- const edges = [];
24
- const nodeStyles = {};
25
- assetGraph.traverse(nodeId => {
26
- let node = assetGraph.getNode(nodeId) ?? null;
27
- if (!node) return;
28
- const fromIds = assetGraph.getNodeIdsConnectedTo(nodeId);
29
- for (const fromId of fromIds) {
30
- let fromNode = assetGraph.getNode(fromId) ?? null;
31
- if (!fromNode) throw new Error('No Node');
32
- const edgeStyle = getEdgeStyle(node);
33
- const nodeStyle = getNodeStyle(node);
34
- let entry = `"${getNodeName(fromNode)}" -> "${getNodeName(node)}"`;
35
- if (edgeStyle) {
36
- entry += ` [${edgeStyle}]`;
37
- }
38
- if (nodeStyle) {
39
- nodeStyles[getNodeName(node)] = nodeStyle;
40
- }
41
- edges.push(entry);
42
- }
43
- });
44
-
45
- // $FlowFixMe
46
- const nodeStylesList = Object.entries(nodeStyles);
47
- if (sort) {
48
- edges.sort();
49
- nodeStylesList.sort();
50
- }
51
- let digraph = `digraph {\n\tnode [shape=rectangle]\n`;
52
- if (style) {
53
- digraph += nodeStylesList.map(([node, style]) => `\t"${node}" [${style}]\n`).join('');
54
- }
55
- digraph += edges.map(v => `\t${v}\n`).join('');
56
- digraph += `}\n`;
57
- return digraph;
58
- }
59
- function getDebugAssetGraphDotPath() {
60
- let debugAssetGraphDot = process.env.DEBUG_ASSET_GRAPH_DOT;
61
- if (debugAssetGraphDot === undefined || debugAssetGraphDot === '') {
62
- return null;
63
- }
64
- if (!_path().default.isAbsolute(debugAssetGraphDot)) {
65
- debugAssetGraphDot = _path().default.join(process.cwd(), debugAssetGraphDot);
66
- }
67
- return debugAssetGraphDot;
68
- }
69
- function getDebugAssetGraphDotOptions() {
70
- const options = {};
71
- let style = process.env.DEBUG_ASSET_GRAPH_DOT_STYLE;
72
- if (style !== undefined) {
73
- options.style = style === 'true';
74
- }
75
- let sort = process.env.DEBUG_ASSET_GRAPH_DOT_SORT;
76
- if (sort !== undefined) {
77
- options.sort = sort === 'true';
78
- }
79
- return options;
80
- }
81
- function fromCwd(input) {
82
- return _path().default.relative(process.cwd(), input);
83
- }
84
- function getNodeName(node) {
85
- if (node.type === 'asset_group') {
86
- // $FlowFixMe
87
- return [`asset_group`, node.id, fromCwd(node.value.filePath)].join('\\n');
88
- } else if (node.type === 'asset') {
89
- // $FlowFixMe
90
- return [`asset`, node.id, fromCwd(node.value.filePath)].join('\\n');
91
- } else if (node.type === 'dependency') {
92
- return [`dependency`, node.id, node.value.specifier].join('\\n');
93
- } else if (node.type === 'entry_specifier') {
94
- // $FlowFixMe
95
- return [`entry_specifier`, node.value].join('\\n');
96
- } else if (node.type === 'entry_file') {
97
- // $FlowFixMe
98
- return [`entry_file`, fromCwd(node.value.filePath)].join('\\n');
99
- }
100
- return 'ROOT';
101
- }
102
- function getEdgeStyle(node) {
103
- if (node.type === 'asset_group') {
104
- return ``;
105
- } else if (node.type === 'asset') {
106
- return ``;
107
- } else if (node.type === 'dependency') {
108
- if (node.value.priority === 2) {
109
- return `style="dashed"`;
110
- }
111
- } else if (node.type === 'entry_specifier') {
112
- return ``;
113
- } else if (node.type === 'entry_file') {
114
- return ``;
115
- }
116
- return '';
117
- }
118
- function getNodeStyle(node) {
119
- if (node.type === 'asset_group') {
120
- return `fillcolor="#E8F5E9", style="filled"`;
121
- } else if (node.type === 'asset') {
122
- return `fillcolor="#DCEDC8", style="filled"`;
123
- } else if (node.type === 'dependency') {
124
- return `fillcolor="#BBDEFB", style="filled"`;
125
- } else if (node.type === 'entry_specifier') {
126
- return `fillcolor="#FFF9C4", style="filled"`;
127
- } else if (node.type === 'entry_file') {
128
- return `fillcolor="#FFE0B2", style="filled"`;
129
- }
130
- return '';
131
- }
@@ -1,265 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = resolveOptions;
7
- function _path() {
8
- const data = _interopRequireDefault(require("path"));
9
- _path = function () {
10
- return data;
11
- };
12
- return data;
13
- }
14
- function _rust() {
15
- const data = require("@atlaspack/rust");
16
- _rust = function () {
17
- return data;
18
- };
19
- return data;
20
- }
21
- function _fs() {
22
- const data = require("@atlaspack/fs");
23
- _fs = function () {
24
- return data;
25
- };
26
- return data;
27
- }
28
- function _cache() {
29
- const data = require("@atlaspack/cache");
30
- _cache = function () {
31
- return data;
32
- };
33
- return data;
34
- }
35
- function _featureFlags() {
36
- const data = require("@atlaspack/feature-flags");
37
- _featureFlags = function () {
38
- return data;
39
- };
40
- return data;
41
- }
42
- function _packageManager() {
43
- const data = require("@atlaspack/package-manager");
44
- _packageManager = function () {
45
- return data;
46
- };
47
- return data;
48
- }
49
- function _utils() {
50
- const data = require("@atlaspack/utils");
51
- _utils = function () {
52
- return data;
53
- };
54
- return data;
55
- }
56
- var _loadDotEnv = _interopRequireDefault(require("./loadDotEnv"));
57
- var _projectPath = require("./projectPath");
58
- var _AtlaspackConfigRequest = require("./requests/AtlaspackConfigRequest");
59
- var _constants = require("./constants");
60
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
61
- // Default cache directory name
62
- const DEFAULT_CACHE_DIRNAME = '.parcel-cache';
63
- const LOCK_FILE_NAMES = ['yarn.lock', 'package-lock.json', 'pnpm-lock.yaml'];
64
-
65
- // Generate a unique instanceId, will change on every run of parcel
66
- function generateInstanceId(entries) {
67
- return (0, _rust().hashString)(`${entries.join(',')}-${Date.now()}-${Math.round(Math.random() * 100)}`);
68
- }
69
-
70
- // Compiles an array of globs to regex - used for lazy include/excludes
71
- function compileGlobs(globs) {
72
- return globs.map(glob => (0, _utils().globToRegex)(glob));
73
- }
74
- function getDefaultFS() {
75
- if ((0, _featureFlags().getFeatureFlagValue)('vcsMode') !== 'OLD') {
76
- return new (_fs().NodeVCSAwareFS)({
77
- gitRepoPath: null,
78
- excludePatterns: [],
79
- logEventDiff: () => {}
80
- });
81
- }
82
- return new (_fs().NodeFS)();
83
- }
84
- async function findGitRepositoryRoot(inputFS, projectRoot) {
85
- let candidate = projectRoot;
86
- while (candidate !== _path().default.parse(candidate).root) {
87
- const gitRepoPath = _path().default.join(candidate, '.git');
88
- if (await inputFS.exists(gitRepoPath)) {
89
- return candidate;
90
- }
91
- candidate = _path().default.dirname(candidate);
92
- }
93
- return null;
94
- }
95
- async function resolveOptions(initialOptions) {
96
- var _initialOptions$defau, _initialOptions$defau2, _initialOptions$defau3, _initialOptions$defau4, _initialOptions$addit, _initialOptions$defau5, _initialOptions$defau6, _initialOptions$defau7, _initialOptions$defau8, _initialOptions$defau9;
97
- const inputFS = initialOptions.inputFS || getDefaultFS();
98
- const outputFS = initialOptions.outputFS || getDefaultFS();
99
- let inputCwd = inputFS.cwd();
100
- let outputCwd = outputFS.cwd();
101
- let entries;
102
- if (initialOptions.entries == null || initialOptions.entries === '') {
103
- entries = [];
104
- } else if (Array.isArray(initialOptions.entries)) {
105
- entries = initialOptions.entries.map(entry => _path().default.resolve(inputCwd, entry));
106
- } else {
107
- entries = [_path().default.resolve(inputCwd, initialOptions.entries)];
108
- }
109
- let shouldMakeEntryReferFolder = false;
110
- if (entries.length === 1 && !(0, _utils().isGlob)(entries[0])) {
111
- let [entry] = entries;
112
- try {
113
- shouldMakeEntryReferFolder = (await inputFS.stat(entry)).isDirectory();
114
- } catch {
115
- // ignore failing stat call
116
- }
117
- }
118
-
119
- // getRootDir treats the input as files, so getRootDir(["/home/user/myproject"]) returns "/home/user".
120
- // Instead we need to make the the entry refer to some file inside the specified folders if entries refers to the directory.
121
- let entryRoot = (0, _utils().getRootDir)(shouldMakeEntryReferFolder ? [_path().default.join(entries[0], 'index')] : entries);
122
- let projectRootFile = (await (0, _utils().resolveConfig)(inputFS, _path().default.join(entryRoot, 'index'), [...LOCK_FILE_NAMES, '.git', '.hg'], _path().default.parse(entryRoot).root)) || _path().default.join(inputCwd, 'index'); // ? Should this just be rootDir
123
-
124
- let projectRoot = _path().default.dirname(projectRootFile);
125
- const gitRoot = await findGitRepositoryRoot(inputFS, projectRoot);
126
- if (inputFS instanceof _fs().NodeVCSAwareFS) {
127
- inputFS.setGitRepoPath(gitRoot);
128
- }
129
- if (outputFS instanceof _fs().NodeVCSAwareFS) {
130
- outputFS.setGitRepoPath(gitRoot);
131
- }
132
- let packageManager = initialOptions.packageManager || new (_packageManager().NodePackageManager)(inputFS, projectRoot);
133
- let cacheDir =
134
- // If a cacheDir is provided, resolve it relative to cwd. Otherwise,
135
- // use a default directory resolved relative to the project root.
136
- initialOptions.cacheDir != null ? _path().default.resolve(outputCwd, initialOptions.cacheDir) : _path().default.resolve(projectRoot, DEFAULT_CACHE_DIRNAME);
137
-
138
- // Make the root watch directory configurable. This is useful in some cases
139
- // where symlinked dependencies outside the project root need to trigger HMR
140
- // updates. Default to the project root if not provided.
141
- let watchDir = initialOptions.watchDir != null ? _path().default.resolve(initialOptions.watchDir) : projectRoot;
142
- const needsRustLmdbCache = (0, _featureFlags().getFeatureFlag)('useLmdbJsLite') || (0, _featureFlags().getFeatureFlag)('atlaspackV3');
143
- let cache = needsRustLmdbCache ? new (_cache().LMDBLiteCache)(cacheDir) : outputFS instanceof _fs().NodeFS ? new (_cache().LMDBCache)(cacheDir) : new (_cache().FSCache)(outputFS, cacheDir);
144
- let mode = initialOptions.mode ?? 'development';
145
- let shouldOptimize = (initialOptions === null || initialOptions === void 0 || (_initialOptions$defau = initialOptions.defaultTargetOptions) === null || _initialOptions$defau === void 0 ? void 0 : _initialOptions$defau.shouldOptimize) ?? mode === 'production';
146
- let publicUrl = (initialOptions === null || initialOptions === void 0 || (_initialOptions$defau2 = initialOptions.defaultTargetOptions) === null || _initialOptions$defau2 === void 0 ? void 0 : _initialOptions$defau2.publicUrl) ?? '/';
147
- let distDir = (initialOptions === null || initialOptions === void 0 || (_initialOptions$defau3 = initialOptions.defaultTargetOptions) === null || _initialOptions$defau3 === void 0 ? void 0 : _initialOptions$defau3.distDir) != null ? _path().default.resolve(inputCwd, initialOptions === null || initialOptions === void 0 || (_initialOptions$defau4 = initialOptions.defaultTargetOptions) === null || _initialOptions$defau4 === void 0 ? void 0 : _initialOptions$defau4.distDir) : undefined;
148
- let shouldBuildLazily = initialOptions.shouldBuildLazily ?? false;
149
- let lazyIncludes = compileGlobs(initialOptions.lazyIncludes ?? []);
150
- if (lazyIncludes.length > 0 && !shouldBuildLazily) {
151
- throw new Error('Lazy includes can only be provided when lazy building is enabled');
152
- }
153
- let lazyExcludes = compileGlobs(initialOptions.lazyExcludes ?? []);
154
- if (lazyExcludes.length > 0 && !shouldBuildLazily) {
155
- throw new Error('Lazy excludes can only be provided when lazy building is enabled');
156
- }
157
- let shouldContentHash = initialOptions.shouldContentHash ?? initialOptions.mode === 'production';
158
- if (shouldBuildLazily && shouldContentHash) {
159
- throw new Error('Lazy bundling does not work with content hashing');
160
- }
161
- let env = {
162
- ...(await (0, _loadDotEnv.default)(initialOptions.env ?? {}, inputFS, _path().default.join(projectRoot, 'index'), projectRoot)),
163
- ...process.env,
164
- ...initialOptions.env
165
- };
166
- let port = determinePort(initialOptions.serveOptions, env.PORT);
167
- return {
168
- config: getRelativeConfigSpecifier(inputFS, projectRoot, initialOptions.config),
169
- defaultConfig: getRelativeConfigSpecifier(inputFS, projectRoot, initialOptions.defaultConfig),
170
- shouldPatchConsole: initialOptions.shouldPatchConsole ?? false,
171
- env,
172
- mode,
173
- shouldAutoInstall: initialOptions.shouldAutoInstall ?? false,
174
- hmrOptions: initialOptions.hmrOptions ?? null,
175
- shouldBuildLazily,
176
- lazyIncludes,
177
- lazyExcludes,
178
- unstableFileInvalidations: initialOptions.unstableFileInvalidations,
179
- shouldBundleIncrementally: initialOptions.shouldBundleIncrementally ?? true,
180
- shouldContentHash,
181
- serveOptions: initialOptions.serveOptions ? {
182
- ...initialOptions.serveOptions,
183
- distDir: distDir ?? _path().default.join(outputCwd, 'dist'),
184
- port
185
- } : false,
186
- shouldDisableCache: initialOptions.shouldDisableCache ?? false,
187
- shouldProfile: initialOptions.shouldProfile ?? false,
188
- shouldTrace: initialOptions.shouldTrace ?? false,
189
- cacheDir,
190
- watchDir,
191
- watchBackend: initialOptions.watchBackend ?? 'watchman',
192
- watchIgnore: initialOptions.watchIgnore,
193
- entries: entries.map(e => (0, _projectPath.toProjectPath)(projectRoot, e)),
194
- targets: initialOptions.targets,
195
- logLevel: initialOptions.logLevel ?? 'info',
196
- projectRoot,
197
- inputFS,
198
- outputFS,
199
- cache,
200
- packageManager,
201
- additionalReporters: ((_initialOptions$addit = initialOptions.additionalReporters) === null || _initialOptions$addit === void 0 ? void 0 : _initialOptions$addit.map(({
202
- packageName,
203
- resolveFrom
204
- }) => ({
205
- packageName,
206
- resolveFrom: (0, _projectPath.toProjectPath)(projectRoot, resolveFrom)
207
- }))) ?? [],
208
- instanceId: generateInstanceId(entries),
209
- detailedReport: initialOptions.detailedReport,
210
- defaultTargetOptions: {
211
- shouldOptimize,
212
- shouldScopeHoist: initialOptions === null || initialOptions === void 0 || (_initialOptions$defau5 = initialOptions.defaultTargetOptions) === null || _initialOptions$defau5 === void 0 ? void 0 : _initialOptions$defau5.shouldScopeHoist,
213
- sourceMaps: (initialOptions === null || initialOptions === void 0 || (_initialOptions$defau6 = initialOptions.defaultTargetOptions) === null || _initialOptions$defau6 === void 0 ? void 0 : _initialOptions$defau6.sourceMaps) ?? true,
214
- publicUrl,
215
- ...(distDir != null ? {
216
- distDir: (0, _projectPath.toProjectPath)(projectRoot, distDir)
217
- } : {
218
- /*::...null*/
219
- }),
220
- engines: initialOptions === null || initialOptions === void 0 || (_initialOptions$defau7 = initialOptions.defaultTargetOptions) === null || _initialOptions$defau7 === void 0 ? void 0 : _initialOptions$defau7.engines,
221
- outputFormat: initialOptions === null || initialOptions === void 0 || (_initialOptions$defau8 = initialOptions.defaultTargetOptions) === null || _initialOptions$defau8 === void 0 ? void 0 : _initialOptions$defau8.outputFormat,
222
- isLibrary: initialOptions === null || initialOptions === void 0 || (_initialOptions$defau9 = initialOptions.defaultTargetOptions) === null || _initialOptions$defau9 === void 0 ? void 0 : _initialOptions$defau9.isLibrary
223
- },
224
- // unused, feature-flags are set above this to allow this function to use
225
- // feature-flags
226
- featureFlags: {
227
- ..._featureFlags().DEFAULT_FEATURE_FLAGS,
228
- ...(initialOptions === null || initialOptions === void 0 ? void 0 : initialOptions.featureFlags)
229
- },
230
- parcelVersion: _constants.ATLASPACK_VERSION
231
- };
232
- }
233
- function getRelativeConfigSpecifier(fs, projectRoot, specifier) {
234
- if (specifier == null) {
235
- return undefined;
236
- } else if (_path().default.isAbsolute(specifier)) {
237
- let resolveFrom = (0, _AtlaspackConfigRequest.getResolveFrom)(fs, projectRoot);
238
- let relative = (0, _utils().relativePath)(_path().default.dirname(resolveFrom), specifier);
239
- // If the config is outside the project root, use an absolute path so that if the project root
240
- // moves the path still works. Otherwise, use a relative path so that the cache is portable.
241
- return relative.startsWith('..') ? specifier : relative;
242
- } else {
243
- return specifier;
244
- }
245
- }
246
- function determinePort(initialServerOptions, portInEnv, defaultPort = 1234) {
247
- function parsePort(port) {
248
- let parsedPort = Number(port);
249
-
250
- // return undefined if port number defined in .env is not valid integer
251
- if (!Number.isInteger(parsedPort)) {
252
- return undefined;
253
- }
254
- return parsedPort;
255
- }
256
- if (!initialServerOptions) {
257
- return typeof portInEnv !== 'undefined' ? parsePort(portInEnv) ?? defaultPort : defaultPort;
258
- }
259
-
260
- // if initialServerOptions.port is equal to defaultPort, then this means that port number is provided via PORT=~~~~ on cli. In this case, we should ignore port number defined in .env.
261
- if (initialServerOptions.port !== defaultPort) {
262
- return initialServerOptions.port;
263
- }
264
- return typeof portInEnv !== 'undefined' ? parsePort(portInEnv) ?? defaultPort : defaultPort;
265
- }
@@ -1,29 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.serializeRaw = exports.deserializeRaw = void 0;
7
- function _buffer() {
8
- const data = require("buffer");
9
- _buffer = function () {
10
- return data;
11
- };
12
- return data;
13
- }
14
- function msgpackr() {
15
- const data = _interopRequireWildcard(require("msgpackr"));
16
- msgpackr = function () {
17
- return data;
18
- };
19
- return data;
20
- }
21
- 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); }
22
- 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; }
23
- let encoder = new (msgpackr().Encoder)({
24
- structuredClone: true
25
- });
26
- let serializeRaw = v => _buffer().Buffer.from(encoder.encode(v));
27
- exports.serializeRaw = serializeRaw;
28
- let deserializeRaw = v => encoder.decode(v);
29
- exports.deserializeRaw = deserializeRaw;
@@ -1,55 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = summarizeRequest;
7
- function _path() {
8
- const data = _interopRequireDefault(require("path"));
9
- _path = function () {
10
- return data;
11
- };
12
- return data;
13
- }
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
- const NODE_MODULES = `${_path().default.sep}node_modules${_path().default.sep}`;
16
- const BUFFER_LIMIT = 5000000; // 5mb
17
-
18
- async function summarizeRequest(fs, req) {
19
- let {
20
- content,
21
- size
22
- } = await summarizeDiskRequest(fs, req);
23
- let isSource = isFilePathSource(fs, req.filePath);
24
- return {
25
- content,
26
- size,
27
- isSource
28
- };
29
- }
30
- function isFilePathSource(fs, filePath) {
31
- return !filePath.includes(NODE_MODULES);
32
- }
33
- async function summarizeDiskRequest(fs, req) {
34
- let code = req.code;
35
- let content;
36
- let size;
37
- if (code == null) {
38
- // Get the filesize. If greater than BUFFER_LIMIT, use a stream to
39
- // compute the hash. In the common case, it's faster to just read the entire
40
- // file first and do the hash all at once without the overhead of streams.
41
- size = (await fs.stat(req.filePath)).size;
42
- if (size > BUFFER_LIMIT) {
43
- content = fs.createReadStream(req.filePath);
44
- } else {
45
- content = await fs.readFile(req.filePath);
46
- }
47
- } else {
48
- content = code;
49
- size = Buffer.byteLength(code);
50
- }
51
- return {
52
- content,
53
- size
54
- };
55
- }
package/lib/types.js DELETED
@@ -1,35 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.SpecifierType = exports.Priority = exports.ExportsCondition = exports.BundleBehaviorNames = exports.BundleBehavior = void 0;
7
- const SpecifierType = exports.SpecifierType = {
8
- esm: 0,
9
- commonjs: 1,
10
- url: 2,
11
- custom: 3
12
- };
13
- const Priority = exports.Priority = {
14
- sync: 0,
15
- parallel: 1,
16
- lazy: 2,
17
- conditional: 3
18
- };
19
-
20
- // Must match package_json.rs in node-resolver-rs.
21
- const ExportsCondition = exports.ExportsCondition = {
22
- import: 1 << 0,
23
- require: 1 << 1,
24
- module: 1 << 2,
25
- style: 1 << 12,
26
- sass: 1 << 13,
27
- less: 1 << 14
28
- };
29
- const BundleBehavior = exports.BundleBehavior = {
30
- inline: 0,
31
- isolated: 1
32
- };
33
- const BundleBehaviorNames = exports.BundleBehaviorNames = Object.keys(BundleBehavior);
34
-
35
- // Asset group nodes are essentially used as placeholders for the results of an asset request
package/lib/utils.js DELETED
@@ -1,160 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.BuildAbortError = void 0;
7
- exports.assertSignalNotAborted = assertSignalNotAborted;
8
- exports.createInvalidations = createInvalidations;
9
- exports.fromInternalSourceLocation = fromInternalSourceLocation;
10
- exports.getBundleGroupId = getBundleGroupId;
11
- exports.getPublicId = getPublicId;
12
- exports.hashFromOption = hashFromOption;
13
- exports.invalidateOnFileCreateToInternal = invalidateOnFileCreateToInternal;
14
- exports.optionsProxy = optionsProxy;
15
- exports.toInternalSourceLocation = toInternalSourceLocation;
16
- exports.toInternalSymbols = toInternalSymbols;
17
- function _assert() {
18
- const data = _interopRequireDefault(require("assert"));
19
- _assert = function () {
20
- return data;
21
- };
22
- return data;
23
- }
24
- function _baseX() {
25
- const data = _interopRequireDefault(require("base-x"));
26
- _baseX = function () {
27
- return data;
28
- };
29
- return data;
30
- }
31
- function _utils() {
32
- const data = require("@atlaspack/utils");
33
- _utils = function () {
34
- return data;
35
- };
36
- return data;
37
- }
38
- var _projectPath = require("./projectPath");
39
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
40
- const base62 = (0, _baseX().default)('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
41
- function getBundleGroupId(bundleGroup) {
42
- return 'bundle_group:' + bundleGroup.target.name + bundleGroup.entryAssetId;
43
- }
44
- function assertSignalNotAborted(signal) {
45
- if (signal && signal.aborted) {
46
- throw new BuildAbortError();
47
- }
48
- }
49
- class BuildAbortError extends Error {
50
- name = 'BuildAbortError';
51
- }
52
- exports.BuildAbortError = BuildAbortError;
53
- function getPublicId(id, alreadyExists) {
54
- let encoded = base62.encode(Buffer.from(id, 'hex'));
55
- for (let end = 5; end <= encoded.length; end++) {
56
- let candidate = encoded.slice(0, end);
57
- if (!alreadyExists(candidate)) {
58
- return candidate;
59
- }
60
- }
61
- throw new Error('Original id was not unique');
62
- }
63
-
64
- // These options don't affect compilation and should cause invalidations
65
- const ignoreOptions = new Set(['env',
66
- // handled by separate invalidateOnEnvChange
67
- 'inputFS', 'outputFS', 'workerFarm', 'packageManager', 'detailedReport', 'shouldDisableCache', 'cacheDir', 'shouldAutoInstall', 'logLevel', 'shouldProfile', 'shouldTrace', 'shouldPatchConsole', 'projectRoot', 'additionalReporters']);
68
- function optionsProxy(options, invalidateOnOptionChange, addDevDependency) {
69
- let packageManager = addDevDependency ? proxyPackageManager(options.projectRoot, options.packageManager, addDevDependency) : options.packageManager;
70
- return new Proxy(options, {
71
- get(target, prop) {
72
- if (prop === 'packageManager') {
73
- return packageManager;
74
- }
75
- if (!ignoreOptions.has(prop)) {
76
- invalidateOnOptionChange(prop);
77
- }
78
- return target[prop];
79
- }
80
- });
81
- }
82
- function proxyPackageManager(projectRoot, packageManager, addDevDependency) {
83
- let require = (id, from, opts) => {
84
- addDevDependency({
85
- specifier: id,
86
- resolveFrom: (0, _projectPath.toProjectPath)(projectRoot, from),
87
- range: opts === null || opts === void 0 ? void 0 : opts.range
88
- });
89
- return packageManager.require(id, from, opts);
90
- };
91
- return new Proxy(packageManager, {
92
- get(target, prop) {
93
- if (prop === 'require') {
94
- return require;
95
- }
96
-
97
- // $FlowFixMe
98
- return target[prop];
99
- }
100
- });
101
- }
102
- function hashFromOption(value) {
103
- if (typeof value === 'object' && value != null) {
104
- return (0, _utils().hashObject)(value);
105
- }
106
- return String(value);
107
- }
108
- function invalidateOnFileCreateToInternal(projectRoot, invalidation) {
109
- if (invalidation.glob != null) {
110
- return {
111
- glob: (0, _projectPath.toProjectPath)(projectRoot, invalidation.glob)
112
- };
113
- } else if (invalidation.filePath != null) {
114
- return {
115
- filePath: (0, _projectPath.toProjectPath)(projectRoot, invalidation.filePath)
116
- };
117
- } else {
118
- (0, _assert().default)(invalidation.aboveFilePath != null && invalidation.fileName != null);
119
- return {
120
- fileName: invalidation.fileName,
121
- aboveFilePath: (0, _projectPath.toProjectPath)(projectRoot, invalidation.aboveFilePath)
122
- };
123
- }
124
- }
125
- function createInvalidations() {
126
- return {
127
- invalidateOnBuild: false,
128
- invalidateOnStartup: false,
129
- invalidateOnOptionChange: new Set(),
130
- invalidateOnEnvChange: new Set(),
131
- invalidateOnFileChange: new Set(),
132
- invalidateOnFileCreate: []
133
- };
134
- }
135
- function fromInternalSourceLocation(projectRoot, loc) {
136
- if (!loc) return loc;
137
- return {
138
- filePath: (0, _projectPath.fromProjectPath)(projectRoot, loc.filePath),
139
- start: loc.start,
140
- end: loc.end
141
- };
142
- }
143
- function toInternalSourceLocation(projectRoot, loc) {
144
- if (!loc) return loc;
145
- return {
146
- filePath: (0, _projectPath.toProjectPath)(projectRoot, loc.filePath),
147
- start: loc.start,
148
- end: loc.end
149
- };
150
- }
151
- function toInternalSymbols(projectRoot, symbols) {
152
- if (!symbols) return symbols;
153
- return new Map([...symbols].map(([k, {
154
- loc,
155
- ...v
156
- }]) => [k, {
157
- ...v,
158
- loc: toInternalSourceLocation(projectRoot, loc)
159
- }]));
160
- }