From 93cf65d80423ec1b89f413415a7329e062ff8854 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Mon, 25 Jan 2021 19:54:29 -0500 Subject: [PATCH] Revert "work around mysterious test failure and add TODO" This reverts commit c4419007f0a43d1fb7f6fcb15b4a143783ae5c03. --- .../samples/attached-sourcemap/_config.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/test/sourcemaps/samples/attached-sourcemap/_config.js b/test/sourcemaps/samples/attached-sourcemap/_config.js index 4e04fb0446..6d9786f6b0 100644 --- a/test/sourcemaps/samples/attached-sourcemap/_config.js +++ b/test/sourcemaps/samples/attached-sourcemap/_config.js @@ -2,16 +2,6 @@ import MagicString from 'magic-string'; let indent_size = 4; let comment_multi = true; - -// TODO -// Using magic-string's own .toUrl() method results in mysterious runtime failures. -// If tests are being run in `PUBLISH=true` mode AND at least one runtime test has been run prior to this test, then magic-string's btoa implementation fails with window not being declared. This is despite it previously checking that window.btoa is available. Presumably there's some sort of context thing going on, either with JSDOM or with Node itself. -// The tests pass when they're not run with `PUBLISH=true` (meaning, they currently pass in CI), and they also pass if you skip all runtime tests. -// I've spent too much time on this already, so for now to unblock the release, I am using the following workaround, which manually serializes the sourcemaps using Node Buffer APIs. -function toUrl(map) { - return 'data:application/json;charset=utf-8;base64,' + Buffer.from(map.toString(), 'utf-8').toString('base64'); -} - function get_processor(tag_name, search, replace) { return { [tag_name]: ({ content, filename }) => { @@ -29,8 +19,8 @@ function get_processor(tag_name, search, replace) { const map_opts = { source: filename, hires: true, includeContent: false }; const map = ms.generateMap(map_opts); const attach_line = (tag_name == 'style' || comment_multi) - ? `\n/*# sourceMappingURL=${toUrl(map)} */` - : `\n//# sourceMappingURL=${toUrl(map)}` // only in script + ? `\n/*# sourceMappingURL=${map.toUrl()} */` + : `\n//# sourceMappingURL=${map.toUrl()}` // only in script ; code = ms.toString() + attach_line;