Inline @babel/highlight in @babel/code-frame#16896
Inline @babel/highlight in @babel/code-frame#16896nicolo-ribaudo merged 6 commits intobabel:mainfrom
@babel/highlight in @babel/code-frame#16896Conversation
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/58238 |
00dc0f5 to
d6ce464
Compare
| return colors; | ||
| } | ||
| import { getDefs, isColorSupported } from "./defs.ts"; | ||
| import { highlight } from "./highlight.ts"; |
There was a problem hiding this comment.
Can we also export the highlight function? So that for @babel/highlight users, the can migrate to the highlight imported from @babel/code-frame when upgrading to Babel 8.
|
Adding this to a minor milestone due to the new exported |
c92df8e to
2c4f3a2
Compare
| // for library not in this monorepo | ||
| // https://github.com/babel/babel/pull/12795 | ||
| if (!id.startsWith("@babel/")) return "compat"; | ||
| if (!id.startsWith("@babel/")) return "default"; |
There was a problem hiding this comment.
Could you briefly explain why archived syntax plugins are using compat while other dependencies are using default? Intuitively we should apply the same interop for everything not in the monorepo.
There was a problem hiding this comment.
Docs: https://rollupjs.org/configuration-options/#output-interop
default matches what Node.js does, so it's what we should use for external packages. For syntax plugins it doesn't really matter, because they all have .default and .__esModule so the compat and default work the same. But yeah, lets use default everywhere.
@babel/highlightis only used in one of our packages:@babel/code-frame. I thus checked on npm, and noticed that it also has very few dependents in the wider ecosystem: just 40 :) https://www.npmjs.com/browse/depended/@babel/highlightI manually checked how it is used in packages that have been updated in the last year, and there are only two packages with usage of
@babel/highlightthat makes sense: one is https://github.com/facebook/flow/blob/2dc7cec37d7aa97f84640248d272ca38d982158e/packages/flow-upgrade/testUtils/codemodTestUtils.js#L15 (for which@babel/code-framewould also be ok, given that it's just to make test output more readable) and one is https://github.com/suchipi/at-js.It's not enough usage for us to justify maintaining it as a standalone package.
If anybody asks for it, we can export aWe now export ahighlightfunction from@babel/code-frame.highlightfunction from@babel/code-frame.Merging
@babel/highlightinto@babel/code-framemeans that we can fully remove thechalkdependency, which is unused (but exposed as-is in the@babel/highlightAPI throughgetChalk()) and alone makes 60% of@babel/code-frame's size. 🎉I will add
@babel/highlightto the archive once this PR is merged.