How to retain static esm imports? #3675
Answered
by
hardfist
jamesarosen
asked this question in
Q&A
-
I have an entrypoint that imports some of my own modules as well as some things that should be provided by the runtime environment: // entrypoint.ts
import foo from "./foo"
import bar from "@some/npm-package"
import baz from "defined-by-runtime"
foo(bar)(baz) I want this to compile to // output.js
import baz from "defined-by-runtime"
theFooExport(theBarExport(baz)) I've tried various configs, such as module.exports = {
entry: {
main: "./entrypoint.ts",
},
externals: {
"defined-by-runtime": "import defined-by-runtime",
},
externalsType: "module",
output: {
module: true,
filename: "output.js",
libraryTarget: "module",
},
}; But I always get an async function that calls |
Beta Was this translation helpful? Give feedback.
Answered by
hardfist
Jul 3, 2023
Replies: 2 comments 2 replies
-
just remove the module.exports = {
entry: {
main: "./entrypoint.ts",
},
externals: {
"defined-by-runtime": "defined-by-runtime", // remove the import otherwise the externalsType is overriden by import other than module
},
externalsType: "module",
output: {
module: true,
filename: "output.js",
libraryTarget: "module",
},
}; |
Beta Was this translation helpful? Give feedback.
1 reply
-
try the nightly version this should be fixed |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
jamesarosen
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
try the nightly version this should be fixed