Complex.js
Complex.js copied to clipboard
ES Module
I'm trying to this package as ES Module, even that it has some code:
Object.defineProperty(Complex, "__esModule", { 'value': true });
ES Modules don't work from the browser.
import Complex from "https://cdn.jsdelivr.net/npm/[email protected]/complex.js";
throws:
Error: Uncaught SyntaxError: The requested module 'https://cdn.jsdelivr.net/npm/[email protected]/complex.js' does not provide an export named 'default'
and
import { Complex } from "https://cdn.jsdelivr.net/npm/[email protected]/complex.js";
throws:
Error: Uncaught SyntaxError: The requested module 'https://cdn.jsdelivr.net/npm/[email protected]/complex.js' does not provide an export named 'Complex'
and:
import "https://cdn.jsdelivr.net/npm/[email protected]/complex.js";
throws:
Error: Uncaught TypeError: Cannot set properties of undefined (setting 'Complex')
Just found out about skypack you can add this to the README. To import the library in ES Module you can use this:
import Complex from "https://cdn.skypack.dev/complex.js";
There is also this option https://cdn.jsdelivr.net/npm/[email protected]/complex.js/+esm
This issue has an impact on other ES modules which use complex.js (in my case @dice-roller/rpg-dice-roller).