From a24b57383553ecd3a73149d9b7202af23ceb69bf Mon Sep 17 00:00:00 2001 From: Jinbao1001 Date: Thu, 29 Aug 2024 17:29:39 +0800 Subject: [PATCH 1/5] fix: watch too many file error --- crates/mako/src/dev.rs | 1 - crates/mako/src/dev/watch.rs | 16 +------ scripts/test-hmr.mjs | 89 ++++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 16 deletions(-) diff --git a/crates/mako/src/dev.rs b/crates/mako/src/dev.rs index eb132bf65..813da4a6c 100644 --- a/crates/mako/src/dev.rs +++ b/crates/mako/src/dev.rs @@ -289,7 +289,6 @@ impl DevServer { eprintln!("Error rebuilding: {:?}", e); } } - watcher.refresh_watch()?; } Ok(()) } diff --git a/crates/mako/src/dev/watch.rs b/crates/mako/src/dev/watch.rs index fb2d46107..345372462 100644 --- a/crates/mako/src/dev/watch.rs +++ b/crates/mako/src/dev/watch.rs @@ -103,21 +103,6 @@ impl<'a> Watcher<'a> { Ok(()) } - pub fn refresh_watch(&mut self) -> anyhow::Result<()> { - let t_refresh_watch = Instant::now(); - self.watch()?; - let t_refresh_watch_duration = t_refresh_watch.elapsed(); - debug!( - "{}", - format!( - "✓ refresh watch in {}", - format!("{}ms", t_refresh_watch_duration.as_millis()).bold() - ) - .green() - ); - Ok(()) - } - fn get_ignore_list(&self, with_output_dir: bool) -> Vec { let mut ignore_list = vec![".git", "node_modules", ".DS_Store", ".node"]; if with_output_dir { @@ -192,6 +177,7 @@ impl<'a> Watcher<'a> { } fn should_ignore_event(path: &Path, kind: &EventKind) -> bool { + println!("kind is:{:?}", kind); if matches!( kind, EventKind::Modify(notify::event::ModifyKind::Metadata(_)) diff --git a/scripts/test-hmr.mjs b/scripts/test-hmr.mjs index dfd6ef68f..57d2725a0 100644 --- a/scripts/test-hmr.mjs +++ b/scripts/test-hmr.mjs @@ -1558,6 +1558,95 @@ ReactDOM.createRoot(document.getElementById("root")!).render(); ); }); +runTest( + 'link npm packages: import a not exit file then add it without main entry', + async () => { + await commonTest( + async () => { + write( + normalizeFiles({ + '/src/index.tsx': ` +import React from 'react'; +import ReactDOM from "react-dom/client"; +import { foo } from "mako-test-package-link/lib1"; + +function App() { + return
{foo}
{Math.random()}
; +} +ReactDOM.createRoot(document.getElementById("root")!).render(); + `, + }), + ); + writePackage( + 'mako-test-package-link', + normalizeFiles({ + 'package.json': ` +{ + "name": "mako-test-package-link", + "version": "1.0.0", + "exports": { + "./lib1": { + "import": "./lib1/index.js" + }, + "./lib2": { + "import": "./lib2/index.js" + } + } +} + `, + + 'lib1/index.js': ` +const foo = 'foo'; +export { foo }; + `, + }), + ); + execSync( + 'cd ./tmp/packages/mako-test-package-link && pnpm link --global', + ); + execSync('pnpm link --global mako-test-package-link'); + }, + (lastResult) => { + assert.equal(lastResult.html, '
foo
', 'Initial render'); + }, + async () => { + // add import to added file + write( + normalizeFiles({ + '/src/index.tsx': ` +import React from 'react'; +import ReactDOM from "react-dom/client"; +import { foo } from "mako-test-package-link/lib1"; +import { bar } from "mako-test-package-link/lib2"; + +function App() { + return
{foo}{bar}
{Math.random()}
; +} +ReactDOM.createRoot(document.getElementById("root")!).render(); + `, + }), + ); + await delay(DELAY_TIME); + // add files + writePackage( + 'mako-test-package-link', + normalizeFiles({ + 'lib2/index.js': ` + const bar = 'bar'; + export { bar }; + `, + }), + ); + }, + (thisResult) => { + console.log(1228, thisResult.html); + assert.equal(thisResult.html, '
foobar
', 'Second render'); + }, + true, + ); + }, +); + runTest('change async import to import', async () => { write( normalizeFiles({ From 83bc494fd3309c3c1936931bd580aadd7d149b7a Mon Sep 17 00:00:00 2001 From: Jinbao1001 Date: Thu, 29 Aug 2024 17:36:16 +0800 Subject: [PATCH 2/5] chore: delete print --- crates/mako/src/dev/watch.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/mako/src/dev/watch.rs b/crates/mako/src/dev/watch.rs index 345372462..3c8dcc7ab 100644 --- a/crates/mako/src/dev/watch.rs +++ b/crates/mako/src/dev/watch.rs @@ -177,7 +177,6 @@ impl<'a> Watcher<'a> { } fn should_ignore_event(path: &Path, kind: &EventKind) -> bool { - println!("kind is:{:?}", kind); if matches!( kind, EventKind::Modify(notify::event::ModifyKind::Metadata(_)) From e39b668cc2aa91803de30a2462849fce79848321 Mon Sep 17 00:00:00 2001 From: Jinbao1001 Date: Thu, 29 Aug 2024 19:06:47 +0800 Subject: [PATCH 3/5] chore: delete log --- scripts/test-hmr.mjs | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/test-hmr.mjs b/scripts/test-hmr.mjs index 57d2725a0..8d12ecc24 100644 --- a/scripts/test-hmr.mjs +++ b/scripts/test-hmr.mjs @@ -1639,7 +1639,6 @@ ReactDOM.createRoot(document.getElementById("root")!).render(); ); }, (thisResult) => { - console.log(1228, thisResult.html); assert.equal(thisResult.html, '
foobar
', 'Second render'); }, true, From 0dfa0a94b801a5a14c6fc5206e87fce4672fe27c Mon Sep 17 00:00:00 2001 From: Jinbao1001 Date: Fri, 30 Aug 2024 15:23:35 +0800 Subject: [PATCH 4/5] release: @umijs/mako@0.8.8-rc.1 --- packages/bundler-mako/package.json | 2 +- packages/mako/npm/darwin-arm64/package.json | 2 +- packages/mako/npm/darwin-x64/package.json | 2 +- packages/mako/npm/linux-arm64-musl/package.json | 2 +- packages/mako/npm/linux-x64-gnu/package.json | 2 +- packages/mako/npm/linux-x64-musl/package.json | 2 +- packages/mako/package.json | 12 ++++++------ 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/bundler-mako/package.json b/packages/bundler-mako/package.json index a4dd39486..1aef5852d 100644 --- a/packages/bundler-mako/package.json +++ b/packages/bundler-mako/package.json @@ -3,7 +3,7 @@ "version": "0.8.7", "dependencies": { "@umijs/bundler-utils": "^4.0.81", - "@umijs/mako": "0.8.7", + "@umijs/mako": "0.8.8-rc.1", "chalk": "^4.1.2", "compression": "^1.7.4", "connect-history-api-fallback": "^2.0.0", diff --git a/packages/mako/npm/darwin-arm64/package.json b/packages/mako/npm/darwin-arm64/package.json index e46978fa2..742be3eb2 100644 --- a/packages/mako/npm/darwin-arm64/package.json +++ b/packages/mako/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "@umijs/mako-darwin-arm64", - "version": "0.8.7", + "version": "0.8.8-rc.1", "os": [ "darwin" ], diff --git a/packages/mako/npm/darwin-x64/package.json b/packages/mako/npm/darwin-x64/package.json index 35d2f4285..d2b0fd835 100644 --- a/packages/mako/npm/darwin-x64/package.json +++ b/packages/mako/npm/darwin-x64/package.json @@ -1,6 +1,6 @@ { "name": "@umijs/mako-darwin-x64", - "version": "0.8.7", + "version": "0.8.8-rc.1", "os": [ "darwin" ], diff --git a/packages/mako/npm/linux-arm64-musl/package.json b/packages/mako/npm/linux-arm64-musl/package.json index 569d20314..d7c2283c2 100644 --- a/packages/mako/npm/linux-arm64-musl/package.json +++ b/packages/mako/npm/linux-arm64-musl/package.json @@ -1,6 +1,6 @@ { "name": "@umijs/mako-linux-arm64-musl", - "version": "0.8.7", + "version": "0.8.8-rc.1", "os": [ "linux" ], diff --git a/packages/mako/npm/linux-x64-gnu/package.json b/packages/mako/npm/linux-x64-gnu/package.json index 6a70b37b9..910c350bc 100644 --- a/packages/mako/npm/linux-x64-gnu/package.json +++ b/packages/mako/npm/linux-x64-gnu/package.json @@ -1,6 +1,6 @@ { "name": "@umijs/mako-linux-x64-gnu", - "version": "0.8.7", + "version": "0.8.8-rc.1", "os": [ "linux" ], diff --git a/packages/mako/npm/linux-x64-musl/package.json b/packages/mako/npm/linux-x64-musl/package.json index b7a51c859..ead5c59c7 100644 --- a/packages/mako/npm/linux-x64-musl/package.json +++ b/packages/mako/npm/linux-x64-musl/package.json @@ -1,6 +1,6 @@ { "name": "@umijs/mako-linux-x64-musl", - "version": "0.8.7", + "version": "0.8.8-rc.1", "os": [ "linux" ], diff --git a/packages/mako/package.json b/packages/mako/package.json index 6bcae356a..94cff6ce4 100644 --- a/packages/mako/package.json +++ b/packages/mako/package.json @@ -1,6 +1,6 @@ { "name": "@umijs/mako", - "version": "0.8.7", + "version": "0.8.8-rc.1", "main": "dist/index.js", "types": "dist/index.d.ts", "bin": { @@ -74,11 +74,11 @@ "src:build": "father build" }, "optionalDependencies": { - "@umijs/mako-darwin-arm64": "0.8.7", - "@umijs/mako-linux-arm64-musl": "0.8.7", - "@umijs/mako-darwin-x64": "0.8.7", - "@umijs/mako-linux-x64-gnu": "0.8.7", - "@umijs/mako-linux-x64-musl": "0.8.7" + "@umijs/mako-darwin-arm64": "0.8.8-rc.1", + "@umijs/mako-linux-arm64-musl": "0.8.8-rc.1", + "@umijs/mako-darwin-x64": "0.8.8-rc.1", + "@umijs/mako-linux-x64-gnu": "0.8.8-rc.1", + "@umijs/mako-linux-x64-musl": "0.8.8-rc.1" }, "repository": "git@github.com:umijs/mako.git" } \ No newline at end of file From 9bb710edcd6e4ad25fca9c5bb95625c655e01ec2 Mon Sep 17 00:00:00 2001 From: Jinbao1001 Date: Thu, 12 Sep 2024 13:42:54 +0800 Subject: [PATCH 5/5] fix: conflict --- packages/mako/package.json | 8 -------- 1 file changed, 8 deletions(-) diff --git a/packages/mako/package.json b/packages/mako/package.json index adc081e21..2bfb1afcf 100644 --- a/packages/mako/package.json +++ b/packages/mako/package.json @@ -77,13 +77,6 @@ "src:build": "father build" }, "optionalDependencies": { -<<<<<<< HEAD - "@umijs/mako-darwin-arm64": "0.8.8-rc.1", - "@umijs/mako-linux-arm64-musl": "0.8.8-rc.1", - "@umijs/mako-darwin-x64": "0.8.8-rc.1", - "@umijs/mako-linux-x64-gnu": "0.8.8-rc.1", - "@umijs/mako-linux-x64-musl": "0.8.8-rc.1" -======= "@umijs/mako-darwin-arm64": "0.8.11", "@umijs/mako-linux-arm64-gnu": "0.8.11", "@umijs/mako-linux-arm64-musl": "0.8.11", @@ -92,7 +85,6 @@ "@umijs/mako-win32-x64-msvc": "0.8.11", "@umijs/mako-linux-x64-gnu": "0.8.11", "@umijs/mako-linux-x64-musl": "0.8.11" ->>>>>>> origin/master }, "repository": "git@github.com:umijs/mako.git" } \ No newline at end of file