Can't import all operators in NodeJS
See original GitHub issueHi!
I’m on NodeJS version 14, Mingo version 3.0.2
I bundle the app with Webpack version 5 (also tried with 4, same effect) and run it via nodemon (2.0.4).
I try to import all operators like that (bundle size is no problem for me):
import { OperatorType, useOperators } from 'mingo/core';
import * as pipelineOperators from 'mingo/operators/pipeline';
import * as projectionOperators from 'mingo/operators/projection';
import * as queryOperators from 'mingo/operators/query';
import * as expressionOperators from 'mingo/operators/expression';
import * as accumulatorOperators from 'mingo/operators/accumulator';
useOperators(OperatorType.PIPELINE, pipelineOperators);
useOperators(OperatorType.PROJECTION, projectionOperators);
useOperators(OperatorType.QUERY, queryOperators);
useOperators(OperatorType.EXPRESSION, expressionOperators);
useOperators(OperatorType.ACCUMULATOR, accumulatorOperators);
Some of the imports work, some (like in this example arithmetic) throw:
(function (exports, require, module, __filename, __dirname) { export * from './arithmetic';
^^^^^^
SyntaxError: Unexpected token 'export'
at new Script (vm.js:99:7)
at createScript (vm.js:247:10)
at Object.runInThisContext (vm.js:295:10)
at wrapSafe (internal/modules/cjs/loader.js:1104:15)
at Module._compile (internal/modules/cjs/loader.js:1164:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
at Module.load (internal/modules/cjs/loader.js:1049:32)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Module.require (internal/modules/cjs/loader.js:1089:19)
at require (internal/modules/cjs/helpers.js:73:18)
[nodemon] app crashed - waiting for file changes before starting...
Other es6 imports work fine in my app. It also seem to have somehting to do with import ordering (which is weird)?
Any ideas?
Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Can't import multiple modules using 'import' - node.js
I'm trying to import classes from a .js file, but when I run the program it seems to have a Syntax error. Here's...
Read more >import - JavaScript - MDN Web Docs - Mozilla
You can import multiple names from the same module. ... The importing module can only read the value but can't re-assign it. ......
Read more >Documentation - Modules - TypeScript
Modules import one another using a module loader. At runtime the module loader is responsible for locating and executing all dependencies of a...
Read more >Everything you should know about 'module' & 'require' in Node.js
require keyword refers to a function which is used to import all the constructs exported using the module.exports object from another module. If ......
Read more >Async hooks | Node.js v19.3.0 Documentation
The specifics of all functions that can be passed to callbacks is in the Hook Callbacks section. import { createHook } from 'node:async_hooks'; ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks, fixed with new version.
I am unable to repro this but the latest version 3.0.3 removes the reliance on the
esm
module which is likely the root cause.Closing this issue. Please reopen if the issue still persists after upgrade.