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

Added "type":"module" to package.json #229

Closed
wants to merge 2 commits into from

Conversation

edwindj
Copy link

@edwindj edwindj commented Jul 20, 2022

Thanks for this wonderful package!

I am using vite 3.0 to build my projects and vite complains that this package appears to be an ESM module, but does not state so in the package.json

vite 3.0:

@simplewebauthn/browser doesn't appear to 
be written in CJS, but also doesn't appear to 
be a valid ES module

Adding the "type":"module" in package.json fixes that.

Thanks for this wonderful package!
I am using vite 3.0 to build my projects and vite complains that this package appears to be an ESM module, but does not say so in the package.json. Adding the "type":"module" fixes that.
packages/browser/package.json Outdated Show resolved Hide resolved
@MasterKale
Copy link
Owner

@edwindj Thank you for the submission, I'm surprised no one's mentioned this before. It definitely makes sense to add this bit to the browser package.

Reversed version number (to unblock the merge into the main)
@MasterKale
Copy link
Owner

MasterKale commented Jul 22, 2022

browser tests are failing with the following error:

ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/home/runner/work/SimpleWebAuthn/SimpleWebAuthn/packages/browser/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file:///home/runner/work/SimpleWebAuthn/SimpleWebAuthn/packages/browser/jest.config.js:1:20
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:541:24)
    at async importModuleDynamicallyWrapper (node:internal/vm/module:438:15)
    at async requireOrImportModule (/home/runner/work/SimpleWebAuthn/SimpleWebAuthn/node_modules/jest-util/build/requireOrImportModule.js:65:32)
    at async readConfigFileAndSetRootDir (/home/runner/work/SimpleWebAuthn/SimpleWebAuthn/node_modules/jest-config/build/readConfigFileAndSetRootDir.js:132:22)
    at async readConfig (/home/runner/work/SimpleWebAuthn/SimpleWebAuthn/node_modules/jest-config/build/index.js:233:18)
    at async readConfigs (/home/runner/work/SimpleWebAuthn/SimpleWebAuthn/node_modules/jest-config/build/index.js:420:26)
    at async runCLI (/home/runner/work/SimpleWebAuthn/SimpleWebAuthn/node_modules/@jest/core/build/cli/index.js:132:59)

Can you take a crack at figuring out how Jest needs to be updated to resolve this? It may be as simple as changing jest.config.js to use import syntax instead.

@MasterKale
Copy link
Owner

@edwindj This is still worth merging in, if you're interested in solving that final Jest config issue (and rebasing on the latest master)

@MasterKale
Copy link
Owner

Superseded by #237

@MasterKale MasterKale closed this Aug 5, 2022
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

Successfully merging this pull request may close these issues.

2 participants