build(deps): update strip-ansi / ansi-regex to 7.x
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 807
- Avg merge
- 10h 12m
- Merged PRs (30d)
- 7
Description
Currently blocked. See also https://github.com/aws/aws-toolkit-vscode/issues/2230#issuecomment-950231166
In order to update this dependency we need to resolve the following:
- strip-ansi 7.0 is a "pure ESM" module which causes the build to fail:
```
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /codebuild/output/src051529497/src/github.com/aws/aws-toolkit-vscode/node_modules/strip-ansi/index.js
require() of ES modules is not supported.
require() of /codebuild/output/src051529497/src/github.com/aws/aws-toolkit-vscode/node_modules/strip-ansi/index.js from /codebuild/output/src051529497/src/github.com/aws/aws-toolkit-vscode/dist/src/shared/utilities/textUtilities.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /codebuild/output/src051529497/src/github.com/aws/aws-toolkit-vscode/node_modules/strip-ansi/package.json.
```
- https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
- switching to `import stripAnsi from 'strip-ansi'` fails in a different way
- [setting](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#es2020-for-target-and-module) `module": "es2020"` in `tsconfig.json` then causes the build to fail on the presence of `import` in `build-scripts/`
- https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#es2020-for-target-and-module
## Status
1. ~~strip-ansi has not actually fixed any bugs or added features so we don't need to upgrade.~~
- It does bump its transitive dependency on `ansi-regex` which fixes a security/performance bug: https://cwe.mitre.org/data/definitions/1333.html
2. we need to wait until
1. we can bump the minimum node version
2. we are certain that typescript + vscode extensions work with ESM
Contributor guide
Research direction
Start by reading tsconfig.json, build-scripts/, and the linked discussion about the ESM failure; compare the CommonJS require path in dist/src/shared/utilities/textUtilities.js with the documented strip-ansi 7.x behavior. The work is done when strip-ansi and ansi-regex can be updated without the build failing, after the Node and TypeScript/VS Code extension compatibility concerns are resolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- build-system
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100