feat: add syntax replacements using web-features-codemods#207
feat: add syntax replacements using web-features-codemods#207
web-features-codemods#207Conversation
Co-authored-by: paul valladares <85648028+dreyfus92@users.noreply.github.com>
|
once #182 lands, we have a new sources option to let the user specify where their sources live. there's also a default glob in there (which we should move to a shared file). im not sure we need any code generation here as everything we need is already available from the package itself as far as i can tell. in that all exported codemods of web-features-codemods are applicable, so we can just put them into a usable shape at runtime. it looks like the fixable replacements script may be wrong and/or broken right now too outside of this as it writes to i think keeping this separate from module replacements makes sense as long as it happens as part of the analyze command |
|
Got it, shall I close this PR for now then? I will be happy to approach this once again once #182 is merged. |
|
feel free to leave it open and we can catch up from main once the other PR lands (should be soon). you could also rebase onto that branch for now so you can resolve the other things meanwhile |
Bumps the production-dependencies group with 1 update: [module-replacements](https://github.com/es-tooling/module-replacements). Updates `module-replacements` from 3.0.0-beta.0 to 3.0.0-beta.4 - [Release notes](https://github.com/es-tooling/module-replacements/releases) - [Commits](e18e/module-replacements@3.0.0-beta.0...3.0.0-beta.4) --- updated-dependencies: - dependency-name: module-replacements dependency-version: 3.0.0-beta.4 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: production-dependencies ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
We moved the module-replacements repo to e18e now, so these links need updating.
119f35a to
4990e4d
Compare
|
@43081j
I will be working on tests next so any inputs on potential test cases will be appreciated. On a side note, it looks like we can get rid of code generation for the module replacement codemods too, unless there is another reason its being done this way currently? |
| const SOURCE_GLOB = ['**/*.{js,ts,mjs,cjs,jsx,tsx}']; | ||
| const SOURCE_IGNORE = [ | ||
| '**/node_modules/**', | ||
| '**/dist/**', | ||
| '**/build/**', | ||
| '**/coverage/**', | ||
| '**/lib/**' | ||
| ]; |
There was a problem hiding this comment.
we should de-dupe these into a shared util the corejs analysis can use too
| import * as webFeatureCodemodExports from '@e18e/web-features-codemods'; | ||
| import type {AnalysisContext, ReportPluginResult} from '../types.js'; | ||
|
|
||
| interface WebFeatureCodemod { |
There was a problem hiding this comment.
we can probably import Codemod from @e18e/web-features-codemods/lib/shared.js but really should be exporting that upstream in the codemods package too.
i will fix that meanwhile
|
i caught up from main for you dont worry about rebasing it all if its a pain as we will squash it anyway in the end. left a couple of comments too. for tests, we should at least have:
in all cases, just use |
Looking to help close #128 eventually.
For now, this PR adds a
fixable-syntax-replacement.tsfile and a generator script, similar to how module replacements are handled in the existing project.I've also added a simple plugin that checks the source files for possible syntax replacements when the analyze command is run, to see if this aligns with what you have planned.
I'll continue working on this PR but I have a couple of things to clarify:
.jsand.tsin the cwd, but should we only check in the src directory? Are there plans to let the user choose this when running the command?Any other feedback is appreciated since I'm new to this codebase.