Skip to content

Commit

Permalink
fix: compatible with Win32 when enable onDemand compile
Browse files Browse the repository at this point in the history
  • Loading branch information
ClarkXia committed Aug 16, 2023
1 parent b588f0a commit 1129e80
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/empty-penguins-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ice/app': patch
---

fix: compatible with Win32 when enable onDemand request
5 changes: 4 additions & 1 deletion packages/ice/src/service/Runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import vm from 'vm';
import { isNodeBuiltin } from 'mlly';
import consola from 'consola';
import lodash from '@ice/bundles/compiled/lodash/index.js';
import dynamicImport from '../utils/dynamicImport.js';

export interface ModuleResult {
code?: string;
Expand Down Expand Up @@ -244,7 +245,9 @@ class Runner {
}

async interopedImport(id: string) {
const importedModule = await import(id);
// If dependency is pre bundled, it will returned as an absolute path,
// use dynamic import to get the module otherwise it will cause error of URL scheme in Win32.
const importedModule = path.isAbsolute(id) ? await dynamicImport(id) : await import(id);
if (!this.shouldInterop(id, importedModule)) {
return importedModule;
}
Expand Down

0 comments on commit 1129e80

Please sign in to comment.