Closed JoshuaKGoldberg closed 5 years ago
I think I'm missing context here. Why are you importing this package that way?
@stephenmathieson sorry, I don't follow your question. Are you wondering why I'm importing the module like import { AxeBuilder } from "axe-webdriverjs"
instead of import * as AxeBuilder from "axe-webdriverjs"
? If that's what you intend to ask, it's because the spec for modules explicitly doesn't allow it. An ES6 module namespace object cannot be invoked as a function or with new.
@JoshuaKGoldberg right... We don't strictly support ES modules here. Instead, we use Node's funky interpretation of CommonJS (where a function/class can take the place of the pseudo "default" export). This was the standard for years, and is still the way many packages are written to date. I think you're probably looking for a TypeScript (or alike) compatible export, which would require us to provide AxeBuilder
on exports.default
. I'm happy to make this change and can do so tomorrow.
On a side note, wouldn't import Builder = require('axe-builder')
work?
This is not valid JavaScript:
See this SO answer:
...so what should happen instead is:
🙃.
Fortunately, this can be a purely additive change: somewhere in
lib/index.js
, you can add:...so that both the CommonJS-style
const AxeBuilder = require("axe-webdriverjs");
and ES-style above orconst AxeBuilder = require("axe-webdriverjs").AxeBuilder;
will work.