Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES Module #42

Open
jcubic opened this issue Dec 19, 2022 · 3 comments
Open

ES Module #42

jcubic opened this issue Dec 19, 2022 · 3 comments

Comments

@jcubic
Copy link

jcubic commented Dec 19, 2022

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/complex.js@2.1.1/complex.js";

throws:

Error: Uncaught SyntaxError: The requested module 'https://cdn.jsdelivr.net/npm/complex.js@2.1.1/complex.js' does not provide an export named 'default'

and

import { Complex } from "https://cdn.jsdelivr.net/npm/complex.js@2.1.1/complex.js";

throws:

Error: Uncaught SyntaxError: The requested module 'https://cdn.jsdelivr.net/npm/complex.js@2.1.1/complex.js' does not provide an export named 'Complex'

and:

import "https://cdn.jsdelivr.net/npm/complex.js@2.1.1/complex.js";

throws:

Error: Uncaught TypeError: Cannot set properties of undefined (setting 'Complex')
@jcubic
Copy link
Author

jcubic commented Dec 19, 2022

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";

@jimaek
Copy link

jimaek commented Dec 20, 2022

There is also this option https://cdn.jsdelivr.net/npm/complex.js@2.1.1/complex.js/+esm

@othelarian
Copy link

This issue has an impact on other ES modules which use complex.js (in my case @dice-roller/rpg-dice-roller).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants