Commit 8f49061
authored
Allow running
This PR allows other repositories to depend on this repo as a VCS
requirement, then to run our scripts, like this:
```json
"scripts": {
"check": "node node_modules/qiskit-documentation/dist/commands/checkMetadata.js"
},
"dependencies": {
"qiskit-documentation": "qiskit/documentation#3422358984f9ede3a6ac8a2bbe7df517fbd306cb"
},
```
```
❯ npm run check
> my-function-docs@0.1.0 check:metadata
> node node_modules/qiskit-documentation/dist/commands/checkMetadata.js
```
`node_modules/qiskit-documentation` will include only the contents of
`src/js` but compiled to JavaScript, along with `package.json`. That
results in the other project bringing in all of the transitive
dependencies of this repo.
Running scripts locally still works.
## Migration to ES Modules
Before, we were using CommonJS for how imports and module loading works.
However, this was causing issues when trying to run in other repos. The
easiest fix was to migrate to ES Modules by setting `"type": "module"`
in `package.json`.
This required that we set a `.js` file extension in all of our import
statements, and that we use `lodash-es` rather than `lodash`.
## Migration to Playwright
I could not get Jest to play nicely with TypeScript & ES Modules. The
simplest fix was to migrate to Playwright.
We already use Playwright in qiskit-sphinx-theme, so this brings nice
consistency to the open source projects.
## Followup work: fix individual scripts
Some of the scripts may need changes to work in other repositories, like
our internal link checker. For now, `checkMetadata.ts` and
`checkExternalLinks.ts` definitely work.scripts/js from other Node projects (#1747)1 parent 3f89260 commit 8f49061
68 files changed
Lines changed: 2029 additions & 5616 deletions
File tree
- scripts/js
- commands
- api
- lib
- api
- __snapshots__
- conversionPipeline.test.ts-snapshots
- links
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
14 | | - | |
15 | 13 | | |
16 | 14 | | |
17 | | - | |
18 | 15 | | |
19 | 16 | | |
20 | 17 | | |
21 | | - | |
22 | 18 | | |
| 19 | + | |
| 20 | + | |
This file was deleted.
0 commit comments