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