forked from module-federation/vite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
张洪恩
committed
Aug 31, 2024
1 parent
95bac58
commit b63c0bd
Showing
6 changed files
with
53 additions
and
50 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* https://github.com/module-federation/vite/issues/68 | ||
*/ | ||
import { mkdirSync, writeFileSync } from 'fs'; | ||
import path from 'pathe'; | ||
import VirtualModule from './VirtualModule'; | ||
|
||
|
||
export function getLocalSharedImportMapPath_windows(virtualModule: VirtualModule) { | ||
return virtualModule.getPath().replace("node_modules", ".__mf__win") | ||
} | ||
export function writeLocalSharedImportMap_windows(virtualModule: VirtualModule, content: string) { | ||
const localSharedImportMapId = getLocalSharedImportMapPath_windows(virtualModule) | ||
createFile(localSharedImportMapId + ".js", "\n// Windows temporarily needs this file, https://github.com/module-federation/vite/issues/68\n" + content) | ||
} | ||
/** | ||
* 创建文件,确保前面的目录存在 | ||
* @param {string} filePath - 文件的完整路径 | ||
* @param {string} content - 写入文件的内容 | ||
*/ | ||
function createFile(filePath: string, content: string) { | ||
// 获取文件的目录路径 | ||
const dir = path.dirname(filePath); | ||
|
||
// 递归创建目录(如果不存在的话) | ||
mkdirSync(dir, { recursive: true }); | ||
|
||
// 创建文件并写入内容 | ||
writeFileSync(filePath, content); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters