Skip to content

Support ESM config file #250

@aciccarello

Description

@aciccarello

If the package.json "type" is set to "module", a js config file is interpreted as ESM. When required, the ESM module is readonly which causes problems for the defaulting code. pa11y-ci might also need to check the default export property rather than needing to export individual properties (rather than export const urls = [...]

> NODE_OPTIONS='--experimental-require-module' pa11y-ci -c _build/tests/pa11y.js

(node:2986) ExperimentalWarning: Support for loading ES Module in require() is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
/Users/ajciccarello/project/node_modules/pa11y-ci/bin/pa11y-ci.js:198
        config.urls = config.urls || [];
                    ^

TypeError: Cannot add property urls, object is not extensible
    at defaultConfig (/Users/ajciccarello/project/node_modules/pa11y-ci/bin/pa11y-ci.js:198:14)
    at /Users/ajciccarello/project/node_modules/pa11y-ci/bin/pa11y-ci.js:142:12
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v20.18.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions