mirror of
https://github.com/denoland/deno.git
synced 2025-02-12 16:59:32 -05:00
Fix TypeScript exports in bundle
This commit is contained in:
parent
fcdfacc2de
commit
1e709aa348
3 changed files with 12 additions and 24 deletions
|
@ -137,13 +137,6 @@ function throwResolutionError(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ts.ScriptKind is not available at runtime, so local enum definition
|
|
||||||
enum ScriptKind {
|
|
||||||
JS = 1,
|
|
||||||
TS = 3,
|
|
||||||
JSON = 6
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A singleton class that combines the TypeScript Language Service host API
|
* A singleton class that combines the TypeScript Language Service host API
|
||||||
* with Deno specific APIs to provide an interface for compiling and running
|
* with Deno specific APIs to provide an interface for compiling and running
|
||||||
|
@ -626,13 +619,13 @@ export class DenoCompiler implements ts.LanguageServiceHost {
|
||||||
const suffix = fileName.substr(fileName.lastIndexOf(".") + 1);
|
const suffix = fileName.substr(fileName.lastIndexOf(".") + 1);
|
||||||
switch (suffix) {
|
switch (suffix) {
|
||||||
case "ts":
|
case "ts":
|
||||||
return ScriptKind.TS;
|
return ts.ScriptKind.TS;
|
||||||
case "js":
|
case "js":
|
||||||
return ScriptKind.JS;
|
return ts.ScriptKind.JS;
|
||||||
case "json":
|
case "json":
|
||||||
return ScriptKind.JSON;
|
return ts.ScriptKind.JSON;
|
||||||
default:
|
default:
|
||||||
return this._options.allowJs ? ScriptKind.JS : ScriptKind.TS;
|
return this._options.allowJs ? ts.ScriptKind.JS : ts.ScriptKind.TS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,6 @@ import * as ts from "typescript";
|
||||||
|
|
||||||
const { DenoCompiler } = compiler;
|
const { DenoCompiler } = compiler;
|
||||||
|
|
||||||
// Enums like this don't exist at runtime, so local copy
|
|
||||||
enum ScriptKind {
|
|
||||||
JS = 1,
|
|
||||||
TS = 3,
|
|
||||||
JSON = 6
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ModuleInfo {
|
interface ModuleInfo {
|
||||||
moduleName: string | null;
|
moduleName: string | null;
|
||||||
filename: string | null;
|
filename: string | null;
|
||||||
|
@ -466,11 +459,11 @@ test(function compilerGetScriptFileNames() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test(function compilerGetScriptKind() {
|
test(function compilerGetScriptKind() {
|
||||||
assertEqual(compilerInstance.getScriptKind("foo.ts"), ScriptKind.TS);
|
assertEqual(compilerInstance.getScriptKind("foo.ts"), ts.ScriptKind.TS);
|
||||||
assertEqual(compilerInstance.getScriptKind("foo.d.ts"), ScriptKind.TS);
|
assertEqual(compilerInstance.getScriptKind("foo.d.ts"), ts.ScriptKind.TS);
|
||||||
assertEqual(compilerInstance.getScriptKind("foo.js"), ScriptKind.JS);
|
assertEqual(compilerInstance.getScriptKind("foo.js"), ts.ScriptKind.JS);
|
||||||
assertEqual(compilerInstance.getScriptKind("foo.json"), ScriptKind.JSON);
|
assertEqual(compilerInstance.getScriptKind("foo.json"), ts.ScriptKind.JSON);
|
||||||
assertEqual(compilerInstance.getScriptKind("foo.txt"), ScriptKind.JS);
|
assertEqual(compilerInstance.getScriptKind("foo.txt"), ts.ScriptKind.JS);
|
||||||
});
|
});
|
||||||
|
|
||||||
test(function compilerGetScriptVersion() {
|
test(function compilerGetScriptVersion() {
|
||||||
|
|
|
@ -139,11 +139,13 @@ export default function makeConfig(commandOptions) {
|
||||||
commonjs({
|
commonjs({
|
||||||
namedExports: {
|
namedExports: {
|
||||||
// Static analysis of `typescript.js` does detect the exports properly, therefore
|
// Static analysis of `typescript.js` does detect the exports properly, therefore
|
||||||
// rollup requires them to be explicitly defined to avoid generating warnings
|
// rollup requires them to be explicitly defined to make them available in the
|
||||||
|
// bundle
|
||||||
[typescriptPath]: [
|
[typescriptPath]: [
|
||||||
"createLanguageService",
|
"createLanguageService",
|
||||||
"formatDiagnosticsWithColorAndContext",
|
"formatDiagnosticsWithColorAndContext",
|
||||||
"ModuleKind",
|
"ModuleKind",
|
||||||
|
"ScriptKind",
|
||||||
"ScriptSnapshot",
|
"ScriptSnapshot",
|
||||||
"ScriptTarget",
|
"ScriptTarget",
|
||||||
"version"
|
"version"
|
||||||
|
|
Loading…
Add table
Reference in a new issue