We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
the transformed Import Calls should follow the ecma specification, which should be a Rejected Promise.
const main = async () => { const num = 1; await import(`./file${num }`).catch(err => { // can not capture module not fould error }); try { await import(`./file${num }`) } catch (err) { // this could } }
the transformed code:
var __glob = (map) => (path) => { var fn = map[path]; if (fn) return fn(); throw new Error("Module not found in bundle: " + path); // synchronously throws an error. }; // import("./file*") in entry.js var globImport_file = __glob({ "./file.js": () => Promise.resolve().then(() => (init_file(), file_exports)) }); var main = async () => { const num = 3; await globImport_file(`./file${num}`).catch((err) => { if (err.code === "ERR_MODULE_NOT_FOUND") { console.log(err); } }); try { await globImport_file(`./file${num}`); } catch (err) { } };
add a new glob for dynamic import:
var __globImport = map => path => { var fn = map[path] if (fn) return fn() return Promise.reject('Module not found') }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Expected behavior
the transformed Import Calls should follow the ecma specification, which should be a Rejected Promise.
current behavior:
the transformed code:
demo: https://esbuild.github.io/try/#YgAwLjI0LjAAIC0tYnVuZGxlAGUAZW50cnkuanMAY29uc3QgbWFpbiA9IGFzeW5jICgpID0+IHsKICAgY29uc3QgbnVtID0gMTsKICAgYXdhaXQgaW1wb3J0KGAuL2ZpbGUke251bSB9YCkuY2F0Y2goZXJyID0+IHsKICAgICAgIGlmIChlcnIuY29kZSA9PT0gIkVSUl9NT0RVTEVfTk9UX0ZPVU5EIikgewogICAgICAgICAvLyBub3Qgd29ya3MKICAgICAgIH0KICAgfSk7CgogICB0cnkgewogICAgICBhd2FpdCBpbXBvcnQoYC4vZmlsZSR7bnVtIH1gKQogICB9IGNhdGNoIChlcnIpIHsKICAgICAvLyB0aGlzIHdvcmtzCiAgIH0KCn0AAGZpbGUuanMAZXhwb3J0IGRlZmF1bHQgMTsAAGZpbGUyLmpzAGV4cG9ydCBkZWZhdWx0IDE7
Possible Workaround:
add a new glob for dynamic import:
The text was updated successfully, but these errors were encountered: