You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importjitifrom'jiti'constmoduleAsText="export default 42"constdataUrl="data:text/javascript;base64,"+btoa(moduleAsText)constnativeImport=awaitimport(dataUrl)console.log(nativeImport.default)// prints 42constwithJiti=jiti(import.meta.filename)(dataUrl)//Throws "MODULE_NOT_FOUND" errorconsole.log(withJiti.default)
Describe the bug
jiti fails to import modules from data-urls, which is supported by node's native import
Additional context
I tested both base64 encodings and text/javascript encoding, neither worked.
Peering at the source-code there doesn't seem to be any handling for this yet. Would you be interested in supporting this?
We discovered this in opral/monorepo#2133, where a vite-plugin broke because of this.
Logs
node:internal/modules/cjs/loader:1144
const err = new Error(message);
^
Error: Cannot find module 'data:text/javascript;base64,ZXhwb3J0IGRlZmF1bHQgNDI='
Require stack:
- /Users/***/dev/jiti-debug/index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
at Function.resolve (node:internal/modules/helpers:187:19)
at _resolve (/Users/***/dev/jiti-debug/node_modules/.pnpm/jiti@1.21.0/node_modules/jiti/dist/jiti.js:1:251148)
at jiti (/Users/***/dev/jiti-debug/node_modules/.pnpm/jiti@1.21.0/node_modules/jiti/dist/jiti.js:1:253746)
at file:///Users/***/dev/jiti-debug/index.js:11:13 {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/Users/***/dev/jiti-debug/index.js' ]
}
The text was updated successfully, but these errors were encountered:
Environment
Node.js v21.2.0
Reproduction
Self contained snippet:
Describe the bug
jiti
fails to import modules from data-urls, which is supported by node's nativeimport
Additional context
I tested both
base64
encodings andtext/javascript
encoding, neither worked.Peering at the source-code there doesn't seem to be any handling for this yet. Would you be interested in supporting this?
We discovered this in opral/monorepo#2133, where a vite-plugin broke because of this.
Logs
The text was updated successfully, but these errors were encountered: