Skip to content

Import errors with esm files since 2.0.1 #192

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

Closed
b0o opened this issue May 7, 2024 · 4 comments
Closed

Import errors with esm files since 2.0.1 #192

b0o opened this issue May 7, 2024 · 4 comments

Comments

@b0o
Copy link

b0o commented May 7, 2024

Hi again 👋

Just got around to updating to 2.0.1, but now I'm getting errors like the following:

Error: Cannot find module 'node_modules/lib-r-math.js/dist/esm/lib/distributions/binomial/dbinom' imported from node_modules/lib-r-math.js/dist/esm/lib/distributions/binomial/index.mjs

The issue seems to stem from the lack of a .mjs extension on the import/re-export statements in the compiled esm code, e.g.:

// node_modules/lib-r-math.js/dist/esm/lib/distributions/binomial/index.mjs
export {
    dbinom
} from './dbinom';
export {
    pbinom
} from './pbinom';
export {
    qbinom
} from './qbinom';
import { rbinomOne } from './rbinom.mjs';
import { repeatedCall64 } from '../../r-func.mjs';
export function rbinom(n, size, prob) {
    return repeatedCall64(n, rbinomOne, size, prob);
}
export {
    rbinomOne
};

should be

// node_modules/lib-r-math.js/dist/esm/lib/distributions/binomial/index.mjs
export {
    dbinom
} from './dbinom.mjs';
export {
    pbinom
} from './pbinom.mjs';
export {
    qbinom
} from './qbinom.mjs';
import { rbinomOne } from './rbinom.mjs';
import { repeatedCall64 } from '../../r-func.mjs';
export function rbinom(n, size, prob) {
    return repeatedCall64(n, rbinomOne, size, prob);
}
export {
    rbinomOne
};

The same goes for the rest of the files in dist/esm/.

@jacobbogers
Copy link
Collaborator

Thanks for finding the issue, looking into it

@jacobbogers
Copy link
Collaborator

I altered the scripts/build.mjs to correct this problem

I released version 2.0.2 with the fix

Thanks for finding this issue

@b0o
Copy link
Author

b0o commented May 8, 2024

Excellent, that fixed it. Thank you!

@jacobbogers
Copy link
Collaborator

Corrected in PR 193

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

2 participants