Hi!
I have a problem with the bundling yargs package. When I try to run bundled code I get the following error:
node:internal/url:1352
throw new ERR_INVALID_ARG_TYPE('path', ['string', 'URL'], path);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of URL. Received undefined
at new NodeError (node:internal/errors:278:15)
at fileURLToPath (node:internal/url:1352:11)
at Object.<anonymous> (/dir/b.js:524035:49)
at Module._compile (node:internal/modules/cjs/loader:1108:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
at Module.load (node:internal/modules/cjs/loader:973:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at node:internal/main/run_main_module:17:47 {
code: 'ERR_INVALID_ARG_TYPE'
}
Looks like it happens cause of the following code (github):
const mainFilename = fileURLToPath(import.meta.url).split('node_modules')[0]
const __dirname = fileURLToPath(import.meta.url)
Which transpiled into:
var import_meta = {};
var mainFilename = (0, import_url.fileURLToPath)(import_meta.url).split("node_modules")[0];
var __dirname = (0, import_url.fileURLToPath)(import_meta.url);
import_meta.url - obviously undefined there.
I try to make a bundle for node.js with the flag --format=cjs
I have checked out this issue - #208, but looks like my isn't duplicate because I try to bundle ESM -> CJS;
Is it possible to add support import.meta.url property for ESM -> CJS bundle?
Hi!
I have a problem with the bundling yargs package. When I try to run bundled code I get the following error:
Looks like it happens cause of the following code (github):
Which transpiled into:
import_meta.url- obviouslyundefinedthere.I try to make a bundle for node.js with the flag
--format=cjsI have checked out this issue - #208, but looks like my isn't duplicate because I try to bundle ESM -> CJS;
Is it possible to add support
import.meta.urlproperty for ESM -> CJS bundle?