File tree Expand file tree Collapse file tree 2 files changed +213
-616
lines changed
packages/taro-platform-h5/src Expand file tree Collapse file tree 2 files changed +213
-616
lines changed Original file line number Diff line number Diff line change @@ -224,7 +224,17 @@ export default class H5 extends TaroPlatformWeb {
224224 const viteCompilerContext = await getViteH5CompilerContext ( this )
225225 if ( viteCompilerContext ) {
226226 const exts = Array . from ( new Set ( viteCompilerContext . frameworkExts . concat ( SCRIPT_EXT ) ) )
227- if ( id . startsWith ( viteCompilerContext . sourceDir ) && exts . some ( ( ext ) => id . includes ( ext ) ) ) {
227+
228+ let cleanId = id
229+
230+ if ( cleanId . startsWith ( '\u0000' ) ) {
231+ cleanId = cleanId . slice ( 1 )
232+ }
233+
234+ cleanId = cleanId . split ( '?' ) [ 0 ] . replace ( / \\ / g, '/' ) // 👈 替换斜杠方向
235+
236+ const normalizedSourceDir = viteCompilerContext . sourceDir . replace ( / \\ / g, '/' ) // 👈 替换斜杠方向
237+ if ( cleanId . startsWith ( normalizedSourceDir ) && exts . some ( ( ext ) => id . includes ( ext ) ) ) {
228238 // @TODO 后续考虑使用 SWC 插件的方式实现
229239 const result = await transformAsync ( code , {
230240 filename : id ,
You can’t perform that action at this time.
0 commit comments