Skip to content

[BUG]: Documentation for loading stripe pure not correct for ESM environments. #714

Closed
@RobertSandiford

Description

@RobertSandiford

What happened?

The sample code:

import {loadStripe} from '@stripe/stripe-js/pure';

attempts to import a directory, which is not valid in ESM. The import needs to reference @stripe/stripe-js/pure/index.js or @stripe/stripe-js/pure/index.mjs to work in a true ESM environment.

Note also that the file @stripe/stripe-js/pure/index.mjs is invalid in ESM too because it attempts to import a file without an extension which is not allowed in ESM: export * from '../dist/pure';

importing '@stripe/stripe-js/pure/index.js' does work currently, although node is importing the CJS module and handling the conversion to the ESM environment (this is mostly fine, but perhaps it won't allow treeshaking during bundling).

Environment

Windows

Reproduction

https://github.com/RobertSandiford/stripe-pure-esm-repro

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions