You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
npm init -y
...
npm i mingo@6.4.13
...
node --input-type=module --eval "import { computeValue } from 'mingo/core'; console.log(computeValue);"
[Function: computeValue]
node --input-type=module --eval "import { Query } from 'mingo'; console.log(new Query({ test: 1 }));"
Query {
condition: { test: 1 },
options: {
idKey: '_id',
scriptEnabled: true,
useStrictMode: true,
useGlobalContext: true,
processingMode: 'CLONE_OFF',
context: Context { operators: [Object] }
},
compiled: [ [Function (anonymous)] ]
}
npm i mingo@6.4.14
...
node --input-type=module --eval "import { computeValue } from 'mingo/core'; console.log(computeValue);"
file:///[snip]/[eval1]:1
import { computeValue } from 'mingo/core'; console.log(computeValue);
^^^^^^^^^^^^
SyntaxError: Named export 'computeValue' not found. The requested module 'mingo/core' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'mingo/core';
const { computeValue } = pkg;
at ModuleJob._instantiate (node:internal/modules/esm/module_job:134:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:217:5)
at async ModuleLoader.eval (node:internal/modules/esm/loader:212:24)
at async loadESM (node:internal/process/esm_loader:28:7)
at async handleMainPromise (node:internal/modules/run_main:113:12)
Node.js v20.12.2
node --input-type=module --eval "import { Query } from 'mingo'; console.log(new Query({ test: 1 }));"
file:///[snip]/[eval1]:1
import { Query } from 'mingo'; console.log(new Query({ test: 1 }));
^^^^^
SyntaxError: Named export 'Query' not found. The requested module 'mingo' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'mingo';
const { Query } from 'mingo'; console.log(new Query({ test: 1 } = pkg;
at ModuleJob._instantiate (node:internal/modules/esm/module_job:134:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:217:5)
at async ModuleLoader.eval (node:internal/modules/esm/loader:212:24)
at async loadESM (node:internal/process/esm_loader:28:7)
at async handleMainPromise (node:internal/modules/run_main:113:12)
Node.js v20.12.2
The text was updated successfully, but these errors were encountered:
Ah sorry about that. Switched to esbuild in the last update which should support ESM correctly but I may have gotten something wrong. Will deprecate this version for now and fix in next update.
Ok, found the issue. NodeJS seem to translate ESM syntax to CommonJS so it uses the distribution under dist/cjs for which the output from esbuild is generated for only browsers when the platform option is not set. Setting that explicitly to node fixes the problem.
#422, but 6.4.14.
The text was updated successfully, but these errors were encountered: