@atlaspack/core 2.13.2-canary.3697 → 2.13.2-canary.3699
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/projectPath.js +19 -1
- package/package.json +17 -17
- package/src/projectPath.js +14 -1
package/lib/projectPath.js
CHANGED
|
@@ -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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/core",
|
|
3
|
-
"version": "2.13.2-canary.
|
|
3
|
+
"version": "2.13.2-canary.3699+be63a515a",
|
|
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-canary.
|
|
24
|
-
"@atlaspack/cache": "2.13.2-canary.
|
|
25
|
-
"@atlaspack/diagnostic": "2.13.2-canary.
|
|
26
|
-
"@atlaspack/events": "2.13.2-canary.
|
|
27
|
-
"@atlaspack/feature-flags": "2.13.2-canary.
|
|
28
|
-
"@atlaspack/fs": "2.13.2-canary.
|
|
29
|
-
"@atlaspack/graph": "3.3.2-canary.
|
|
30
|
-
"@atlaspack/logger": "2.13.2-canary.
|
|
31
|
-
"@atlaspack/package-manager": "2.13.2-canary.
|
|
32
|
-
"@atlaspack/plugin": "2.13.2-canary.
|
|
33
|
-
"@atlaspack/profiler": "2.13.2-canary.
|
|
34
|
-
"@atlaspack/rust": "2.13.2-canary.
|
|
35
|
-
"@atlaspack/types": "2.13.2-canary.
|
|
36
|
-
"@atlaspack/utils": "2.13.2-canary.
|
|
37
|
-
"@atlaspack/workers": "2.13.2-canary.
|
|
23
|
+
"@atlaspack/build-cache": "2.13.2-canary.3699+be63a515a",
|
|
24
|
+
"@atlaspack/cache": "2.13.2-canary.3699+be63a515a",
|
|
25
|
+
"@atlaspack/diagnostic": "2.13.2-canary.3699+be63a515a",
|
|
26
|
+
"@atlaspack/events": "2.13.2-canary.3699+be63a515a",
|
|
27
|
+
"@atlaspack/feature-flags": "2.13.2-canary.3699+be63a515a",
|
|
28
|
+
"@atlaspack/fs": "2.13.2-canary.3699+be63a515a",
|
|
29
|
+
"@atlaspack/graph": "3.3.2-canary.3699+be63a515a",
|
|
30
|
+
"@atlaspack/logger": "2.13.2-canary.3699+be63a515a",
|
|
31
|
+
"@atlaspack/package-manager": "2.13.2-canary.3699+be63a515a",
|
|
32
|
+
"@atlaspack/plugin": "2.13.2-canary.3699+be63a515a",
|
|
33
|
+
"@atlaspack/profiler": "2.13.2-canary.3699+be63a515a",
|
|
34
|
+
"@atlaspack/rust": "2.13.2-canary.3699+be63a515a",
|
|
35
|
+
"@atlaspack/types": "2.13.2-canary.3699+be63a515a",
|
|
36
|
+
"@atlaspack/utils": "2.13.2-canary.3699+be63a515a",
|
|
37
|
+
"@atlaspack/workers": "2.13.2-canary.3699+be63a515a",
|
|
38
38
|
"@mischnic/json-sourcemap": "^0.1.0",
|
|
39
39
|
"@parcel/source-map": "^2.1.1",
|
|
40
40
|
"base-x": "^3.0.8",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"./src/serializerCore.js": "./src/serializerCore.browser.js"
|
|
68
68
|
},
|
|
69
69
|
"type": "commonjs",
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "be63a515ad13dd5ec1e241843d9ef6fdae8699d5"
|
|
71
71
|
}
|
package/src/projectPath.js
CHANGED
|
@@ -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
|
|