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

ESM issue when trying to use spectral bundler in a packaged binary #2660

Open
jackkav opened this issue Jul 24, 2024 · 0 comments
Open

ESM issue when trying to use spectral bundler in a packaged binary #2660

jackkav opened this issue Jul 24, 2024 · 0 comments

Comments

@jackkav
Copy link

jackkav commented Jul 24, 2024

After using @yao-pkg/pkg to bundle spectral and load a .spectral.yml by a given path the bundleAndLoadRuleset function throws this error.

It appears to be an inconsistent dependency between nimma and jsep both esm, and simple-eval and jsep which is commonjs and esm respectively.

 FATAL  require() of ES Module /snapshot/insomnia/node_modules/jsep/dist/cjs/jsep.cjs.js from /snapshot/insomnia/node_modules/simple-eval/dist/index.js not supported.
jsep.cjs.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead either rename jsep.cjs.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /snapshot/insomnia/node_modules/jsep/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

This happens when using latest version of @stoplight/spectral[..] packages

The major difference in how spectral CLI is built and insomnia CLI appears to be esbuild.

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

1 participant