Closed edwindj closed 2 years ago
@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.
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.
@edwindj This is still worth merging in, if you're interested in solving that final Jest config issue (and rebasing on the latest master)
Superseded by #237
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:
Adding the "type":"module" in package.json fixes that.