Comments (4)
Yes, dynamic import: await import('...')
is the only way I know of.
Have to make it a dual CJS/ESM package for your use case (?).
Would changing all of the exports from
{
".": {
"types": "./types/index.d.ts",
"default": "./lib/index.js"
},
...
}
to
{
".": {
"require": "./lib/index.cjs",
"import": "./lib/index.js",
"types": "./types/index.d.ts"
},
...
}
be enough for vite ? Bundler wise I only know some esbuild.
If so I'll try to remember how to CJS and add it to the generate exports script.
(I went all-in when esm was available, I haven't used CJS in years).
from node-nodert.
π€Is this https://nodejs.org/api/vm.html#when-importmoduledynamically-is-a-function related to your problem ?
When importModuleDynamically is a function, it will be invoked when import() is called in the compiled code for users to customize how the requested module should be compiled and evaluated. Currently, the Node.js instance must be launched with the --experimental-vm-modules flag for this option to work. If the flag isn't set, this callback will be ignored. If the code evaluated actually calls to import(), the result will reject with ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING_FLAG.
Node arg can be passed to electron using --js-flags="foo=bar"
ex: electron --js-flags="--env-file=.env" .
from node-nodert.
π€Is this https://nodejs.org/api/vm.html#when-importmoduledynamically-is-a-function related to your problem ?
When importModuleDynamically is a function, it will be invoked when import() is called in the compiled code for users to customize how the requested module should be compiled and evaluated. Currently, the Node.js instance must be launched with the --experimental-vm-modules flag for this option to work. If the flag isn't set, this callback will be ignored. If the code evaluated actually calls to import(), the result will reject with ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING_FLAG.
Node arg can be passed to electron using
--js-flags="foo=bar"
ex:electron --js-flags="--env-file=.env" .
Seems like it is the issue. π€, I am wondering how I can now append this flag to my production executable so that it always get run. The package doesn't seem like it would be receiving updates anymore so it would always be experimental.
Or I just remove the bytecode protection and see how that goes
Edit: Passing the flag didn't seem to fix the issue. Passed it multiple ways, via the bytecode loader, script itself, electron switches and more. But it didn't work. Such a shame that node leaves their work in shambles atimes π
from node-nodert.
Looking at: https://nodejs.org/docs/latest-v21.x/api/vm.html#vmconstantsuse_main_context_default_loader, this should solve the issue. Except node 21.7.3 throws undefined error, this is a real headscratcher and atp out of the scope of this project. Thanks Anthony π
from node-nodert.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-nodert.