Preventing "require" statement from being generated for external dependencies #19749
Unanswered
mysticfall
asked this question in
Q&A
Replies: 2 comments 1 reply
-
Probably swapping it via virtual module works fine, something like: export default defineConfig({
plugins: [myPluign()]
})
function myPluign() {
return {
name: 'my-plugin',
enforce: 'pre',
resolveId(source) {
if (source === 'skyrimPlatform') return '\0skyrim'
},
load(id) {
if (id === '\0skyrim') {
// assuming this list isn't too huge or can be auto-generated somehow
return `
export const Debug = skyrimPlatform.Debug;
// ...
`
}
}
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
-
Using rollup-plugin-external-globals plugin has solved my issue. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using the following config file to build my application targeted for Node.js.:
My intention is to exclude
skyrimPlatform
from the dependency list since it will be globally available at runtime. However, it still generates therequire
statement for the module like this:from this source script:
The only way I could make it omit the
require
statement is by changing the format toumd
oriife
, but it broke importing native Node modules likeos:node
.Is there a way I could achieve this?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions