Skip to content

Commit

Permalink
Make it work
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Jul 17, 2023
1 parent 0f6b02b commit f1718c7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
7 changes: 7 additions & 0 deletions packages/babel-highlight/src/chalk.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export * from "chalk-BABEL_8_BREAKING-true";

// TODO: Eventually remove the .default fallback when we fully migrate to chalk 5
declare const _default:
| typeof import("chalk-BABEL_8_BREAKING-false").default
| typeof import("chalk-BABEL_8_BREAKING-true").default;
export { _default as default };
10 changes: 10 additions & 0 deletions packages/babel-highlight/src/chalk.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/// <reference types="./chalk.d.ts" />

// Chalk provides its own type defintions, but yarn-plugin-conditions does not
// play well with them. Additionally, we want to provide the same "default"
// when using ESM and CJS (extracting default from CJS's module.exports).
// TODO: Remote whis when we fully migrate to chalk 5

export * from "chalk";
import _chalk from "chalk";
export default _chalk.default ?? _chalk;
6 changes: 1 addition & 5 deletions packages/babel-highlight/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ import {
isKeyword,
} from "@babel/helper-validator-identifier";

import _chalk, { supportsColor, Chalk, type ChalkInstance } from "chalk";
// TODO: Eventually remove the .default fallback when we fully migrate to chalk 5
const chalk =
(_chalk as unknown as typeof import("chalk-BABEL_8_BREAKING-false"))
.default ?? _chalk;
import chalk, { supportsColor, Chalk, type ChalkInstance } from "./chalk";

/**
* Names that are always allowed as identifiers, but also appear as keywords
Expand Down

0 comments on commit f1718c7

Please sign in to comment.