Skip to content

Commit

Permalink
fix(build): use builder pattern when creating unicode escape sequence…
Browse files Browse the repository at this point in the history
…s to solve problems in legacy browsers
  • Loading branch information
wessberg committed Oct 23, 2020
1 parent 1262d65 commit ea64e5c
Show file tree
Hide file tree
Showing 2 changed files with 524 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/build/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import {BROTLI_OPTIONS} from "./options/brotli-options";
import {ZLIB_OPTIONS} from "./options/zlib-options";
import {IPolyfillFeature} from "../polyfill/i-polyfill-feature";
import {build as esbuild} from "esbuild";
import {transform} from "@swc/core";
import {tmpdir} from "os";
import {join} from "path";
import {generateRandomHash} from "../util/hash-util/hash-util";
import {unlinkSync, writeFileSync} from "fs";
import {transform} from "@swc/core";
import {UnicodeEscapeRestorer} from "./swc/unicode-escape-restorer";

function stringifyPolyfillFeature(feature: IPolyfillFeature): string {
const metaEntries = Object.entries(feature.meta);
Expand Down Expand Up @@ -90,7 +91,9 @@ export async function build({paths, features, featuresRequested, userAgent, cont
filename: virtualOutputFileName,
jsc: {
target: ecmaVersion
}
},
// replace unicode characters with a builder pattern to fix issues in legacy browsers
plugin: m => new UnicodeEscapeRestorer().visitProgram(m)
}));
}

Expand Down
Loading

0 comments on commit ea64e5c

Please sign in to comment.