@atlaspack/fs 2.12.1-dev.3478 → 2.12.1-dev.3502

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/fs",
3
- "version": "2.12.1-dev.3478+5fd2da535",
3
+ "version": "2.12.1-dev.3502+c2daeab5a",
4
4
  "description": "Blazing fast, zero configuration web application bundler",
5
5
  "license": "(MIT OR Apache-2.0)",
6
6
  "publishConfig": {
@@ -20,7 +20,7 @@
20
20
  "types": false,
21
21
  "main": {
22
22
  "includeNodeModules": {
23
- "@atlaspack/core": false,
23
+ "@atlaspack/build-cache": false,
24
24
  "@atlaspack/feature-flags": false,
25
25
  "@atlaspack/rust": false,
26
26
  "@atlaspack/types-internal": false,
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "browser": {
34
34
  "includeNodeModules": {
35
- "@atlaspack/core": false,
35
+ "@atlaspack/build-cache": false,
36
36
  "@atlaspack/feature-flags": false,
37
37
  "@atlaspack/rust": false,
38
38
  "@atlaspack/types-internal": false,
@@ -48,26 +48,24 @@
48
48
  "check-ts": "tsc --noEmit index.d.ts"
49
49
  },
50
50
  "dependencies": {
51
- "@atlaspack/feature-flags": "2.12.1-dev.3478+5fd2da535",
52
- "@atlaspack/rust": "2.12.1-dev.3478+5fd2da535",
53
- "@atlaspack/types-internal": "2.12.1-dev.3478+5fd2da535",
54
- "@atlaspack/utils": "2.12.1-dev.3478+5fd2da535",
55
- "@atlaspack/workers": "2.12.1-dev.3478+5fd2da535",
51
+ "@atlaspack/build-cache": "2.12.1-dev.3502+c2daeab5a",
52
+ "@atlaspack/feature-flags": "2.12.1-dev.3502+c2daeab5a",
53
+ "@atlaspack/rust": "2.12.1-dev.3502+c2daeab5a",
54
+ "@atlaspack/types-internal": "2.12.1-dev.3502+c2daeab5a",
55
+ "@atlaspack/utils": "2.12.1-dev.3502+c2daeab5a",
56
+ "@atlaspack/workers": "2.12.1-dev.3502+c2daeab5a",
56
57
  "@parcel/watcher": "^2.0.7"
57
58
  },
58
59
  "devDependencies": {
59
- "@atlaspack/watcher-watchman-js": "2.12.1-dev.3478+5fd2da535",
60
+ "@atlaspack/watcher-watchman-js": "2.12.1-dev.3502+c2daeab5a",
60
61
  "graceful-fs": "^4.2.4",
61
62
  "ncp": "^2.0.0",
62
63
  "nullthrows": "^1.1.1",
63
64
  "utility-types": "^3.10.0"
64
65
  },
65
- "peerDependencies": {
66
- "@atlaspack/core": "^2.12.1-dev.3478+5fd2da535"
67
- },
68
66
  "browser": {
69
67
  "@atlaspack/fs": "./lib/browser.js",
70
68
  "./src/NodeFS.js": "./src/NodeFS.browser.js"
71
69
  },
72
- "gitHead": "5fd2da535ecbe096d57e03aec15e80bb1d7601f7"
70
+ "gitHead": "c2daeab5a12461903159dec34df5671eaaa9b749"
73
71
  }
package/src/MemoryFS.js CHANGED
@@ -15,7 +15,7 @@ import type {
15
15
 
16
16
  import path from 'path';
17
17
  import {Readable, Writable} from 'stream';
18
- import {registerSerializableClass} from '@atlaspack/core';
18
+ import {registerSerializableClass} from '@atlaspack/build-cache';
19
19
  import {SharedBuffer} from '@atlaspack/utils';
20
20
  import packageJSON from '../package.json';
21
21
  import WorkerFarm, {Handle} from '@atlaspack/workers';
@@ -628,6 +628,7 @@ export class MemoryFS implements FileSystem {
628
628
  }
629
629
 
630
630
  async writeSnapshot(dir: FilePath, snapshot: FilePath): Promise<void> {
631
+ await this.mkdirp(path.dirname(snapshot));
631
632
  await this.writeFile(snapshot, '' + this.events.length);
632
633
  }
633
634
 
@@ -854,11 +855,15 @@ class Stat {
854
855
  }
855
856
  }
856
857
 
858
+ interface DirEntry {
859
+ mode: number;
860
+ }
861
+
857
862
  class Dirent {
858
863
  name: string;
859
864
  #mode: number;
860
865
 
861
- constructor(name: string, entry: interface {mode: number}) {
866
+ constructor(name: string, entry: DirEntry) {
862
867
  this.name = name;
863
868
  this.#mode = entry.mode;
864
869
  }
package/src/NodeFS.js CHANGED
@@ -19,7 +19,7 @@ import ncp from 'ncp';
19
19
  import path from 'path';
20
20
  import {tmpdir} from 'os';
21
21
  import {promisify} from 'util';
22
- import {registerSerializableClass} from '@atlaspack/core';
22
+ import {registerSerializableClass} from '@atlaspack/build-cache';
23
23
  import {hashFile} from '@atlaspack/utils';
24
24
  import {getFeatureFlag} from '@atlaspack/feature-flags';
25
25
  import watcher from '@parcel/watcher';
@@ -0,0 +1,79 @@
1
+ // @flow strict-local
2
+
3
+ import path from 'path';
4
+ import {NodeFS} from './NodeFS';
5
+ import {getVcsStateSnapshot, getEventsSince} from '@atlaspack/rust';
6
+ import type {FilePath} from '@atlaspack/types-internal';
7
+ import type {Event, Options as WatcherOptions} from '@parcel/watcher';
8
+ import {registerSerializableClass} from '@atlaspack/build-cache';
9
+
10
+ // $FlowFixMe
11
+ import packageJSON from '../package.json';
12
+
13
+ export interface NodeVCSAwareFSOptions {
14
+ gitRepoPath: FilePath;
15
+ excludePatterns: Array<string>;
16
+ logEventDiff: (watcherEvents: Event[], vcsEvents: string[]) => void;
17
+ }
18
+
19
+ export class NodeVCSAwareFS extends NodeFS {
20
+ #options: NodeVCSAwareFSOptions;
21
+
22
+ constructor(options: NodeVCSAwareFSOptions) {
23
+ super();
24
+ this.#options = options;
25
+ }
26
+
27
+ async getEventsSince(
28
+ dir: FilePath,
29
+ snapshot: FilePath,
30
+ opts: WatcherOptions,
31
+ ): Promise<Array<Event>> {
32
+ const snapshotFile = await this.readFile(snapshot).toString();
33
+ const {nativeSnapshotPath, vcsState} = JSON.parse(snapshotFile);
34
+
35
+ const watcherEventsSince = await this.watcher().getEventsSince(
36
+ dir,
37
+ nativeSnapshotPath,
38
+ opts,
39
+ );
40
+ const vcsEventsSince = getEventsSince(
41
+ this.#options.gitRepoPath,
42
+ vcsState.gitHash,
43
+ );
44
+ this.#options.logEventDiff(watcherEventsSince, vcsEventsSince);
45
+
46
+ return watcherEventsSince;
47
+ }
48
+
49
+ async writeSnapshot(
50
+ dir: FilePath,
51
+ snapshot: FilePath,
52
+ opts: WatcherOptions,
53
+ ): Promise<void> {
54
+ const snapshotDirectory = path.dirname(snapshot);
55
+ const filename = path.basename(snapshot, '.txt');
56
+ const nativeSnapshotPath = path.join(
57
+ snapshotDirectory,
58
+ `${filename}.native-snapshot.txt`,
59
+ );
60
+ await this.watcher().writeSnapshot(dir, nativeSnapshotPath, opts);
61
+
62
+ // TODO: we need the git repo path, pass the exclude patterns
63
+ const vcsState = await getVcsStateSnapshot(
64
+ this.#options.gitRepoPath,
65
+ this.#options.excludePatterns,
66
+ );
67
+
68
+ const snapshotContents = {
69
+ vcsState,
70
+ nativeSnapshotPath,
71
+ };
72
+ await this.writeFile(snapshot, JSON.stringify(snapshotContents));
73
+ }
74
+ }
75
+
76
+ registerSerializableClass(
77
+ `${packageJSON.version}:NodeVCSAwareFS`,
78
+ NodeVCSAwareFS,
79
+ );
package/src/OverlayFS.js CHANGED
@@ -15,7 +15,7 @@ import type {
15
15
  AsyncSubscription,
16
16
  } from '@parcel/watcher';
17
17
 
18
- import {registerSerializableClass} from '@atlaspack/core';
18
+ import {registerSerializableClass} from '@atlaspack/build-cache';
19
19
  import WorkerFarm from '@atlaspack/workers';
20
20
  import packageJSON from '../package.json';
21
21
  import {findAncestorFile, findNodeModule, findFirstFile} from './find';
@@ -15,7 +15,7 @@ describe('OverlayFS', () => {
15
15
 
16
16
  beforeEach(() => {
17
17
  workerFarm = new WorkerFarm({
18
- workerPath: require.resolve('@atlaspack/core/src/worker.js'),
18
+ workerPath: require.resolve('@atlaspack/core/worker'),
19
19
  });
20
20
  underlayFS = new MemoryFS(workerFarm);
21
21
  fs = new OverlayFS(workerFarm, underlayFS);