-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚸 Use dynamic import for WASI in loadPrism
- To delay the warning `ExperimentalWarning: WASI is an experimental feature and might change at any time` for prism/wasm until the actual moment prism is used. - Introduced the `renameImportWasi` plugin to address an issue where `import 'wasi';` was being included in the build artifact despite being dynamically imported within the `db-structure` package.
- Loading branch information
1 parent
064997b
commit bf5b33a
Showing
5 changed files
with
37 additions
and
4 deletions.
There are no files selected for viewing
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,6 @@ | ||
--- | ||
"@liam-hq/db-structure": patch | ||
"@liam-hq/cli": patch | ||
--- | ||
|
||
:children_crossing: Delay the warning `ExperimentalWarning: WASI is an experimental feature and might change at any time` for prism/wasm until the actual moment prism is used. |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './remove-import-wasi.js' | ||
export * from './set-env.js' |
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,19 @@ | ||
import fs from 'fs' | ||
import { type Plugin } from 'vite' | ||
|
||
// The `import 'wasi'` statement is dynamically imported within the db-structure package. | ||
// However, `import 'wasi';` gets included in the build output. | ||
// To address this, the buildEnd hook removes it from the build artifact. | ||
export function renameImportWasi(): Plugin { | ||
return { | ||
name: 'remove-import-wasi', | ||
buildEnd() { | ||
const filePath = 'dist-cli/bin/cli.js' | ||
const originalContent = fs.readFileSync(filePath, 'utf8') | ||
const content = originalContent.replace(/import 'wasi';\s*/g, '') | ||
fs.writeFileSync(filePath, content, 'utf8') | ||
}, | ||
} | ||
} | ||
|
||
export default renameImportWasi |
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