dynamic require not working for ajv-oai
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 9.8k
- Forks
- 326
- PR merge metrics
- No merged PRs in 30d
Description
In one of my projects ajv-oai is used as a submodule within another module that is used directly.
Inside ajv-oai a dynamic require is used and it looks like ncc cannot resolve it. At runtime the required module then cannot be found.
I stripped it down a bit. Maybe someone can tell me what must be changed to make it working with ncc.
In ajv-oai this line with require is not resolved.
If it's written like this, it is working:
before ncc:
const schema = "json-schema-draft-04";
const x = require(`ajv/lib/refs/${schema}.json`);
after ncc:
const schema = "json-schema-draft-04";
const x = __webpack_require__(6267);
stripped down ajv-oai method before ncc:
AjvOAI({ metaSchema = 'json-schema-draft-04', ...optsIn } = {}) {
require(`ajv/lib/refs/${metaSchema}.json`)
}
after ncc (nothing changed):
AjvOAI({ metaSchema = 'json-schema-draft-04', ...optsIn } = {}) {
require(`ajv/lib/refs/${metaSchema}.json`)
}
I'm happy for every hint what I could change or also could be changed in ajv-oai to make it working. Maybe it's possible to get it solved in ncc directly.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the dynamic require in ajv-oai's lib/ajv-oai.js and reproduce the stripped-down example described in the issue using ncc. Inspect how ncc handles the template-based path to ajv/lib/refs/${metaSchema}.json; the work is done when the bundled output can resolve the required schema at runtime.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100