Ignore certain dynamic import? #3336
-
Hello, I'd like to ignore certain dynamic imports from being resolved by Snowpack, is that possible somehow? With some magic comment may be, or some other way? I've just filled an issue regarding my question: #3334 The TLDR is - I'm writing a cross-platform testing tool, which can run the tests in browsers, Node and Deno. The environment-specific files are fetched in run-time, with dynamic import. Snowpack crashes on the files for Node.js environment, and I don't need those files to be poly-filled for browsers at all. That is why I'm looking for a way to ignore certain dynamic imports. Something like: static async getLauncherClass () : Promise<typeof Launcher> {
if (isNodejs())
// MAGICALLY_IGNORE_THIS_DYNAMIC_IMPORT
return (await import('../launcher/LauncherNodejs.js')).LauncherNodejs
else if (isDeno())
// MAGICALLY_IGNORE_THIS_DYNAMIC_IMPORT
return (await import('../launcher/LauncherDeno.js')).LauncherDeno
else
// NO_DO_NOT_IGNORE_THIS_DYNAMIC_IMPORT
return (await import('../launcher/LauncherBrowser.js')).LauncherBrowser
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Ok, using an expression instead of the string constant seems to do it:
|
Beta Was this translation helpful? Give feedback.
Ok, using an expression instead of the string constant seems to do it: