numjs icon indicating copy to clipboard operation
numjs copied to clipboard

Add support for ES6 module

Open WangNianyi2001 opened this issue 3 years ago • 1 comments
trafficstars

As mentioned in issue #107, current numjs doesn't play well with ES6 module syntax. For example, trying to importing the whole package into an object will not work:

import * as nj from 'numjs'; // Could not find a declaration file for module 'numjs'.

And importing it directly will result in an error:

import 'numjs'; // Uncaught ReferenceError: global is not defined (pool.js:8:4)

The package is still using CommonJS-fashioned require & module.exports and is not supporting ES6 module at all! Please consider make it compatible with modules or provide another module-specified package.

WangNianyi2001 avatar Jul 10 '22 08:07 WangNianyi2001

@WangNianyi2001 try yarn add --dev @types/numjs Unfortunately types not perfectly working, lots of weird errors, but at least something

ffind avatar Jul 20 '22 03:07 ffind

file:///C:/Users/johnd/ml/test/temp.js:8 ones, ^^^^ SyntaxError: Named export 'ones' not found. The requested module 'numjs' is a Co mmonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default export, for example usin g:

johndeighan avatar Feb 10 '23 00:02 johndeighan