Skip to content

Import errors with esm files since 2.0.1 #192

@b0o

Description

@b0o

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/.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions