@atlaspack/core 2.13.2-dev.3674 → 2.13.2-dev.3689

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.
@@ -41,57 +41,26 @@ const NODE_MODULES = `${_path().default.sep}node_modules${_path().default.sep}`;
41
41
  const CONFIG = Symbol.for('parcel-plugin-config');
42
42
  async function loadPlugin(pluginName, configPath, keyPath, options) {
43
43
  let resolveFrom = configPath;
44
- let range;
45
- if (resolveFrom.includes(NODE_MODULES)) {
46
- var _configPkg$config$dep;
47
- // Config packages can reference plugins, but cannot contain other plugins within them.
48
- // This forces every published plugin to be published separately so they can be mixed and matched if needed.
49
- if (pluginName.startsWith('.')) {
50
- let configContents = await options.inputFS.readFile(configPath, 'utf8');
51
- throw new (_diagnostic().default)({
52
- diagnostic: {
53
- message: (0, _diagnostic().md)`Local plugins are not supported in Atlaspack config packages. Please publish "${pluginName}" as a separate npm package.`,
54
- origin: '@atlaspack/core',
55
- codeFrames: keyPath ? [{
56
- filePath: configPath,
57
- language: 'json5',
58
- code: configContents,
59
- codeHighlights: (0, _diagnostic().generateJSONCodeHighlights)(configContents, [{
60
- key: keyPath,
61
- type: 'value'
62
- }])
63
- }] : undefined
64
- }
65
- });
66
- }
67
- let configPkg = await (0, _utils().loadConfig)(options.inputFS, resolveFrom, ['package.json'], options.projectRoot);
68
- if (configPkg != null && ((_configPkg$config$dep = configPkg.config.dependencies) === null || _configPkg$config$dep === void 0 ? void 0 : _configPkg$config$dep[pluginName]) == null) {
69
- var _configPkg$config$par;
70
- // If not in the config's dependencies, the plugin will be auto installed with
71
- // the version declared in "parcelDependencies".
72
- range = (_configPkg$config$par = configPkg.config.parcelDependencies) === null || _configPkg$config$par === void 0 ? void 0 : _configPkg$config$par[pluginName];
73
- if (range == null) {
74
- let contents = await options.inputFS.readFile(configPkg.files[0].filePath, 'utf8');
75
- throw new (_diagnostic().default)({
76
- diagnostic: {
77
- message: (0, _diagnostic().md)`Could not determine version of ${pluginName} in ${_path().default.relative(process.cwd(), resolveFrom)}. Either include it in "dependencies" or "parcelDependencies".`,
78
- origin: '@atlaspack/core',
79
- codeFrames: configPkg.config.dependencies || configPkg.config.parcelDependencies ? [{
80
- filePath: configPkg.files[0].filePath,
81
- language: 'json5',
82
- code: contents,
83
- codeHighlights: (0, _diagnostic().generateJSONCodeHighlights)(contents, [{
84
- key: configPkg.config.parcelDependencies ? '/parcelDependencies' : '/dependencies',
85
- type: 'key'
86
- }])
87
- }] : undefined
88
- }
89
- });
90
- }
91
44
 
92
- // Resolve from project root if not in the config's dependencies.
93
- resolveFrom = _path().default.join(options.projectRoot, 'index');
94
- }
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
+ });
95
64
  }
96
65
  let resolved, pkg;
97
66
  try {
@@ -99,8 +68,7 @@ async function loadPlugin(pluginName, configPath, keyPath, options) {
99
68
  resolved,
100
69
  pkg
101
70
  } = await options.packageManager.resolve(pluginName, resolveFrom, {
102
- shouldAutoInstall: options.shouldAutoInstall,
103
- range
71
+ shouldAutoInstall: options.shouldAutoInstall
104
72
  }));
