From 7ebe0c3eea3ea6d012ee1e51ccae8e1cc45f7190 Mon Sep 17 00:00:00 2001 From: pqcqaq <905739777@qq.com> Date: Sat, 30 Nov 2024 10:38:10 +0800 Subject: [PATCH] fixed --- src/template.ts | 5 ++++- template/scripts/watchServer.js | 9 +++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/template.ts b/src/template.ts index 2d8be93..f55322f 100644 --- a/src/template.ts +++ b/src/template.ts @@ -311,7 +311,10 @@ export function packageJsonContent({ "readable-stream": "3.6.2" }, "_moduleAliases": { - "@project": "./lib" + "@project": "./lib", + "@oak-general-business": "./node_modules/oak-general-business/lib", + "@oak-frontend-base": "./node_modules/oak-frontend-base/lib", + "@oak-app-domain": "./lib/oak-app-domain" } } `; diff --git a/template/scripts/watchServer.js b/template/scripts/watchServer.js index b84f554..49acbbf 100644 --- a/template/scripts/watchServer.js +++ b/template/scripts/watchServer.js @@ -90,7 +90,11 @@ const restart = async () => { // 清空lib以下目录的缓存 // 删除所有模块的缓存 Object.keys(require.cache).forEach(function (key) { + if (key.includes('node_modules')) { + return; + } if (key.includes('lib')) { + console.log('delete module cache:', key); delete require.cache[key]; } }); @@ -181,9 +185,10 @@ const onChangeDebounced = _.debounce(async (path, type) => { const diagnostics = ts.getPreEmitDiagnostics(program, sourceFile); if (diagnostics.length) { const syntaxErrors = diagnostics.filter( - (diagnostic) => diagnostic.category === ts.DiagnosticCategory.Error + (diagnostic) => + diagnostic.category === ts.DiagnosticCategory.Error ); - + if (syntaxErrors.length) { console.error(`Error in ${path}`); syntaxErrors.forEach((diagnostic) => {