Skip to content

Commit

Permalink
Revert "Register highlight languages on demand (make Parcel 1.5 MB sm…
Browse files Browse the repository at this point in the history
…aller)" (#6485)
  • Loading branch information
devongovett committed Jun 20, 2021
1 parent cf17201 commit e63235f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
3 changes: 1 addition & 2 deletions packages/core/codeframe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
"chalk": "^4.1.0",
"emphasize": "^4.2.0",
"slice-ansi": "^4.0.0",
"string-width": "^4.2.0",
"highlight.js": "~10.4.0"
"string-width": "^4.2.0"
},
"devDependencies": {
"strip-ansi": "^6.0.0"
Expand Down
11 changes: 1 addition & 10 deletions packages/core/codeframe/src/codeframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import type {DiagnosticCodeHighlight} from '@parcel/diagnostic';

import chalk from 'chalk';
import emphasize from 'emphasize/lib/core';
import emphasize from 'emphasize';
import stringWidth from 'string-width';
import sliceAnsi from 'slice-ansi';

Expand All @@ -27,18 +27,9 @@ const TAB_REPLACE_REGEX = /\t/g;
const TAB_REPLACEMENT = ' ';
const DEFAULT_TERMINAL_WIDTH = 80;

const registeredLanguages = new Map();

const highlightSyntax = (txt: string, lang?: string): string => {
if (lang) {
try {
if (!registeredLanguages.get(lang)) {
// TODO use dynamic import
// $FlowFixMe flow doesn't support string interpolation inside require!
const syntax = require(`highlight.js/lib/languages/${lang}`);
emphasize.registerLanguage(lang, syntax);
registeredLanguages.set(lang, true);
}
return emphasize.highlight(lang, txt).value;
} catch (e) {
// fallback for unknown languages...
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8101,10 +8101,10 @@ listr2@^2.1.0:
rxjs "^6.5.5"
through "^2.3.8"

lmdb-store@^1.5.2:
version "1.5.2"
resolved "https://registry.yarnpkg.com/lmdb-store/-/lmdb-store-1.5.2.tgz#11f4bef7f20b804f8b95e5984a2a153dc314708d"
integrity sha512-xQcy1Mk86SN1f+viX3YqTkNsRAiawSeUv27B36H2syK2TsNQyBPqk72QHqTdoIsFqdO7KeXK2a8Ch5cG/viHaA==
lmdb-store@^1.5.4:
version "1.5.5"
resolved "https://registry.yarnpkg.com/lmdb-store/-/lmdb-store-1.5.5.tgz#b51f5d045bf0fbae205e31eab781900be3b25ad9"
integrity sha512-EwCn+eSGH1XD35qaDzbHTYMig+Aj+kBbCpxWHzhtrIBJpFYq5uoBo4zWG4JRFxsbfonFELhuiyX0QokISIxzsQ==
dependencies:
mkdirp "^1.0.4"
nan "^2.14.2"
Expand Down

0 comments on commit e63235f

Please sign in to comment.