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

Index.js makes some build tools think that it is a CommonJS module instead of ESM #55

Closed
AsyncBanana opened this issue Jul 15, 2021 · 4 comments

Comments

@AsyncBanana
Copy link

The index.js seems to be a CommonJS module to some build tools (notably Sveltekit's static adapter) because it does not have a .mjs suffix and there is no "type": "module" in the package.json. Two solutions are to add the module type to package.json, which would allow for the removal of all .mjs suffixes, or add an mjs suffix to index.js.

@Amatewasu
Copy link
Contributor

+1, it looks like it prevents me from doing some tests with Jest.

@tomayac
Copy link
Member

tomayac commented Jul 20, 2021

Just released v0.18.1 that should fix this.

@Amatewasu
Copy link
Contributor

Thanks a lot for your great reactivity! I upgraded the package to 0.18.1 (and checked the associated package.json file in my node_modules folder, the module type is here) but I still have the error when running tests with Jest (but it's running fine otherwise).
I am not sure it comes from browser-fs-access.

But here's my trace if it can help in any way:

XXXXXanonymizationXXXXX\node_modules\browser-fs-access\dist\index.js:2
    export{fileOpen}from"./file-open.mjs";export{directoryOpen}from"./directory-open.mjs";export{fileSave}from"./file-save.mjs";export{default as supported}from"./supported.mjs";
    ^^^^^^

    SyntaxError: Unexpected token 'export'

      1 | import { polygon, Properties } from '@turf/helpers';
      2 | import { union } from '@turf/turf';
    > 3 | import { directoryOpen, FileWithDirectoryHandle, supported as fsSupported } from 'browser-fs-access';
        | ^

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1350:14)

@tomayac
Copy link
Member

tomayac commented Jul 20, 2021

In #42, this was traced down to jestjs/jest#2550 (comment).

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