Skip to content

Support .cjs extension #249

@aciccarello

Description

@aciccarello

In a project with a package.json set to "type": "module", node changes their file interpretation to ESM. If I want to keep my pa11y JS config the same, I tried to use the .cjs extension to have Node parse the file as commonjs. But it seems like pa11y is trying to interpret the file as JSON and failing.

> pa11y-ci -c _build/tests/pa11y.cjs

There was a problem loading "/Users/ajciccarello/project/_build/tests/pa11y.cjs":
SyntaxError: Unexpected token 'c', "const test"... is not valid JSON
    at JSON.parse (<anonymous>)
    at loadLocalConfigUnmodified (/Users/ajciccarello/project/node_modules/pa11y-ci/bin/pa11y-ci.js:165:15)
    at /Users/ajciccarello/project/node_modules/pa11y-ci/bin/pa11y-ci.js:124:13
    at new Promise (<anonymous>)
    at loadConfig (/Users/ajciccarello/project/node_modules/pa11y-ci/bin/pa11y-ci.js:120:9)
    at /Users/ajciccarello/project/node_modules/pa11y-ci/bin/pa11y-ci.js:70:10
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions