Skip to content

Commit

Permalink
fix: compatible with Win32 when enable onDemand compile (#6466)
Browse files Browse the repository at this point in the history
* fix: compatible with Win32 when enable onDemand compile

* test: add test case
  • Loading branch information
ClarkXia authored Aug 16, 2023
1 parent b588f0a commit 5fbf49a
Show file tree
Hide file tree
Showing 3 changed files with 13 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
4 changes: 4 additions & 0 deletions examples/with-antd/ice.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import antd from '@ice/plugin-antd';
import moment from '@ice/plugin-moment-locales';

export default defineConfig(() => ({
server: {
onDemand: true,
format: 'esm',
},
plugins: [
antd({
importStyle: true,
Expand Down
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 5fbf49a

Please sign in to comment.