@atlaspack/core 2.13.2-dev.3682 → 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.
- package/lib/loadAtlaspackPlugin.js +20 -41
- package/lib/projectPath.js +19 -1
- package/package.json +17 -17
- package/src/atlaspack-v3/AtlaspackV3.js +1 -1
- package/src/loadAtlaspackPlugin.js +26 -71
- package/src/projectPath.js +14 -1
|
@@ -41,47 +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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
let configPkg = await (0, _utils().loadConfig)(options.inputFS, resolveFrom, ['package.json'], options.projectRoot);
|
|
67
|
-
if (configPkg != null && ((_configPkg$config$dep = configPkg.config.dependencies) === null || _configPkg$config$dep === void 0 ? void 0 : _configPkg$config$dep[pluginName]) == null) {
|
|
68
|
-
let contents = await options.inputFS.readFile(configPkg.files[0].filePath, 'utf8');
|
|
69
|
-
throw new (_diagnostic().default)({
|
|
70
|
-
diagnostic: {
|
|
71
|
-
message: (0, _diagnostic().md)`Could not determine version of ${pluginName} in ${_path().default.relative(process.cwd(), resolveFrom)}. Include it in "dependencies".`,
|
|
72
|
-
origin: '@atlaspack/core',
|
|
73
|
-
codeFrames: configPkg.config.dependencies ? [{
|
|
74
|
-
filePath: configPkg.files[0].filePath,
|
|
75
|
-
language: 'json5',
|
|
76
|
-
code: contents,
|
|
77
|
-
codeHighlights: (0, _diagnostic().generateJSONCodeHighlights)(contents, [{
|
|
78
|
-
key: '/dependencies',
|
|
79
|
-
type: 'key'
|
|
80
|
-
}])
|
|
81
|
-
}] : undefined
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}
|
|
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
|
+
});
|
|
85
64
|
}
|
|
86
65
|
let resolved, pkg;
|
|
87
66
|
try {
|
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-dev.
|
|
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.
|
|
24
|
-
"@atlaspack/cache": "2.13.2-dev.
|
|
25
|
-
"@atlaspack/diagnostic": "2.13.2-dev.
|
|
26
|
-
"@atlaspack/events": "2.13.2-dev.
|
|
27
|
-
"@atlaspack/feature-flags": "2.13.2-dev.
|
|
28
|
-
"@atlaspack/fs": "2.13.2-dev.
|
|
29
|
-
"@atlaspack/graph": "3.3.2-dev.
|
|
30
|
-
"@atlaspack/logger": "2.13.2-dev.
|
|
31
|
-
"@atlaspack/package-manager": "2.13.2-dev.
|
|
32
|
-
"@atlaspack/plugin": "2.13.2-dev.
|
|
33
|
-
"@atlaspack/profiler": "2.13.2-dev.
|
|
34
|
-
"@atlaspack/rust": "2.13.2-dev.
|
|
35
|
-
"@atlaspack/types": "2.13.2-dev.
|
|
36
|
-
"@atlaspack/utils": "2.13.2-dev.
|
|
37
|
-
"@atlaspack/workers": "2.13.2-dev.
|
|
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": "
|
|
69
|
+
"gitHead": "7a2e6e7835fa846b27021b374097c6a4f37541ba"
|
|
70
70
|
}
|
|
@@ -10,11 +10,7 @@ import ThrowableDiagnostic, {
|
|
|
10
10
|
generateJSONCodeHighlights,
|
|
11
11
|
md,
|
|
12
12
|
} from '@atlaspack/diagnostic';
|
|
13
|
-
import {
|
|
14
|
-
findAlternativeNodeModules,
|
|
15
|
-
loadConfig,
|
|
16
|
-
resolveConfig,
|
|
17
|
-
} from '@atlaspack/utils';
|
|
13
|
+
import {findAlternativeNodeModules, resolveConfig} from '@atlaspack/utils';
|
|
18
14
|
import {type ProjectPath, toProjectPath} from './projectPath';
|
|
19
15
|
import {version as ATLASPACK_VERSION} from '../package.json';
|
|
20
16
|
|
|
@@ -32,73 +28,32 @@ export default async function loadPlugin<T>(
|
|
|
32
28
|
resolveFrom: ProjectPath,
|
|
33
29
|
|}> {
|
|
34
30
|
let resolveFrom = configPath;
|
|
35
|
-
if (resolveFrom.includes(NODE_MODULES)) {
|
|
36
|
-
// Config packages can reference plugins, but cannot contain other plugins within them.
|
|
37
|
-
// This forces every published plugin to be published separately so they can be mixed and matched if needed.
|
|
38
|
-
if (pluginName.startsWith('.')) {
|
|
39
|
-
let configContents = await options.inputFS.readFile(configPath, 'utf8');
|
|
40
|
-
throw new ThrowableDiagnostic({
|
|
41
|
-
diagnostic: {
|
|
42
|
-
message: md`Local plugins are not supported in Atlaspack config packages. Please publish "${pluginName}" as a separate npm package.`,
|
|
43
|
-
origin: '@atlaspack/core',
|
|
44
|
-
codeFrames: keyPath
|
|
45
|
-
? [
|
|
46
|
-
{
|
|
47
|
-
filePath: configPath,
|
|
48
|
-
language: 'json5',
|
|
49
|
-
code: configContents,
|
|
50
|
-
codeHighlights: generateJSONCodeHighlights(configContents, [
|
|
51
|
-
{
|
|
52
|
-
key: keyPath,
|
|
53
|
-
type: 'value',
|
|
54
|
-
},
|
|
55
|
-
]),
|
|
56
|
-
},
|
|
57
|
-
]
|
|
58
|
-
: undefined,
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
31
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
language: 'json5',
|
|
89
|
-
code: contents,
|
|
90
|
-
codeHighlights: generateJSONCodeHighlights(contents, [
|
|
91
|
-
{
|
|
92
|
-
key: '/dependencies',
|
|
93
|
-
type: 'key',
|
|
94
|
-
},
|
|
95
|
-
]),
|
|
96
|
-
},
|
|
97
|
-
]
|
|
98
|
-
: undefined,
|
|
99
|
-
},
|
|
100
|
-
});
|
|
101
|
-
}
|
|
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
|
+
});
|
|
102
57
|
}
|
|
103
58
|
|
|
104
59
|
let resolved, pkg;
|
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
|
|