@modern-js/plugin 3.1.1 → 3.1.2

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.
@@ -1,7 +1,7 @@
1
1
  import crypto_0 from "crypto";
2
- import { readFileSync } from "fs";
3
- import { join, resolve } from "path";
4
2
  import { chokidar, createDebugger, isDevCommand } from "@modern-js/utils";
3
+ import * as __rspack_external_fs from "fs";
4
+ import * as __rspack_external_path from "path";
5
5
  const debug = createDebugger('watch-files');
6
6
  const hashMap = new Map();
7
7
  const md5 = (data)=>crypto_0.createHash('md5').update(data).digest('hex');
@@ -11,7 +11,7 @@ const createFileWatcher = async (appContext)=>{
11
11
  const extraFiles = await appContext.hooks.addWatchFiles.call();
12
12
  const watched = extraFiles.filter((extra)=>Array.isArray(extra)).flat();
13
13
  const privateWatched = extraFiles.filter((extra)=>!Array.isArray(extra) && extra.isPrivate).map((extra)=>extra.files).flat();
14
- const isPrivate = (filename)=>privateWatched.some((ff)=>resolve(appDirectory, filename).startsWith(ff));
14
+ const isPrivate = (filename)=>privateWatched.some((ff)=>__rspack_external_path.resolve(appDirectory, filename).startsWith(ff));
15
15
  debug("watched: %o", watched);
16
16
  const watcher = chokidar.watch([
17
17
  ...watched,
@@ -29,7 +29,7 @@ const createFileWatcher = async (appContext)=>{
29
29
  });
30
30
  watcher.on('change', (changed)=>{
31
31
  const lastHash = hashMap.get(changed);
32
- const currentHash = md5(readFileSync(join(appDirectory, changed), 'utf8'));
32
+ const currentHash = md5(__rspack_external_fs.readFileSync(__rspack_external_path.join(appDirectory, changed), 'utf8'));
33
33
  if (currentHash !== lastHash) {
34
34
  debug("file change: %s", changed);
35
35
  hashMap.set(changed, currentHash);
@@ -42,7 +42,7 @@ const createFileWatcher = async (appContext)=>{
42
42
  });
43
43
  watcher.on('add', (changed)=>{
44
44
  debug("add file: %s", changed);
45
- const currentHash = md5(readFileSync(join(appDirectory, changed), 'utf8'));
45
+ const currentHash = md5(__rspack_external_fs.readFileSync(__rspack_external_path.join(appDirectory, changed), 'utf8'));
46
46
  hashMap.set(changed, currentHash);
47
47
  appContext.hooks.onFileChanged.call({
48
48
  filename: changed,
@@ -1,8 +1,8 @@
1
1
  import "node:module";
2
- import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
3
2
  import path from "path";
4
3
  import { compatibleRequire, fs, globby } from "@modern-js/utils";
5
4
  import { createJiti } from "jiti";
5
+ import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
6
6
  var loadConfig_filename = __rspack_fileURLToPath(import.meta.url);
7
7
  const getConfigFilePath = (appDirectory, configFilePath)=>{
8
8
  if (path.isAbsolute(configFilePath)) return configFilePath;
@@ -1,8 +1,8 @@
1
1
  import "node:module";
2
2
  import crypto_0 from "crypto";
3
- import { readFileSync } from "fs";
4
- import { join, resolve } from "path";
5
3
  import { chokidar, createDebugger, isDevCommand } from "@modern-js/utils";
4
+ import * as __rspack_external_fs from "fs";
5
+ import * as __rspack_external_path from "path";
6
6
  const debug = createDebugger('watch-files');
7
7
  const hashMap = new Map();
8
8
  const md5 = (data)=>crypto_0.createHash('md5').update(data).digest('hex');
@@ -12,7 +12,7 @@ const createFileWatcher = async (appContext)=>{
12
12
  const extraFiles = await appContext.hooks.addWatchFiles.call();
13
13
  const watched = extraFiles.filter((extra)=>Array.isArray(extra)).flat();
14
14
  const privateWatched = extraFiles.filter((extra)=>!Array.isArray(extra) && extra.isPrivate).map((extra)=>extra.files).flat();
15
- const isPrivate = (filename)=>privateWatched.some((ff)=>resolve(appDirectory, filename).startsWith(ff));
15
+ const isPrivate = (filename)=>privateWatched.some((ff)=>__rspack_external_path.resolve(appDirectory, filename).startsWith(ff));
16
16
  debug("watched: %o", watched);
17
17
  const watcher = chokidar.watch([
18
18
  ...watched,
@@ -30,7 +30,7 @@ const createFileWatcher = async (appContext)=>{
30
30
  });
31
31
  watcher.on('change', (changed)=>{
32
32
  const lastHash = hashMap.get(changed);
33
- const currentHash = md5(readFileSync(join(appDirectory, changed), 'utf8'));
33
+ const currentHash = md5(__rspack_external_fs.readFileSync(__rspack_external_path.join(appDirectory, changed), 'utf8'));
34
34
  if (currentHash !== lastHash) {
35
35
  debug("file change: %s", changed);
36
36
  hashMap.set(changed, currentHash);
@@ -43,7 +43,7 @@ const createFileWatcher = async (appContext)=>{
43
43
  });
44
44
  watcher.on('add', (changed)=>{
45
45
  debug("add file: %s", changed);
46
- const currentHash = md5(readFileSync(join(appDirectory, changed), 'utf8'));
46
+ const currentHash = md5(__rspack_external_fs.readFileSync(__rspack_external_path.join(appDirectory, changed), 'utf8'));
47
47
  hashMap.set(changed, currentHash);
48
48
  appContext.hooks.onFileChanged.call({
49
49
  filename: changed,
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "3.1.1",
18
+ "version": "3.1.2",
19
19
  "types": "./dist/types/index.d.ts",
20
20
  "main": "./dist/cjs/index.js",
21
21
  "exports": {
@@ -82,19 +82,19 @@
82
82
  }
83
83
  },
84
84
  "dependencies": {
85
- "@rsbuild/core": "2.0.0-beta.4",
85
+ "@rsbuild/core": "2.0.0-rc.0",
86
86
  "@swc/helpers": "^0.5.17",
87
87
  "jiti": "^2.6.1",
88
- "@modern-js/runtime-utils": "3.1.1",
89
- "@modern-js/types": "3.1.1",
90
- "@modern-js/utils": "3.1.1"
88
+ "@modern-js/runtime-utils": "3.1.2",
89
+ "@modern-js/utils": "3.1.2",
90
+ "@modern-js/types": "3.1.2"
91
91
  },
92
92
  "devDependencies": {
93
- "@rslib/core": "0.20.0",
93
+ "@rslib/core": "0.20.3",
94
94
  "@types/node": "^20",
95
95
  "@types/react": "^19.2.14",
96
96
  "typescript": "^5",
97
- "@modern-js/builder": "3.1.1",
97
+ "@modern-js/builder": "3.1.2",
98
98
  "@modern-js/rslib": "2.68.10"
99
99
  },
100
100
  "sideEffects": false,