-
Notifications
You must be signed in to change notification settings - Fork 779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(imports): add doT
template engine
#1024
Conversation
This patch adds the [`doT`](https://npmjs.org/dot) template engine to `axe.imports`. This is required for a runtime localization (a WIP feature). A lot of hackery was required to get this working, since `doT` doesn't expose a UMD wrapper that our build system supports. Rather than attempting to get our existing tooling to "unwrap" `doT`'s custom UMD, I've decided to save a lot of time/effort and just wrap it in an IIFE. There are likely 1,000,000s of variations of UMD in the wild and it's unreasonable for us to attempt to support them all. The added IIFE method works in cases where the code functions exactly the same regarless of enviroment (this does not include libraries like Axios). IMHO the only reasonable solution to this problem is to use a proper bundler for building `axe-core`.
* @param {string} sourceUrl path to the distributable of the library | ||
* @param {string} sourceCode source code for the library | ||
* @param {Object} [options] Optional options | ||
* @property {Boolean} umd Does the library contain a UMD wrapper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, what's the distinction between param
and property
here in jsdoc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
property
is a member of the above param
build/tasks/generate-imports.js
Outdated
|
||
// If there was a global prior to our script, make sure we | ||
// "save" it (think "$.noConflict()"). | ||
var __old_global__ = global["${global}"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two global
variables in use here, so the code is a little hard to follow (the global
passed in and the variable set to the current scope). How can you reset to the old global when it has been overwritten with a new variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The passed global
is a library name. I'll rename to make that clearer.
To be sure its reset, see a few LOC below.
* develop: feat(imports): add `doT` template engine (#1024) doc: ensure client is closed doc: fix comment doc: fix "parity" typo doc: ensure user starts chrome chore(package): auto-format *.ts files (#1029) build: replace babel-preset-es2015 with babel-preset-env (#1027) chore: remove `.jshintrc` files (#1028) chore: add `.npmrc` (#1026) chore: upgrade Prettier and run the formatter (#1030) doc(examples): add simple CDP example ci: Speed up builds by caching node_modules (#1025)
This patch adds the
doT
template engine toaxe.imports
. This is required for a runtime localization (a WIP feature).We're continuing to use
doT
rather than replacing it with a maintained template engine because all of our rules/checks/messaging currently use it. Changing this now would be a very large task, which is outside of the scope of the feature I'm working on.A lot of hackery was required to get this working, since
doT
doesn't expose a UMD wrapper that our build system supports. Rather than attempting to get our existing tooling to "unwrap"doT
's custom UMD, I've decided to save a lot of time/effort and just wrap it in an IIFE. There are likely 1,000s of variations of UMD in the wild and it's unreasonable for us to attempt to support them all. The added IIFE method works in cases where the code functions exactly the same regarless of enviroment (this does not include libraries like Axios). IMHO the only reasonable solution to this problem is to use a proper bundler for buildingaxe-core
.Reviewer checks
Required fields, to be filled out by PR reviewer(s)