1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 15:24:46 -05:00

Generate declarations

This commit is contained in:
Kitson Kelly 2018-08-07 13:27:31 -07:00 committed by Ryan Dahl
parent eda1c7b74a
commit 817380a2d9
14 changed files with 297 additions and 107 deletions

View file

@ -197,19 +197,53 @@ flatbuffer("msg_cpp") {
] ]
} }
# Generates type declarations for files that need to be included
# in the runtime bundle
run_node("gen_declarations") {
out_dir = target_gen_dir
sources = [
"js/console.ts",
"js/deno.ts",
"js/globals.ts",
"js/os.ts",
"js/tsconfig.generated.json",
"js/util.ts",
]
outputs = [
out_dir + "/js/console.d.ts",
out_dir + "/js/deno.d.ts",
out_dir + "/js/globals.d.ts",
out_dir + "/js/os.d.ts",
out_dir + "/js/util.d.ts",
]
deps = [
":msg_ts",
]
args = [
"./node_modules/typescript/bin/tsc",
"-p",
rebase_path("js/tsconfig.generated.json", root_build_dir),
"--baseUrl",
rebase_path(root_build_dir),
"--outDir",
rebase_path(out_dir),
]
}
run_node("bundle") { run_node("bundle") {
out_dir = "$target_gen_dir/bundle/" out_dir = "$target_gen_dir/bundle/"
sources = [ sources = [
"js/assets.ts", "js/assets.ts",
"js/console.ts", "js/console.ts",
"js/deno.d.ts",
"js/globals.ts", "js/globals.ts",
"js/lib.globals.d.ts", "js/lib.globals.d.ts",
"js/main.ts", "js/main.ts",
"js/os.ts", "js/os.ts",
"js/plugins.d.ts",
"js/runtime.ts", "js/runtime.ts",
"js/types.ts", "js/types.d.ts",
"js/util.ts", "js/util.ts",
"js/v8_source_maps.ts",
"rollup.config.js", "rollup.config.js",
"src/msg.fbs", "src/msg.fbs",
"tsconfig.json", "tsconfig.json",
@ -219,6 +253,7 @@ run_node("bundle") {
out_dir + "main.js.map", out_dir + "main.js.map",
] ]
deps = [ deps = [
":gen_declarations",
":msg_ts", ":msg_ts",
] ]
args = [ args = [

View file

@ -5,11 +5,15 @@
// There is a rollup plugin that will inline any module ending with `!string` // There is a rollup plugin that will inline any module ending with `!string`
// tslint:disable:max-line-length // tslint:disable:max-line-length
import denoDts from "/js/deno.d.ts!string";
// import libDts from "/third_party/node_modules/typescript/lib/lib.d.ts!string"; // Generated definitions
import globalsDts from "/js/lib.globals.d.ts!string"; import consoleDts from "gen/js/console.d.ts!string";
// import libDomD qts from "/third_party/node_modules/typescript/lib/lib.dom.d.ts!string"; import denoDts from "gen/js/deno.d.ts!string";
// import libDomIterableDts from "/third_party/node_modules/typescript/lib/lib.dom.iterable.d.ts!string"; import globalsDts from "gen/js/globals.d.ts!string";
import osDts from "gen/js/os.d.ts!string";
import utilDts from "gen/js/util.d.ts!string";
// Static libraries
import libEs2015Dts from "/third_party/node_modules/typescript/lib/lib.es2015.d.ts!string"; import libEs2015Dts from "/third_party/node_modules/typescript/lib/lib.es2015.d.ts!string";
import libEs2015CollectionDts from "/third_party/node_modules/typescript/lib/lib.es2015.collection.d.ts!string"; import libEs2015CollectionDts from "/third_party/node_modules/typescript/lib/lib.es2015.collection.d.ts!string";
import libEs2015CoreDts from "/third_party/node_modules/typescript/lib/lib.es2015.core.d.ts!string"; import libEs2015CoreDts from "/third_party/node_modules/typescript/lib/lib.es2015.core.d.ts!string";
@ -38,17 +42,23 @@ import libEsnextAsynciterablesDts from "/third_party/node_modules/typescript/lib
import libEsnextDts from "/third_party/node_modules/typescript/lib/lib.esnext.d.ts!string"; import libEsnextDts from "/third_party/node_modules/typescript/lib/lib.esnext.d.ts!string";
import libEsnextIntlDts from "/third_party/node_modules/typescript/lib/lib.esnext.intl.d.ts!string"; import libEsnextIntlDts from "/third_party/node_modules/typescript/lib/lib.esnext.intl.d.ts!string";
import libEsnextSymbolDts from "/third_party/node_modules/typescript/lib/lib.esnext.symbol.d.ts!string"; import libEsnextSymbolDts from "/third_party/node_modules/typescript/lib/lib.esnext.symbol.d.ts!string";
// import libScripthost from "/third_party/node_modules/typescript/lib/lib.scripthost.d.ts!string"; import libGlobalsDts from "/js/lib.globals.d.ts!string";
// import libWebworkerImportscripts from "/third_party/node_modules/typescript/lib/lib.webworker.importscripts.d.ts!string";
// Static definitions
import typescriptDts from "/third_party/node_modules/typescript/lib/typescript.d.ts!string"; import typescriptDts from "/third_party/node_modules/typescript/lib/typescript.d.ts!string";
import typesDts from "/js/types.d.ts!string";
// tslint:enable:max-line-length
// prettier-ignore // prettier-ignore
export const assetSourceCode: { [key: string]: string } = { export const assetSourceCode: { [key: string]: string } = {
// Generated definitions
"console.d.ts": consoleDts,
"deno.d.ts": denoDts, "deno.d.ts": denoDts,
// "lib.d.ts": libDts, "globals.d.ts": globalsDts,
"lib.globals.d.ts": globalsDts, "os.d.ts": osDts,
// "lib.dom.d.ts": libDomDts, "util.d.ts": utilDts,
// "lib.dom.iterable.d.ts": libDomIterableDts,
// Static libraries
"lib.es2015.collection.d.ts": libEs2015CollectionDts, "lib.es2015.collection.d.ts": libEs2015CollectionDts,
"lib.es2015.core.d.ts": libEs2015CoreDts, "lib.es2015.core.d.ts": libEs2015CoreDts,
"lib.es2015.d.ts": libEs2015Dts, "lib.es2015.d.ts": libEs2015Dts,
@ -61,32 +71,25 @@ export const assetSourceCode: { [key: string]: string } = {
"lib.es2015.symbol.wellknown.d.ts": libEs2015SymbolWellknownDts, "lib.es2015.symbol.wellknown.d.ts": libEs2015SymbolWellknownDts,
"lib.es2016.array.include.d.ts": libEs2016ArrayIncludeDts, "lib.es2016.array.include.d.ts": libEs2016ArrayIncludeDts,
"lib.es2016.d.ts": libEs2016Dts, "lib.es2016.d.ts": libEs2016Dts,
//"lib.es2016.full.d.ts": readFileSync(__dirname + "/../third_party/node_modules/typescript/lib/lib.es2016.full.d.ts", "utf8"),
"lib.es2017.d.ts": libEs2017Dts, "lib.es2017.d.ts": libEs2017Dts,
//"lib.es2017.full.d.ts": readFileSync(__dirname + "/../third_party/node_modules/typescript/lib/lib.es2017.full.d.ts", "utf8"),
"lib.es2017.intl.d.ts": libEs2017IntlDts, "lib.es2017.intl.d.ts": libEs2017IntlDts,
"lib.es2017.object.d.ts": libEs2017ObjectDts, "lib.es2017.object.d.ts": libEs2017ObjectDts,
"lib.es2017.sharedmemory.d.ts": libEs2017SharedmemoryDts, "lib.es2017.sharedmemory.d.ts": libEs2017SharedmemoryDts,
"lib.es2017.string.d.ts": libEs2017StringDts, "lib.es2017.string.d.ts": libEs2017StringDts,
"lib.es2017.typedarrays.d.ts": libEs2017TypedarraysDts, "lib.es2017.typedarrays.d.ts": libEs2017TypedarraysDts,
"lib.es2018.d.ts": libEs2018Dts, "lib.es2018.d.ts": libEs2018Dts,
//"lib.es2018.full.d.ts": readFileSync(__dirname + "/../third_party/node_modules/typescript/lib/lib.es2018.full.d.ts", "utf8"),
"lib.es2018.intl.d.ts": libEs2018IntlDts, "lib.es2018.intl.d.ts": libEs2018IntlDts,
"lib.es2018.promise.d.ts": libEs2018PromiseDts, "lib.es2018.promise.d.ts": libEs2018PromiseDts,
"lib.es2018.regexp.d.ts": libEs2018RegexpDts, "lib.es2018.regexp.d.ts": libEs2018RegexpDts,
"lib.es5.d.ts": libEs5Dts, "lib.es5.d.ts": libEs5Dts,
//"lib.es6.d.ts": readFileSync(__dirname + "/../third_party/node_modules/typescript/lib/lib.es6.d.ts", "utf8"),
"lib.esnext.d.ts": libEsnextDts, "lib.esnext.d.ts": libEsnextDts,
"lib.esnext.array.d.ts": libEsnextArrayDts, "lib.esnext.array.d.ts": libEsnextArrayDts,
"lib.esnext.asynciterable.d.ts": libEsnextAsynciterablesDts, "lib.esnext.asynciterable.d.ts": libEsnextAsynciterablesDts,
"lib.esnext.intl.d.ts": libEsnextIntlDts, "lib.esnext.intl.d.ts": libEsnextIntlDts,
"lib.esnext.symbol.d.ts": libEsnextSymbolDts, "lib.esnext.symbol.d.ts": libEsnextSymbolDts,
//"lib.esnext.full.d.ts": readFileSync(__dirname + "/../third_party/node_modules/typescript/lib/lib.esnext.full.d.ts", "utf8"), "lib.globals.d.ts": libGlobalsDts,
// "lib.scripthost.d.ts": libScripthost,
// "lib.webworker.d.ts": libWebworker, // Static definitions
// "lib.webworker.importscripts.d.ts": libWebworkerImportscripts,
//"protocol.d.ts": readFileSync(__dirname + "/../third_party/node_modules/typescript/lib/protocol.d.ts", "utf8"),
//"tsserverlibrary.d.ts": readFileSync(__dirname + "/../third_party/node_modules/typescript/lib/tsserverlibrary.d.ts", "utf8"),
"typescript.d.ts": typescriptDts, "typescript.d.ts": typescriptDts,
//"typescriptServices.d.ts": readFileSync(__dirname + "/../third_party/node_modules/typescript/lib/typescriptServices.d.ts", "utf8"), "types.d.ts": typesDts,
}; };

10
js/deno.d.ts vendored
View file

@ -1,10 +0,0 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
type MessageCallback = (msg: Uint8Array) => void;
interface Deno {
recv(cb: MessageCallback): void;
send(msg: ArrayBufferView): null | Uint8Array;
print(x: string): void;
}
declare let deno: Deno;

View file

@ -1,5 +1,5 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license. // Copyright 2018 the Deno authors. All rights reserved. MIT license.
// Public deno module. // Public deno module.
// TODO get rid of deno.d.ts // TODO get rid of deno.d.ts
export { pub, sub } from "./dispatch"; // export { pub, sub } from "./dispatch";
export { readFileSync, writeFileSync } from "./os"; export { readFileSync, writeFileSync } from "./os";

View file

@ -1,5 +1,25 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license. // Copyright 2018 the Deno authors. All rights reserved. MIT license.
import { Console } from "./console";
declare global {
type MessageCallback = (msg: Uint8Array) => void;
interface Deno {
print(text: string): void;
recv(cb: MessageCallback): void;
send(msg: ArrayBufferView): Uint8Array | null;
}
interface Window {
console: Console;
}
const console: Console;
const deno: Readonly<Deno>;
const window: Window;
}
// If you use the eval function indirectly, by invoking it via a reference // If you use the eval function indirectly, by invoking it via a reference
// other than eval, as of ECMAScript 5 it works in the global scope rather than // other than eval, as of ECMAScript 5 it works in the global scope rather than
// the local scope. This means, for instance, that function declarations create // the local scope. This means, for instance, that function declarations create
@ -20,7 +40,6 @@ window["window"] = window; // Create a window object.
// window["clearTimeout"] = timer.clearTimer; // window["clearTimeout"] = timer.clearTimer;
// window["clearInterval"] = timer.clearTimer; // window["clearInterval"] = timer.clearTimer;
import { Console } from "./console";
window["console"] = new Console(); window["console"] = new Console();
// import { fetch } from "./fetch"; // import { fetch } from "./fetch";

24
js/lib.globals.d.ts vendored
View file

@ -6,36 +6,14 @@
/// <reference lib="esnext" /> /// <reference lib="esnext" />
// TODO generate `console.d.ts` and inline it in `assets.ts` and remove import "gen/js/globals";
// declaration of `Console`
// import { Console } from 'gen/console';
declare class Console {
// tslint:disable-next-line:no-any
log(...args: any[]): void;
// tslint:disable-next-line:no-any
debug(...args: any[]): void;
// tslint:disable-next-line:no-any
info(...args: any[]): void;
// tslint:disable-next-line:no-any
warn(...args: any[]): void;
// tslint:disable-next-line:no-any
error(...args: any[]): void;
// tslint:disable-next-line:no-any
assert(condition: boolean, ...args: any[]): void;
}
interface Window { interface Window {
console: Console;
// TODO(ry) These shouldn't be global. // TODO(ry) These shouldn't be global.
mainSource: string; mainSource: string;
setMainSourceMap(sm: string): void; setMainSourceMap(sm: string): void;
} }
// Globals in the runtime environment
declare let console: Console;
declare const window: Window;
// TODO(ry) These shouldn't be global. // TODO(ry) These shouldn't be global.
declare let mainSource: string; declare let mainSource: string;
declare function setMainSourceMap(sm: string): void; declare function setMainSourceMap(sm: string): void;

View file

@ -1,6 +1,5 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license. // Copyright 2018 the Deno authors. All rights reserved. MIT license.
// tslint:disable-next-line:no-reference // tslint:disable-next-line:no-reference
/// <reference path="deno.d.ts" />
import { flatbuffers } from "flatbuffers"; import { flatbuffers } from "flatbuffers";
import { deno as fbs } from "gen/msg_generated"; import { deno as fbs } from "gen/msg_generated";
import { assert, log, assignCmdId } from "./util"; import { assert, log, assignCmdId } from "./util";

View file

@ -166,12 +166,11 @@ export function resolveModule(
util.log("resolveModule", { moduleSpecifier, containingFile }); util.log("resolveModule", { moduleSpecifier, containingFile });
util.assert(moduleSpecifier != null && moduleSpecifier.length > 0); util.assert(moduleSpecifier != null && moduleSpecifier.length > 0);
let filename: string, sourceCode: string, outputCode: string; let filename: string, sourceCode: string, outputCode: string;
if ( if (moduleSpecifier.startsWith(ASSETS) || containingFile.startsWith(ASSETS)) {
moduleSpecifier.startsWith(ASSETS) ||
containingFile.startsWith(ASSETS)
) {
// Assets are compiled into the runtime javascript bundle. // Assets are compiled into the runtime javascript bundle.
const assetName = moduleSpecifier.split("/").pop(); const moduleId = moduleSpecifier.split("/").pop();
const assetName = moduleId.includes(".") ? moduleId : `${moduleId}.d.ts`;
util.assert(assetName in assetSourceCode);
sourceCode = assetSourceCode[assetName]; sourceCode = assetSourceCode[assetName];
filename = ASSETS + assetName; filename = ASSETS + assetName;
} else { } else {
@ -330,7 +329,7 @@ class TypeScriptHost implements ts.LanguageServiceHost {
} }
getDefaultLibFileName(options: ts.CompilerOptions): string { getDefaultLibFileName(options: ts.CompilerOptions): string {
const fn = "lib.deno.d.ts"; // ts.getDefaultLibFileName(options); const fn = "lib.globals.d.ts"; // ts.getDefaultLibFileName(options);
util.log("getDefaultLibFileName", fn); util.log("getDefaultLibFileName", fn);
const m = resolveModule(fn, ASSETS); const m = resolveModule(fn, ASSETS);
return m.fileName; return m.fileName;
@ -354,7 +353,9 @@ class TypeScriptHost implements ts.LanguageServiceHost {
return undefined; return undefined;
} }
} }
const isExternalLibraryImport = false; // This flags to the compiler to not go looking to transpile functional
// code, anything that is in `/$asset$/` is just library code
const isExternalLibraryImport = resolvedFileName.startsWith(ASSETS);
return { resolvedFileName, isExternalLibraryImport }; return { resolvedFileName, isExternalLibraryImport };
}); });
} }

View file

@ -0,0 +1,16 @@
{
// This configuration file provides the tsc configuration for generating
// definitions for the runtime, which are then inlined via the `js/assets.ts`
// module into the bundle to be available for type checking at runtime
// See also gen_declarations in //BUILD.gn
"extends": "../tsconfig.json",
"compilerOptions": {
"declaration": true,
"declarationMap": true,
},
"files": [
"../node_modules/typescript/lib/lib.esnext.d.ts",
"./deno.ts",
"./globals.ts"
]
}

134
js/types.d.ts vendored Normal file
View file

@ -0,0 +1,134 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
export type TypedArray = Uint8Array | Float32Array | Int32Array;
export interface ModuleInfo {
moduleName?: string;
filename?: string;
sourceCode?: string;
outputCode?: string;
}
// Following definitions adapted from:
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/index.d.ts
// Type definitions for Node.js 10.3.x
// Definitions by: Microsoft TypeScript <http://typescriptlang.org>
// DefinitelyTyped <https://github.com/DefinitelyTyped/DefinitelyTyped>
// Parambir Singh <https://github.com/parambirs>
// Christian Vaagland Tellnes <https://github.com/tellnes>
// Wilco Bakker <https://github.com/WilcoBakker>
// Nicolas Voigt <https://github.com/octo-sniffle>
// Chigozirim C. <https://github.com/smac89>
// Flarna <https://github.com/Flarna>
// Mariusz Wiktorczyk <https://github.com/mwiktorczyk>
// wwwy3y3 <https://github.com/wwwy3y3>
// Deividas Bakanas <https://github.com/DeividasBakanas>
// Kelvin Jin <https://github.com/kjin>
// Alvis HT Tang <https://github.com/alvis>
// Sebastian Silbermann <https://github.com/eps1lon>
// Hannes Magnusson <https://github.com/Hannes-Magnusson-CK>
// Alberto Schiabel <https://github.com/jkomyno>
// Klaus Meinhardt <https://github.com/ajafff>
// Huw <https://github.com/hoo29>
// Nicolas Even <https://github.com/n-e>
// Bruno Scheufler <https://github.com/brunoscheufler>
// Mohsen Azimi <https://github.com/mohsen1>
// Hoàng Văn Khải <https://github.com/KSXGitHub>
// Alexander T. <https://github.com/a-tarasyuk>
// Lishude <https://github.com/islishude>
// Andrew Makarov <https://github.com/r3nya>
export interface CallSite {
/**
* Value of "this"
*/
getThis(): any;
/**
* Type of "this" as a string.
* This is the name of the function stored in the constructor field of
* "this", if available. Otherwise the object's [[Class]] internal
* property.
*/
getTypeName(): string | null;
/**
* Current function
*/
getFunction(): Function | undefined;
/**
* Name of the current function, typically its name property.
* If a name property is not available an attempt will be made to try
* to infer a name from the function's context.
*/
getFunctionName(): string | null;
/**
* Name of the property [of "this" or one of its prototypes] that holds
* the current function
*/
getMethodName(): string | null;
/**
* Name of the script [if this function was defined in a script]
*/
getFileName(): string | null;
/**
* Get the script name or source URL for the source map
*/
getScriptNameOrSourceURL(): string;
/**
* Current line number [if this function was defined in a script]
*/
getLineNumber(): number | null;
/**
* Current column number [if this function was defined in a script]
*/
getColumnNumber(): number | null;
/**
* A call site object representing the location where eval was called
* [if this function was created using a call to eval]
*/
getEvalOrigin(): string | undefined;
/**
* Is this a toplevel invocation, that is, is "this" the global object?
*/
isToplevel(): boolean;
/**
* Does this call take place in code defined by a call to eval?
*/
isEval(): boolean;
/**
* Is this call in native V8 code?
*/
isNative(): boolean;
/**
* Is this a constructor call?
*/
isConstructor(): boolean;
}
declare global {
// Declare "static" methods in Error
interface ErrorConstructor {
/** Create .stack property on a target object */
captureStackTrace(targetObject: Object, constructorOpt?: Function): void;
/**
* Optional override for formatting stack traces
*
* @see https://github.com/v8/v8/wiki/Stack%20Trace%20API#customizing-stack-traces
*/
prepareStackTrace?: (err: Error, stackTraces: CallSite[]) => any;
stackTraceLimit: number;
}
}

View file

@ -1,9 +0,0 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
export type TypedArray = Uint8Array | Float32Array | Int32Array;
export interface ModuleInfo {
moduleName?: string;
filename?: string;
sourceCode?: string;
outputCode?: string;
}

View file

@ -2,16 +2,11 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license. // Copyright 2018 the Deno authors. All rights reserved. MIT license.
// Originated from source-map-support but has been heavily modified for deno. // Originated from source-map-support but has been heavily modified for deno.
// Because NodeJS.CallSite and Error.prepareStackTrace are used we add a
// dependency on the Node types.
// TODO(ry) Ideally this triple slash directive should be removed as we only
// need CallSite and Error.prepareStackTrace but nothing else.
/// <reference types="node" />
import { SourceMapConsumer, MappedPosition } from "source-map"; import { SourceMapConsumer, MappedPosition } from "source-map";
import { RawSourceMap } from "source-map"; import { RawSourceMap } from "source-map";
import * as base64 from "base64-js"; import * as base64 from "base64-js";
import { arrayToStr } from "./util"; import { arrayToStr } from "./util";
import { CallSite } from "./types";
const consumers = new Map<string, SourceMapConsumer>(); const consumers = new Map<string, SourceMapConsumer>();
@ -22,10 +17,6 @@ interface Options {
installPrepareStackTrace: boolean; installPrepareStackTrace: boolean;
} }
interface CallSite extends NodeJS.CallSite {
getScriptNameOrSourceURL(): string;
}
interface Position { interface Position {
source: string; // Filename source: string; // Filename
column: number; column: number;

View file

@ -24,6 +24,15 @@ const tsconfigOverride = {
} }
}; };
// when the build path is not a child of the root of the project path
// TypeScript will output resources following the same path structure,
// `BASEPATH` will be a relative path to the root of the source project which
// we can use to determine what TypeScript would have output
const basePathParts = process.env.BASEPATH.split("/");
while (basePathParts[0] === "..") {
basePathParts.shift();
}
// this is a rollup plugin which will look for imports ending with `!string` and resolve // this is a rollup plugin which will look for imports ending with `!string` and resolve
// them with a module that will inline the contents of the file as a string. Needed to // them with a module that will inline the contents of the file as a string. Needed to
// support `js/assets.ts`. // support `js/assets.ts`.
@ -37,17 +46,38 @@ function strings({ include, exclude } = {}) {
return { return {
name: "strings", name: "strings",
/**
* @param {string} importee
*/
resolveId(importee) { resolveId(importee) {
if (importee.endsWith("!string")) { if (importee.endsWith("!string")) {
// strip the `!string` from `importee`
importee = importee.slice(0, importee.lastIndexOf("!string"));
if (!importee.startsWith("gen/")) {
// this is a static asset which is located relative to the root of the source project
return path.resolve(path.join(process.env.BASEPATH, importee));
}
// ignoring the first part, which is "gen"
const [, ...importeeParts] = importee.split("/");
// generated assets will be output by TypeScript relative between the build path and the
// root of the project. For example on Travis, the project path is:
// /home/travis/build/denoland/deno/
// and the build path is:
// /home/travis/out/Default/
// TypeScript will then output `globals.d.ts` from `js/globals.ts` to:
// /home/travis/out/Default/gen/build/denoland/deno/js/globals.d.ts
// therefore we need to insert any non relative BASEPATH parts into
// the final module ID
return path.resolve( return path.resolve(
path.join( path.join(process.cwd(), "gen", ...basePathParts, ...importeeParts)
process.env.BASEPATH,
importee.slice(0, importee.lastIndexOf("!string"))
)
); );
} }
}, },
/**
* @param {any} code
* @param {string} id
*/
transform(code, id) { transform(code, id) {
if (filter(id)) { if (filter(id)) {
return { return {
@ -98,6 +128,15 @@ export default function makeConfig(commandOptions) {
module: mockPath module: mockPath
}), }),
// Provides inlining of file contents for `js/assets.ts`
strings({
include: [
"*.d.ts",
`${__dirname}/**/*.d.ts`,
`${process.cwd()}/**/*.d.ts`
]
}),
// Resolves any resources that have been generated at build time // Resolves any resources that have been generated at build time
resolveGenerated(), resolveGenerated(),
@ -146,11 +185,6 @@ export default function makeConfig(commandOptions) {
] ]
}), }),
// Provides inlining of file contents for `js/assets.ts`
strings({
include: ["*.d.ts", `${__dirname}/**/*.d.ts`]
}),
// Provide some concise information about the bundle // Provide some concise information about the bundle
analyze({ analyze({
skipFormatted: true, skipFormatted: true,

View file

@ -1,23 +1,22 @@
{ {
"compilerOptions": { "compilerOptions": {
"allowJs": true, "allowUnreachableCode": false,
"baseUrl": ".", "baseUrl": ".",
"module": "esnext", "module": "esnext",
"noImplicitAny": true,
"sourceMap": true,
"removeComments": true,
"preserveConstEnums": true,
"target": "esnext",
"moduleResolution": "node", "moduleResolution": "node",
"noImplicitAny": true,
"noImplicitReturns": true, "noImplicitReturns": true,
"pretty": true,
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true,
"allowUnreachableCode": false, "noLib": true,
"experimentalDecorators": true,
"paths": { "paths": {
"*": ["*", "out/debug/*", "out/default/*", "out/release/*"] "*": ["*", "out/debug/*", "out/default/*", "out/release/*"]
} },
"preserveConstEnums": true,
"pretty": true,
"removeComments": true,
"sourceMap": true,
"target": "esnext",
"types": []
}, },
"include": ["js/main.ts"], "files": ["node_modules/typescript/lib/lib.esnext.d.ts", "js/main.ts"]
"exclude": ["node_modules"]
} }