@atlaspack/core 2.12.1-canary.3456 → 2.12.1-canary.3457
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/Atlaspack.js +1 -1
- package/lib/atlaspack-v3/fs.js +31 -29
- package/lib/atlaspack-v3/index.js +2 -2
- package/lib/atlaspack-v3/jsCallable.js +9 -4
- package/lib/atlaspack-v3/worker/worker.js +0 -2
- package/package.json +16 -16
- package/src/Atlaspack.js +2 -2
- package/src/atlaspack-v3/fs.js +39 -25
- package/src/atlaspack-v3/index.js +1 -1
- package/src/atlaspack-v3/jsCallable.js +11 -10
- package/src/atlaspack-v3/worker/worker.js +1 -3
package/lib/Atlaspack.js
CHANGED
|
@@ -187,7 +187,7 @@ class Atlaspack {
|
|
|
187
187
|
threads: process.env.NODE_ENV === 'test' ? 2 : undefined,
|
|
188
188
|
entries: Array.isArray(entries) ? entries : entries == null ? undefined : [entries],
|
|
189
189
|
env: resolvedOptions.env,
|
|
190
|
-
fs: inputFS &&
|
|
190
|
+
fs: inputFS && new _atlaspackV.FileSystemV3(inputFS),
|
|
191
191
|
defaultTargetOptions: {
|
|
192
192
|
// $FlowFixMe projectPath is just a string
|
|
193
193
|
distDir: resolvedOptions.defaultTargetOptions.distDir,
|
package/lib/atlaspack-v3/fs.js
CHANGED
|
@@ -3,35 +3,37 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.FileSystemV3 = void 0;
|
|
7
7
|
var _jsCallable = require("./jsCallable");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}),
|
|
22
|
-
isFile: path => {
|
|
23
|
-
try {
|
|
24
|
-
return fs.statSync(path).isFile();
|
|
25
|
-
} catch {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
isDir: path => {
|
|
30
|
-
try {
|
|
31
|
-
return fs.statSync(path).isDirectory();
|
|
32
|
-
} catch {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
8
|
+
class FileSystemV3 {
|
|
9
|
+
#fs;
|
|
10
|
+
constructor(fs) {
|
|
11
|
+
this.#fs = fs;
|
|
12
|
+
}
|
|
13
|
+
canonicalize = (0, _jsCallable.jsCallable)(path => this.#fs.realpathSync(path));
|
|
14
|
+
createDirectory = (0, _jsCallable.jsCallable)(path => this.#fs.mkdirp(path));
|
|
15
|
+
cwd = (0, _jsCallable.jsCallable)(() => this.#fs.cwd());
|
|
16
|
+
isFile = path => {
|
|
17
|
+
try {
|
|
18
|
+
return this.#fs.statSync(path).isFile();
|
|
19
|
+
} catch {
|
|
20
|
+
return false;
|
|
35
21
|
}
|
|
36
22
|
};
|
|
37
|
-
|
|
23
|
+
isDir = path => {
|
|
24
|
+
try {
|
|
25
|
+
return this.#fs.statSync(path).isDirectory();
|
|
26
|
+
} catch {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
readFile = (0, _jsCallable.jsCallable)((path, encoding) => {
|
|
31
|
+
if (!encoding) {
|
|
32
|
+
// $FlowFixMe
|
|
33
|
+
return [...this.#fs.readFileSync(path)];
|
|
34
|
+
} else {
|
|
35
|
+
return this.#fs.readFileSync(path, encoding);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
exports.FileSystemV3 = FileSystemV3;
|
|
@@ -9,10 +9,10 @@ Object.defineProperty(exports, "AtlaspackV3", {
|
|
|
9
9
|
return _AtlaspackV.AtlaspackV3;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
Object.defineProperty(exports, "
|
|
12
|
+
Object.defineProperty(exports, "FileSystemV3", {
|
|
13
13
|
enumerable: true,
|
|
14
14
|
get: function () {
|
|
15
|
-
return _fs.
|
|
15
|
+
return _fs.FileSystemV3;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
var _fs = require("./fs");
|
|
@@ -5,11 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.jsCallable = jsCallable;
|
|
7
7
|
function jsCallable(fn) {
|
|
8
|
-
return (...args) => {
|
|
8
|
+
return async (...args) => {
|
|
9
9
|
try {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return
|
|
10
|
+
// $FlowFixMe "await" is needed to log the error from
|
|
11
|
+
// Promises and is safe to use on non-promises
|
|
12
|
+
return await fn(...args);
|
|
13
|
+
// $FlowFixMe
|
|
14
|
+
} catch (error) {
|
|
15
|
+
// eslint-disable-next-line no-console
|
|
16
|
+
console.error(error);
|
|
17
|
+
throw error;
|
|
13
18
|
}
|
|
14
19
|
};
|
|
15
20
|
}
|
|
@@ -249,11 +249,9 @@ class AtlaspackWorker {
|
|
|
249
249
|
type: mutableAsset.type,
|
|
250
250
|
code: Array.from(await mutableAsset.getBuffer()),
|
|
251
251
|
meta: mutableAsset.meta,
|
|
252
|
-
// $FlowFixMe TODO Rust does not accept an undefined pipeline
|
|
253
252
|
pipeline: mutableAsset.pipeline,
|
|
254
253
|
query: mutableAsset.query.toString(),
|
|
255
254
|
symbols: mutableAsset.symbols.intoNapi(),
|
|
256
|
-
// $FlowFixMe TODO Rust does not accept an undefined pipeline
|
|
257
255
|
uniqueKey: mutableAsset.uniqueKey,
|
|
258
256
|
sideEffects: mutableAsset.sideEffects,
|
|
259
257
|
isBundleSplittable: mutableAsset.isBundleSplittable,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/core",
|
|
3
|
-
"version": "2.12.1-canary.
|
|
3
|
+
"version": "2.12.1-canary.3457+9b872e432",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -20,20 +20,20 @@
|
|
|
20
20
|
"check-ts": "tsc --noEmit index.d.ts"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@atlaspack/cache": "2.12.1-canary.
|
|
24
|
-
"@atlaspack/diagnostic": "2.12.1-canary.
|
|
25
|
-
"@atlaspack/events": "2.12.1-canary.
|
|
26
|
-
"@atlaspack/feature-flags": "2.12.1-canary.
|
|
27
|
-
"@atlaspack/fs": "2.12.1-canary.
|
|
28
|
-
"@atlaspack/graph": "3.2.1-canary.
|
|
29
|
-
"@atlaspack/logger": "2.12.1-canary.
|
|
30
|
-
"@atlaspack/package-manager": "2.12.1-canary.
|
|
31
|
-
"@atlaspack/plugin": "2.12.1-canary.
|
|
32
|
-
"@atlaspack/profiler": "2.12.1-canary.
|
|
33
|
-
"@atlaspack/rust": "2.12.1-canary.
|
|
34
|
-
"@atlaspack/types": "2.12.1-canary.
|
|
35
|
-
"@atlaspack/utils": "2.12.1-canary.
|
|
36
|
-
"@atlaspack/workers": "2.12.1-canary.
|
|
23
|
+
"@atlaspack/cache": "2.12.1-canary.3457+9b872e432",
|
|
24
|
+
"@atlaspack/diagnostic": "2.12.1-canary.3457+9b872e432",
|
|
25
|
+
"@atlaspack/events": "2.12.1-canary.3457+9b872e432",
|
|
26
|
+
"@atlaspack/feature-flags": "2.12.1-canary.3457+9b872e432",
|
|
27
|
+
"@atlaspack/fs": "2.12.1-canary.3457+9b872e432",
|
|
28
|
+
"@atlaspack/graph": "3.2.1-canary.3457+9b872e432",
|
|
29
|
+
"@atlaspack/logger": "2.12.1-canary.3457+9b872e432",
|
|
30
|
+
"@atlaspack/package-manager": "2.12.1-canary.3457+9b872e432",
|
|
31
|
+
"@atlaspack/plugin": "2.12.1-canary.3457+9b872e432",
|
|
32
|
+
"@atlaspack/profiler": "2.12.1-canary.3457+9b872e432",
|
|
33
|
+
"@atlaspack/rust": "2.12.1-canary.3457+9b872e432",
|
|
34
|
+
"@atlaspack/types": "2.12.1-canary.3457+9b872e432",
|
|
35
|
+
"@atlaspack/utils": "2.12.1-canary.3457+9b872e432",
|
|
36
|
+
"@atlaspack/workers": "2.12.1-canary.3457+9b872e432",
|
|
37
37
|
"@mischnic/json-sourcemap": "^0.1.0",
|
|
38
38
|
"@parcel/source-map": "^2.1.1",
|
|
39
39
|
"base-x": "^3.0.8",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"browser": {
|
|
58
58
|
"./src/serializerCore.js": "./src/serializerCore.browser.js"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "9b872e432000b9fc618db3fa0a13dbab0e7431ee"
|
|
61
61
|
}
|
package/src/Atlaspack.js
CHANGED
|
@@ -58,7 +58,7 @@ import {
|
|
|
58
58
|
} from './projectPath';
|
|
59
59
|
import {tracer} from '@atlaspack/profiler';
|
|
60
60
|
import {setFeatureFlags, DEFAULT_FEATURE_FLAGS} from '@atlaspack/feature-flags';
|
|
61
|
-
import {AtlaspackV3,
|
|
61
|
+
import {AtlaspackV3, FileSystemV3} from './atlaspack-v3';
|
|
62
62
|
|
|
63
63
|
registerCoreWithSerializer();
|
|
64
64
|
|
|
@@ -144,7 +144,7 @@ export default class Atlaspack {
|
|
|
144
144
|
? undefined
|
|
145
145
|
: [entries],
|
|
146
146
|
env: resolvedOptions.env,
|
|
147
|
-
fs: inputFS &&
|
|
147
|
+
fs: inputFS && new FileSystemV3(inputFS),
|
|
148
148
|
defaultTargetOptions: {
|
|
149
149
|
// $FlowFixMe projectPath is just a string
|
|
150
150
|
distDir: resolvedOptions.defaultTargetOptions.distDir,
|
package/src/atlaspack-v3/fs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @flow strict-local
|
|
2
2
|
|
|
3
|
-
import type {FileSystem} from '@atlaspack/rust';
|
|
3
|
+
import type {FileSystem, JsCallable} from '@atlaspack/rust';
|
|
4
4
|
import type {
|
|
5
5
|
Encoding,
|
|
6
6
|
FilePath,
|
|
@@ -9,33 +9,47 @@ import type {
|
|
|
9
9
|
|
|
10
10
|
import {jsCallable} from './jsCallable';
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
export class FileSystemV3 implements FileSystem {
|
|
13
|
+
#fs: ClassicFileSystem;
|
|
14
|
+
|
|
15
|
+
constructor(fs: ClassicFileSystem) {
|
|
16
|
+
this.#fs = fs;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
canonicalize: JsCallable<[FilePath], FilePath> = jsCallable(
|
|
20
|
+
(path: FilePath) => this.#fs.realpathSync(path),
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
createDirectory: JsCallable<[FilePath], Promise<void>> = jsCallable(
|
|
24
|
+
(path: FilePath) => this.#fs.mkdirp(path),
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
cwd: JsCallable<[], FilePath> = jsCallable(() => this.#fs.cwd());
|
|
28
|
+
|
|
29
|
+
isFile: JsCallable<[FilePath], boolean> = (path: string) => {
|
|
30
|
+
try {
|
|
31
|
+
return this.#fs.statSync(path).isFile();
|
|
32
|
+
} catch {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
isDir: JsCallable<[FilePath], boolean> = (path: string) => {
|
|
38
|
+
try {
|
|
39
|
+
return this.#fs.statSync(path).isDirectory();
|
|
40
|
+
} catch {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
readFile: JsCallable<[FilePath, Encoding], string> = jsCallable(
|
|
46
|
+
(path: string, encoding?: Encoding) => {
|
|
19
47
|
if (!encoding) {
|
|
20
48
|
// $FlowFixMe
|
|
21
|
-
return [...fs.readFileSync(path)];
|
|
49
|
+
return [...this.#fs.readFileSync(path)];
|
|
22
50
|
} else {
|
|
23
|
-
return fs.readFileSync(path, encoding);
|
|
24
|
-
}
|
|
25
|
-
}),
|
|
26
|
-
isFile: (path: string) => {
|
|
27
|
-
try {
|
|
28
|
-
return fs.statSync(path).isFile();
|
|
29
|
-
} catch {
|
|
30
|
-
return false;
|
|
51
|
+
return this.#fs.readFileSync(path, encoding);
|
|
31
52
|
}
|
|
32
53
|
},
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
return fs.statSync(path).isDirectory();
|
|
36
|
-
} catch {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
};
|
|
54
|
+
);
|
|
41
55
|
}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
// @flow strict-local
|
|
2
2
|
|
|
3
|
-
export type JsCallable<Args: $ReadOnlyArray<mixed>, Return> = (
|
|
4
|
-
...Args
|
|
5
|
-
) => Return;
|
|
6
|
-
|
|
7
3
|
export function jsCallable<Args: $ReadOnlyArray<mixed>, Return>(
|
|
8
|
-
fn: (...Args) => Return
|
|
9
|
-
): (...Args) => Return {
|
|
10
|
-
return (...args: Args) => {
|
|
4
|
+
fn: (...Args) => Return | Promise<Return>,
|
|
5
|
+
): (...Args) => Promise<Return> {
|
|
6
|
+
return async (...args: Args): Promise<Return> => {
|
|
11
7
|
try {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return
|
|
8
|
+
// $FlowFixMe "await" is needed to log the error from
|
|
9
|
+
// Promises and is safe to use on non-promises
|
|
10
|
+
return await fn(...args);
|
|
11
|
+
// $FlowFixMe
|
|
12
|
+
} catch (error) {
|
|
13
|
+
// eslint-disable-next-line no-console
|
|
14
|
+
console.error(error);
|
|
15
|
+
throw error;
|
|
15
16
|
}
|
|
16
17
|
};
|
|
17
18
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import assert from 'assert';
|
|
3
3
|
import * as napi from '@atlaspack/rust';
|
|
4
|
+
import type {JsCallable} from '@atlaspack/rust';
|
|
4
5
|
import {NodeFS} from '@atlaspack/fs';
|
|
5
6
|
import {NodePackageManager} from '@atlaspack/package-manager';
|
|
6
7
|
import type {
|
|
@@ -24,7 +25,6 @@ import {
|
|
|
24
25
|
dependencyPriorityMap,
|
|
25
26
|
} from './compat';
|
|
26
27
|
import {jsCallable} from '../jsCallable';
|
|
27
|
-
import type {JsCallable} from '../jsCallable';
|
|
28
28
|
|
|
29
29
|
const CONFIG = Symbol.for('parcel-plugin-config');
|
|
30
30
|
|
|
@@ -256,11 +256,9 @@ export class AtlaspackWorker {
|
|
|
256
256
|
type: mutableAsset.type,
|
|
257
257
|
code: Array.from(await mutableAsset.getBuffer()),
|
|
258
258
|
meta: mutableAsset.meta,
|
|
259
|
-
// $FlowFixMe TODO Rust does not accept an undefined pipeline
|
|
260
259
|
pipeline: mutableAsset.pipeline,
|
|
261
260
|
query: mutableAsset.query.toString(),
|
|
262
261
|
symbols: mutableAsset.symbols.intoNapi(),
|
|
263
|
-
// $FlowFixMe TODO Rust does not accept an undefined pipeline
|
|
264
262
|
uniqueKey: mutableAsset.uniqueKey,
|
|
265
263
|
sideEffects: mutableAsset.sideEffects,
|
|
266
264
|
isBundleSplittable: mutableAsset.isBundleSplittable,
|