import of Standalone module in ESM module requires using .default property
See original GitHub issueWhat version of Ajv are you using? Does the issue happen if you use the latest version?
v8.6.2
Your code Sandbox
import Ajv from "ajv";
import standalone from "ajv/dist/standalone/index.js";
const ajv = new Ajv();
const validate = ajv.compile({ type: "number", maximum: 5 });
const schema_compiler: string = standalone(ajv, validate);
Validation result, data AFTER validation, error messages
TypeError: standalone is not a function
at file:///sandbox/src/index.ts:6:13
at ModuleJob.run (internal/modules/esm/module_job.js:170:25)
at async Loader.import (internal/modules/esm/loader.js:178:24)
at async Object.loadESM (internal/process/esm_loader.js:68:5)
What results did you expect?
I should be able to import standalone
module without using .default
property
Are you going to resolve the issue?
This one is very similar to #1381. If required, I can create a PR to add module.exports = exports = standaloneCode
for lib/standalone/index.ts
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Building CJS module from ESM with mixed named and default ...
I am trying to configure rollup to build commonjs module from existing esm. I have set of separate standalone methods, exported with default...
Read more >Using ES Modules (ESM) in Node.js: A Practical Guide (Part 1)
This guide shows you how to use ESM in Node.js, detailing the basics, ... when importing CJS modules, you can only use “default”...
Read more >Standalone validation code - Ajv JSON schema validator
The standalone code can be generated in either CJS (module.export & require) or ESM (exports & import), it defaults to CJS. Set the...
Read more >import() which is available in all commonjs modules. - You.com
taskRepository: Failed to require task module for setTimestamp: require() of ES ... but translates CommonJS modules into modules with a default property:.
Read more >Getting started with standalone components - Angular
@Component({ standalone: true, selector: 'photo-gallery', // an existing module is imported directly into a standalone component imports: [MatButtonModule], ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
thank you! There was some incompatible typescript change I know fixed.
Cool. I have raised #1757 with the changes. My changes are consistent with what was done to fix #1381. CI seems to be failing for the PR and I don’t understand the reason why it is failing. Same tests when I run locally passes.