105
73
  } catch (err) {
106
74
  if (err.code !== 'MODULE_NOT_FOUND') {
@@ -142,7 +110,6 @@ async function loadPlugin(pluginName, configPath, keyPath, options) {
142
110
  return {
143
111
  plugin,
144
112
  version: (0, _nullthrows().default)(pkg).version,
145
- resolveFrom: (0, _projectPath.toProjectPath)(options.projectRoot, resolveFrom),
146
- range
113
+ resolveFrom: (0, _projectPath.toProjectPath)(options.projectRoot, resolveFrom)
147
114
  };
148
115
  }
@@ -22,17 +22,31 @@ function _utils() {
22
22
  };
23
23
  return data;
24
24
  }
25
+ function _featureFlags() {
26
+ const data = require("@atlaspack/feature-flags");
27
+ _featureFlags = function () {
28
+ return data;
29
+ };
30
+ return data;
31
+ }
25
32
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26
33
  /**
27
34
  * A path that's relative to the project root.
28
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
+ */
29
43
  function toProjectPath_(projectRoot, p) {
30
44
  // If the file path is not provided, then treat it as though it is already from the project root
31
45
  if (p == null) {
32
46
  return p;
33
47
  }
34
48
 
35
- // If the file path is already relative and it does not begin with . then treat the path as if it
49
+ // If the file path is already relative and it does not begin with '.', then treat the path as if it
36
50
  // is already from the project root. This prevents relative paths from being processed twice,
37
51
  // most often within `toInternalSourceLocation` when handling loc types from symbols and asset
38
52
  // dependencies.
@@ -45,6 +59,10 @@ function toProjectPath_(projectRoot, p) {
45
59
  // the project root is not portable anyway.
46
60
  let relative = (0, _utils().relativePath)(projectRoot, p, false);
47
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
+ }
48
66
  return process.platform === 'win32' ? (0, _utils().normalizeSeparators)(p) : p;
49
67
  }
50
68
  return relative;
@@ -33,7 +33,8 @@ function createAtlaspackBuildRequest(input) {
33
33
  async function run({
34
34
  input,
35
35
  api,
36
- options
36
+ options,
37
+ rustAtlaspack
37
38
  }) {
38
39
  let {
39
40
  optionsRef,
@@ -50,7 +51,7 @@ async function run({
50
51
  changedAssets,
51
52
  assetRequests
52
53
  } = await api.runRequest(bundleGraphRequest, {
53
- force: options.shouldBuildLazily && requestedAssetIds.size > 0
54
+ force: Boolean(rustAtlaspack) || options.shouldBuildLazily && requestedAssetIds.size > 0
54
55
  });
55
56
 
56
57
  // $FlowFixMe Added in Flow 0.121.0 upgrade in #4381 (Windows only)
@@ -146,7 +146,7 @@ function createBundleGraphRequest(input) {
146
146
  changedAssets,
147
147
  assetRequests
148
148
  } = await api.runRequest(request, {
149
- force: options.shouldBuildLazily && requestedAssetIds.size > 0
149
+ force: Boolean(input.rustAtlaspack) || options.shouldBuildLazily && requestedAssetIds.size > 0
150
150
  });
151
151
  if ((_input$options$featur = input.options.featureFlags) !== null && _input$options$featur !== void 0 && _input$options$featur.loadableSideEffects) {
152
152
  applySideEffectsForLoadableImports(assetGraph);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/core",
3
- "version": "2.13.2-dev.3674+d7732a10a",
3
+ "version": "2.13.2-dev.3689+7a2e6e783",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -20,21 +20,21 @@
20
20
  "check-ts": "tsc --noEmit index.d.ts"
21
21
  },
22
22
  "dependencies": {
23
- "@atlaspack/build-cache": "2.13.2-dev.3674+d7732a10a",
24
- "@atlaspack/cache": "2.13.2-dev.3674+d7732a10a",
25
- "@atlaspack/diagnostic": "2.13.2-dev.3674+d7732a10a",
26
- "@atlaspack/events": "2.13.2-dev.3674+d7732a10a",
27
- "@atlaspack/feature-flags": "2.13.2-dev.3674+d7732a10a",
28
- "@atlaspack/fs": "2.13.2-dev.3674+d7732a10a",
29
- "@atlaspack/graph": "3.3.2-dev.3674+d7732a10a",
30
- "@atlaspack/logger": "2.13.2-dev.3674+d7732a10a",
31
- "@atlaspack/package-manager": "2.13.2-dev.3674+d7732a10a",
32
- "@atlaspack/plugin": "2.13.2-dev.3674+d7732a10a",
33
- "@atlaspack/profiler": "2.13.2-dev.3674+d7732a10a",
34
- "@atlaspack/rust": "2.13.2-dev.3674+d7732a10a",
35
- "@atlaspack/types": "2.13.2-dev.3674+d7732a10a",
36
- "@atlaspack/utils": "2.13.2-dev.3674+d7732a10a",
37
- "@atlaspack/workers": "2.13.2-dev.3674+d7732a10a",
23
+ "@atlaspack/build-cache": "2.13.2-dev.3689+7a2e6e783",
24
+ "@atlaspack/cache": "2.13.2-dev.3689+7a2e6e783",
25
+ "@atlaspack/diagnostic": "2.13.2-dev.3689+7a2e6e783",
26
+ "@atlaspack/events": "2.13.2-dev.3689+7a2e6e783",
27
+ "@atlaspack/feature-flags": "2.13.2-dev.3689+7a2e6e783",
28
+ "@atlaspack/fs": "2.13.2-dev.3689+7a2e6e783",
29
+ "@atlaspack/graph": "3.3.2-dev.3689+7a2e6e783",
30
+ "@atlaspack/logger": "2.13.2-dev.3689+7a2e6e783",
31
+ "@atlaspack/package-manager": "2.13.2-dev.3689+7a2e6e783",
32
+ "@atlaspack/plugin": "2.13.2-dev.3689+7a2e6e783",
33
+ "@atlaspack/profiler": "2.13.2-dev.3689+7a2e6e783",
34
+ "@atlaspack/rust": "2.13.2-dev.3689+7a2e6e783",
35
+ "@atlaspack/types": "2.13.2-dev.3689+7a2e6e783",
36
+ "@atlaspack/utils": "2.13.2-dev.3689+7a2e6e783",
37
+ "@atlaspack/workers": "2.13.2-dev.3689+7a2e6e783",
38
38
  "@mischnic/json-sourcemap": "^0.1.0",
39
39
  "@parcel/source-map": "^2.1.1",
40
40
  "base-x": "^3.0.8",
@@ -66,5 +66,5 @@
66
66
  "browser": {
67
67
  "./src/serializerCore.js": "./src/serializerCore.browser.js"
68
68
  },
69
- "gitHead": "d7732a10a9a123de06d5eedcf9800d621e740229"
69
+ "gitHead": "7a2e6e7835fa846b27021b374097c6a4f37541ba"
70
70
  }
@@ -12,7 +12,6 @@ import type {
12
12
  Packager,
13
13
  Reporter,
14
14
  Semver,
15
- SemverRange,
16
15
  Validator,
17
16
  FilePath,
18
17
  } from '@atlaspack/types';
@@ -52,7 +51,6 @@ export type LoadedPlugin<T> = {|
52
51
  plugin: T,
53
52
  resolveFrom: ProjectPath,
54
53
  keyPath?: string,
55
- range?: ?SemverRange,
56
54
  |};
57
55
 
58
56
  export class AtlaspackConfig {
@@ -120,7 +118,6 @@ export class AtlaspackConfig {
120
118
  plugin: T,
121
119
  version: Semver,
122
120
  resolveFrom: ProjectPath,
123
- range: ?SemverRange,
124
121
  |}> {
125
122
  let plugin = this.pluginCache.get(node.packageName);
126
123
  if (plugin) {
@@ -65,7 +65,7 @@ export class AtlaspackV3 {
65
65
  return graph;
66
66
  }
67
67
 
68
- respondToFsEvents(events: Array<Event>): boolean {
68
+ respondToFsEvents(events: Array<Event>): Promise<boolean> {
69
69
  return this._internal.respondToFsEvents(events);
70
70
  }
71
71
  }
@@ -1,10 +1,5 @@
1
1
  // @flow
2
- import type {
3
- FilePath,
4
- PackageName,
5
- Semver,
6
- SemverRange,
7
- } from '@atlaspack/types';
2
+ import type {FilePath, PackageName, Semver} from '@atlaspack/types';
8
3
  import type {AtlaspackOptions} from './types';
9
4
 
10
5
  import path from 'path';
@@ -15,11 +10,7 @@ import ThrowableDiagnostic, {
15
10
  generateJSONCodeHighlights,
16
11
  md,
17
12
  } from '@atlaspack/diagnostic';
18
- import {
19
- findAlternativeNodeModules,
20
- loadConfig,
21
- resolveConfig,
22
- } from '@atlaspack/utils';
13
+ import {findAlternativeNodeModules, resolveConfig} from '@atlaspack/utils';
23
14
  import {type ProjectPath, toProjectPath} from './projectPath';
24
15
  import {version as ATLASPACK_VERSION} from '../package.json';
25
16
 
@@ -35,90 +26,34 @@ export default async function loadPlugin<T>(
35
26
  plugin: T,
36
27
  version: Semver,
37
28
  resolveFrom: ProjectPath,
38
- range: ?SemverRange,
39
29
  |}> {
40
30
  let resolveFrom = configPath;
41
- let range;
42
- if (resolveFrom.includes(NODE_MODULES)) {
43
- // Config packages can reference plugins, but cannot contain other plugins within them.
44
- // This forces every published plugin to be published separately so they can be mixed and matched if needed.
45
- if (pluginName.startsWith('.')) {
46
- let configContents = await options.inputFS.readFile(configPath, 'utf8');
47
- throw new ThrowableDiagnostic({
48
- diagnostic: {
49
- message: md`Local plugins are not supported in Atlaspack config packages. Please publish "${pluginName}" as a separate npm package.`,
50
- origin: '@atlaspack/core',
51
- codeFrames: keyPath
52
- ? [
53
- {
54
- filePath: configPath,
55
- language: 'json5',
56
- code: configContents,
57
- codeHighlights: generateJSONCodeHighlights(configContents, [
58
- {
59
- key: keyPath,
60
- type: 'value',
61
- },
62
- ]),
63
- },
64
- ]
65
- : undefined,
66
- },
67
- });
68
- }
69
-
70
- let configPkg = await loadConfig(
71
- options.inputFS,
72
- resolveFrom,
73
- ['package.json'],
74
- options.projectRoot,
75
- );
76
- if (
77
- configPkg != null &&
78
- configPkg.config.dependencies?.[pluginName] == null
79
- ) {
80
- // If not in the config's dependencies, the plugin will be auto installed with
81
- // the version declared in "parcelDependencies".
82
- range = configPkg.config.parcelDependencies?.[pluginName];
83
31
 
84
- if (range == null) {
85
- let contents = await options.inputFS.readFile(
86
- configPkg.files[0].filePath,
87
- 'utf8',
88
- );
89
- throw new ThrowableDiagnostic({
90
- diagnostic: {
91
- message: md`Could not determine version of ${pluginName} in ${path.relative(
92
- process.cwd(),
93
- resolveFrom,
94
- )}. Either include it in "dependencies" or "parcelDependencies".`,
95
- origin: '@atlaspack/core',
96
- codeFrames:
97
- configPkg.config.dependencies ||
98
- configPkg.config.parcelDependencies
99
- ? [
100
- {
101
- filePath: configPkg.files[0].filePath,
102
- language: 'json5',
103
- code: contents,
104
- codeHighlights: generateJSONCodeHighlights(contents, [
105
- {
106
- key: configPkg.config.parcelDependencies
107
- ? '/parcelDependencies'
108
- : '/dependencies',
109
- type: 'key',
110
- },
111
- ]),
112
- },
113
- ]
114
- : undefined,
115
- },
116
- });
117
- }
118
-
119
- // Resolve from project root if not in the config's dependencies.
120
- resolveFrom = path.join(options.projectRoot, 'index');
121
- }
32
+ // Config packages can reference plugins, but cannot contain other plugins within them.
33
+ // This forces every published plugin to be published separately so they can be mixed and matched if needed.
34
+ if (resolveFrom.includes(NODE_MODULES) && pluginName.startsWith('.')) {
35
+ let configContents = await options.inputFS.readFile(configPath, 'utf8');
36
+ throw new ThrowableDiagnostic({
37
+ diagnostic: {
38
+ message: md`Local plugins are not supported in Atlaspack config packages. Please publish "${pluginName}" as a separate npm package.`,
39
+ origin: '@atlaspack/core',
40
+ codeFrames: keyPath
41
+ ? [
42
+ {
43
+ filePath: configPath,
44
+ language: 'json5',
45
+ code: configContents,
46
+ codeHighlights: generateJSONCodeHighlights(configContents, [
47
+ {
48
+ key: keyPath,
49
+ type: 'value',
50
+ },
51
+ ]),
52
+ },
53
+ ]
54
+ : undefined,
55
+ },
56
+ });
122
57
  }
123
58
 
124
59
  let resolved, pkg;
@@ -126,10 +61,7 @@ export default async function loadPlugin<T>(
126
61
  ({resolved, pkg} = await options.packageManager.resolve(
127
62
  pluginName,
128
63
  resolveFrom,
129
- {
130
- shouldAutoInstall: options.shouldAutoInstall,
131
- range,
132
- },
64
+ {shouldAutoInstall: options.shouldAutoInstall},
133
65
  ));
134
66
  } catch (err) {
135
67
  if (err.code !== 'MODULE_NOT_FOUND') {
@@ -242,6 +174,5 @@ export default async function loadPlugin<T>(
242
174
  plugin,
243
175
  version: nullthrows(pkg).version,
244
176
  resolveFrom: toProjectPath(options.projectRoot, resolveFrom),
245
- range,
246
177
  };
247
178
  }
@@ -2,19 +2,27 @@
2
2
  import type {FilePath} from '@atlaspack/types';
3
3
  import path from 'path';
4
4
  import {relativePath, normalizeSeparators} from '@atlaspack/utils';
5
+ import {getFeatureFlagValue} from '@atlaspack/feature-flags';
5
6
 
6
7
  /**
7
8
  * A path that's relative to the project root.
8
9
  */
9
10
  export opaque type ProjectPath = string;
10
11
 
12
+ /**
13
+ * Converts a file path to a project-relative path.
14
+ *
15
+ * @param projectRoot - The project root.
16
+ * @param p - The file path to convert.
17
+ * @returns The project path.
18
+ */
11
19
  function toProjectPath_(projectRoot: FilePath, p: FilePath): ProjectPath {
12
20
  // If the file path is not provided, then treat it as though it is already from the project root
13
21
  if (p == null) {
14
22
  return p;
15
23
  }
16
24
 
17
- // If the file path is already relative and it does not begin with . then treat the path as if it
25
+ // If the file path is already relative and it does not begin with '.', then treat the path as if it
18
26
  // is already from the project root. This prevents relative paths from being processed twice,
19
27
  // most often within `toInternalSourceLocation` when handling loc types from symbols and asset
20
28
  // dependencies.
@@ -27,6 +35,11 @@ function toProjectPath_(projectRoot: FilePath, p: FilePath): ProjectPath {
27
35
  // the project root is not portable anyway.
28
36
  let relative = relativePath(projectRoot, p, false);
29
37
  if (relative.startsWith('..')) {
38
+ // e.g given projectRoot = '/Users/monorepo/project' and p = '/Users/monorepo/other-project/src/index.js' --> relative = '../other-project/src/index.js'
39
+ if (getFeatureFlagValue('patchProjectPaths')) {
40
+ return relative;
41
+ }
42
+
30
43
  return process.platform === 'win32' ? normalizeSeparators(p) : p;
31
44
  }
32
45
 
@@ -61,7 +61,7 @@ export default function createAtlaspackBuildRequest(
61
61
  };
62
62
  }
63
63
 
64
- async function run({input, api, options}) {
64
+ async function run({input, api, options, rustAtlaspack}) {
65
65
  let {optionsRef, requestedAssetIds, signal} = input;
66
66
 
67
67
  let bundleGraphRequest = createBundleGraphRequest({
@@ -72,7 +72,9 @@ async function run({input, api, options}) {
72
72
 
73
73
  let {bundleGraph, changedAssets, assetRequests}: BundleGraphResult =
74
74
  await api.runRequest(bundleGraphRequest, {
75
- force: options.shouldBuildLazily && requestedAssetIds.size > 0,
75
+ force:
76
+ Boolean(rustAtlaspack) ||
77
+ (options.shouldBuildLazily && requestedAssetIds.size > 0),
76
78
  });
77
79
 
78
80
  // $FlowFixMe Added in Flow 0.121.0 upgrade in #4381 (Windows only)
@@ -163,7 +163,9 @@ export default function createBundleGraphRequest(
163
163
  let {assetGraph, changedAssets, assetRequests} = await api.runRequest(
164
164
  request,
165
165
  {
166
- force: options.shouldBuildLazily && requestedAssetIds.size > 0,
166
+ force:
167
+ Boolean(input.rustAtlaspack) ||
168
+ (options.shouldBuildLazily && requestedAssetIds.size > 0),
167
169
  },
168
170
  );
169
171