-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Inline @babel/highlight
in @babel/code-frame
#16896
Conversation
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -521,7 +521,7 @@ function buildRollup(packages, buildStandalone) { | |||
// We have manually applied commonjs-esm interop to the source | |||
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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/highlight
is 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/highlight
that makes sense: one is https://github.com/facebook/flow/blob/2dc7cec37d7aa97f84640248d272ca38d982158e/packages/flow-upgrade/testUtils/codemodTestUtils.js#L15 (for which@babel/code-frame
would 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 ahighlight
function from@babel/code-frame
.highlight
function from@babel/code-frame
.Merging
@babel/highlight
into@babel/code-frame
means that we can fully remove thechalk
dependency, which is unused (but exposed as-is in the@babel/highlight
API throughgetChalk()
) and alone makes 60% of@babel/code-frame
's size. 🎉I will add
@babel/highlight
to the archive once this PR is merged.