-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #998 from microsoft/support-scripty
Adds global versions of the @ts/* deps
- Loading branch information
Showing
12 changed files
with
89 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// @ts-check | ||
|
||
// Creates a web version of tstwoslash which sets a global of 'tstwoslash'. | ||
// Relies on tsvfs already existing | ||
|
||
const fs = require("fs") | ||
const path = require("path") | ||
|
||
const esm = fs.readFileSync(path.join(__dirname, "..", "dist", "twoslash.esm.js"), "utf8") | ||
const body = esm | ||
.replace("import {", "const {") | ||
.replace("} from '@typescript/vfs';", "} = globals.tsvfs") | ||
.replace("export {", "const twoslash = {") | ||
const prefix = ` | ||
const getGlobal = function () { | ||
if (typeof self !== 'undefined') { return self; } | ||
if (typeof window !== 'undefined') { return window; } | ||
if (typeof global !== 'undefined') { return global; } | ||
throw new Error('unable to locate global object'); | ||
}; | ||
const globals = getGlobal(); | ||
if (typeof globals.tsvfs === 'undefined') throw new Error("Could not find tsvfs on the global object") | ||
` | ||
|
||
const suffix = ` | ||
globals.twoslash = twoslash` | ||
|
||
fs.writeFileSync(path.join(__dirname, "..", "dist", "twoslash.globals.js"), prefix + body + suffix, "utf8") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// @ts-check | ||
|
||
// Creates a web version of tsvfs which sets a global of 'tsvfs'. | ||
|
||
const fs = require("fs") | ||
const path = require("path") | ||
|
||
const esm = fs.readFileSync(path.join(__dirname, "..", "dist", "vfs.esm.js"), "utf8") | ||
const body = esm.replace("export {", "const tsvfs = {") | ||
const suffix = ` | ||
const getGlobal = function () { | ||
if (typeof self !== 'undefined') { return self; } | ||
if (typeof window !== 'undefined') { return window; } | ||
if (typeof global !== 'undefined') { return global; } | ||
throw new Error('unable to locate global object'); | ||
}; | ||
const globals = getGlobal(); | ||
globals.tsvfs = tsvfs; | ||
` | ||
|
||
fs.writeFileSync(path.join(__dirname, "..", "dist", "vfs.globals.js"), body + suffix, "utf8") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters