feat: adding linter for commits
This commit is contained in:
21
node_modules/ts-node/LICENSE
generated
vendored
Normal file
21
node_modules/ts-node/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
306
node_modules/ts-node/README.md
generated
vendored
Normal file
306
node_modules/ts-node/README.md
generated
vendored
Normal file
@ -0,0 +1,306 @@
|
||||
# 
|
||||
|
||||
[![NPM version][npm-image]][npm-url]
|
||||
[![NPM downloads][downloads-image]][downloads-url]
|
||||
[![Build status][github-actions-image]][github-actions-url]
|
||||
[![Test coverage][codecov-image]][codecov-url]
|
||||
|
||||
> TypeScript execution and REPL for node.js, with source map support. **Works with `typescript@>=2.7`**.
|
||||
|
||||
### *Experimental ESM support*
|
||||
|
||||
Native ESM support is currently experimental. For usage, limitations, and to provide feedback, see [#1007](https://github.com/TypeStrong/ts-node/issues/1007).
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
# Locally in your project.
|
||||
npm install -D typescript
|
||||
npm install -D ts-node
|
||||
|
||||
# Or globally with TypeScript.
|
||||
npm install -g typescript
|
||||
npm install -g ts-node
|
||||
```
|
||||
|
||||
**Tip:** Installing modules locally allows you to control and share the versions through `package.json`. TS Node will always resolve the compiler from `cwd` before checking relative to its own installation.
|
||||
|
||||
## Usage
|
||||
|
||||
### Shell
|
||||
|
||||
```sh
|
||||
# Execute a script as `node` + `tsc`.
|
||||
ts-node script.ts
|
||||
|
||||
# Starts a TypeScript REPL.
|
||||
ts-node
|
||||
|
||||
# Execute code with TypeScript.
|
||||
ts-node -e 'console.log("Hello, world!")'
|
||||
|
||||
# Execute, and print, code with TypeScript.
|
||||
ts-node -p -e '"Hello, world!"'
|
||||
|
||||
# Pipe scripts to execute with TypeScript.
|
||||
echo 'console.log("Hello, world!")' | ts-node
|
||||
|
||||
# Equivalent to ts-node --script-mode
|
||||
ts-node-script scripts.ts
|
||||
|
||||
# Equivalent to ts-node --transpile-only
|
||||
ts-node-transpile-only scripts.ts
|
||||
```
|
||||
|
||||

|
||||
|
||||
### Shebang
|
||||
|
||||
```typescript
|
||||
#!/usr/bin/env ts-node-script
|
||||
|
||||
console.log("Hello, world!")
|
||||
```
|
||||
|
||||
`ts-node-script` is recommended because it enables `--script-mode`, discovering `tsconfig.json` relative to the script's location instead of `process.cwd()`. This makes scripts more portable.
|
||||
|
||||
Passing CLI arguments via shebang is allowed on Mac but not Linux. For example, the following will fail on Linux:
|
||||
|
||||
```
|
||||
#!/usr/bin/env ts-node --script-mode --transpile-only --files
|
||||
// This shebang is not portable. It only works on Mac
|
||||
```
|
||||
|
||||
### Programmatic
|
||||
|
||||
You can require `ts-node` and register the loader for future requires by using `require('ts-node').register({ /* options */ })`. You can also use file shortcuts - `node -r ts-node/register` or `node -r ts-node/register/transpile-only` - depending on your preferences.
|
||||
|
||||
**Note:** If you need to use advanced node.js CLI arguments (e.g. `--inspect`), use them with `node -r ts-node/register` instead of the `ts-node` CLI.
|
||||
|
||||
#### Developers
|
||||
|
||||
**TS Node** exports a `create()` function that can be used to initialize a TypeScript compiler that isn't registered to `require.extensions`, and it uses the same code as `register`.
|
||||
|
||||
### Mocha
|
||||
|
||||
Mocha 6
|
||||
|
||||
```sh
|
||||
mocha --require ts-node/register --watch-extensions ts,tsx "test/**/*.{ts,tsx}" [...args]
|
||||
```
|
||||
|
||||
**Note:** `--watch-extensions` is only used in `--watch` mode.
|
||||
|
||||
Mocha 7
|
||||
|
||||
```sh
|
||||
mocha --require ts-node/register --extensions ts,tsx --watch --watch-files src 'tests/**/*.{ts,tsx}' [...args]
|
||||
```
|
||||
|
||||
### Tape
|
||||
|
||||
```sh
|
||||
ts-node node_modules/tape/bin/tape [...args]
|
||||
```
|
||||
|
||||
### Gulp
|
||||
|
||||
```sh
|
||||
# Create a `gulpfile.ts` and run `gulp`.
|
||||
gulp
|
||||
```
|
||||
|
||||
### Visual Studio Code
|
||||
|
||||
Create a new node.js configuration, add `-r ts-node/register` to node args and move the `program` to the `args` list (so VS Code doesn't look for `outFiles`).
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Launch Program",
|
||||
"runtimeArgs": [
|
||||
"-r",
|
||||
"ts-node/register"
|
||||
],
|
||||
"args": [
|
||||
"${workspaceFolder}/index.ts"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**Note:** If you are using the `--project <tsconfig.json>` command line argument as per the [Configuration Options](#configuration-options), and want to apply this same behavior when launching in VS Code, add an "env" key into the launch configuration: `"env": { "TS_NODE_PROJECT": "<tsconfig.json>" }`.
|
||||
|
||||
### IntelliJ (and WebStorm)
|
||||
|
||||
Create a new Node.js configuration and add `-r ts-node/register` to "Node parameters."
|
||||
|
||||
**Note:** If you are using the `--project <tsconfig.json>` command line argument as per the [Configuration Options](#configuration-options), and want to apply this same behavior when launching in IntelliJ, specify under "Environment Variables": `TS_NODE_PROJECT=<tsconfig.json>`.
|
||||
|
||||
## How It Works
|
||||
|
||||
**TypeScript Node** works by registering the TypeScript compiler for `.tsx?` and `.jsx?` (when `allowJs == true`) extensions. When node.js has an extension registered (via `require.extensions`), it will use the extension internally for module resolution. When an extension is unknown to node.js, it handles the file as `.js` (JavaScript). By default, **TypeScript Node** avoids compiling files in `/node_modules/` for three reasons:
|
||||
|
||||
1. Modules should always be published in a format node.js can consume
|
||||
2. Transpiling the entire dependency tree will make your project slower
|
||||
3. Differing behaviours between TypeScript and node.js (e.g. ES2015 modules) can result in a project that works until you decide to support a feature natively from node.js
|
||||
|
||||
**P.S.** This means if you don't register an extension, it is compiled as JavaScript. When `ts-node` is used with `allowJs`, JavaScript files are transpiled using the TypeScript compiler.
|
||||
|
||||
## Loading `tsconfig.json`
|
||||
|
||||
**Typescript Node** loads `tsconfig.json` automatically. Use `--skip-project` to skip loading the `tsconfig.json`.
|
||||
|
||||
It is resolved relative to `--dir` using [the same search behavior as `tsc`](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html). In `--script-mode`, this is the directory containing the script. Otherwise it is resolved relative to `process.cwd()`, which matches the behavior of `tsc`.
|
||||
|
||||
Use `--project` to specify the path to your `tsconfig.json`, ignoring `--dir`.
|
||||
|
||||
**Tip**: You can use `ts-node` together with [tsconfig-paths](https://www.npmjs.com/package/tsconfig-paths) to load modules according to the `paths` section in `tsconfig.json`.
|
||||
|
||||
## Configuration Options
|
||||
|
||||
You can set options by passing them before the script path, via programmatic usage, via `tsconfig.json`, or via environment variables.
|
||||
|
||||
```sh
|
||||
ts-node --compiler ntypescript --project src/tsconfig.json hello-world.ts
|
||||
```
|
||||
|
||||
**Note:** [`ntypescript`](https://github.com/TypeStrong/ntypescript#readme) is an example of a TypeScript-compatible `compiler`.
|
||||
|
||||
### CLI Options
|
||||
|
||||
`ts-node` supports `--print` (`-p`), `--eval` (`-e`), `--require` (`-r`) and `--interactive` (`-i`) similar to the [node.js CLI options](https://nodejs.org/api/cli.html).
|
||||
|
||||
* `-h, --help` Prints the help text
|
||||
* `-v, --version` Prints the version. `-vv` prints node and typescript compiler versions, too
|
||||
* `-s, --script-mode` Resolve config relative to the directory of the passed script instead of the current directory. Changes default of `--dir`
|
||||
|
||||
### CLI and Programmatic Options
|
||||
|
||||
_The name of the environment variable and the option's default value are denoted in parentheses._
|
||||
|
||||
* `-T, --transpile-only` Use TypeScript's faster `transpileModule` (`TS_NODE_TRANSPILE_ONLY`, default: `false`)
|
||||
* `-H, --compiler-host` Use TypeScript's compiler host API (`TS_NODE_COMPILER_HOST`, default: `false`)
|
||||
* `-I, --ignore [pattern]` Override the path patterns to skip compilation (`TS_NODE_IGNORE`, default: `/node_modules/`)
|
||||
* `-P, --project [path]` Path to TypeScript JSON project file (`TS_NODE_PROJECT`)
|
||||
* `-C, --compiler [name]` Specify a custom TypeScript compiler (`TS_NODE_COMPILER`, default: `typescript`)
|
||||
* `-D, --ignore-diagnostics [code]` Ignore TypeScript warnings by diagnostic code (`TS_NODE_IGNORE_DIAGNOSTICS`)
|
||||
* `-O, --compiler-options [opts]` JSON object to merge with compiler options (`TS_NODE_COMPILER_OPTIONS`)
|
||||
* `--dir` Specify working directory for config resolution (`TS_NODE_CWD`, default: `process.cwd()`, or `dirname(scriptPath)` if `--script-mode`)
|
||||
* `--scope` Scope compiler to files within `cwd` (`TS_NODE_SCOPE`, default: `false`)
|
||||
* `--files` Load `files`, `include` and `exclude` from `tsconfig.json` on startup (`TS_NODE_FILES`, default: `false`)
|
||||
* `--pretty` Use pretty diagnostic formatter (`TS_NODE_PRETTY`, default: `false`)
|
||||
* `--skip-project` Skip project config resolution and loading (`TS_NODE_SKIP_PROJECT`, default: `false`)
|
||||
* `--skip-ignore` Skip ignore checks (`TS_NODE_SKIP_IGNORE`, default: `false`)
|
||||
* `--emit` Emit output files into `.ts-node` directory (`TS_NODE_EMIT`, default: `false`)
|
||||
* `--prefer-ts-exts` Re-order file extensions so that TypeScript imports are preferred (`TS_NODE_PREFER_TS_EXTS`, default: `false`)
|
||||
* `--log-error` Logs TypeScript errors to stderr instead of throwing exceptions (`TS_NODE_LOG_ERROR`, default: `false`)
|
||||
|
||||
### Programmatic-only Options
|
||||
|
||||
* `transformers` `_ts.CustomTransformers | ((p: _ts.Program) => _ts.CustomTransformers)`: An object with transformers or a factory function that accepts a program and returns a transformers object to pass to TypeScript. Factory function cannot be used with `transpileOnly` flag
|
||||
* `readFile`: Custom TypeScript-compatible file reading function
|
||||
* `fileExists`: Custom TypeScript-compatible file existence function
|
||||
|
||||
### Options via tsconfig.json
|
||||
|
||||
Most options can be specified by a `"ts-node"` object in `tsconfig.json` using their programmatic, camelCase names. For example, to enable `--transpile-only`:
|
||||
|
||||
```json
|
||||
// tsconfig.json
|
||||
{
|
||||
"ts-node": {
|
||||
"transpileOnly": true
|
||||
},
|
||||
"compilerOptions": {}
|
||||
}
|
||||
```
|
||||
|
||||
Our bundled [JSON schema](https://unpkg.com/browse/ts-node@8.8.2/tsconfig.schema.json) lists all compatible options.
|
||||
|
||||
## SyntaxError
|
||||
|
||||
Any error that is not a `TSError` is from node.js (e.g. `SyntaxError`), and cannot be fixed by TypeScript or `ts-node`. These are runtime issues with your code.
|
||||
|
||||
### Import Statements
|
||||
|
||||
There are two options when using `import` statements: compile them to CommonJS or use node's native ESM support.
|
||||
|
||||
To compile to CommonJS, you must set `"module": "CommonJS"` in your `tsconfig.json` or compiler options.
|
||||
|
||||
Node's native ESM support is currently experimental and so is `ts-node`'s ESM loader hook. For usage, limitations, and to provide feedback, see [#1007](https://github.com/TypeStrong/ts-node/issues/1007).
|
||||
|
||||
## Help! My Types Are Missing!
|
||||
|
||||
**TypeScript Node** does _not_ use `files`, `include` or `exclude`, by default. This is because a large majority projects do not use all of the files in a project directory (e.g. `Gulpfile.ts`, runtime vs tests) and parsing every file for types slows startup time. Instead, `ts-node` starts with the script file (e.g. `ts-node index.ts`) and TypeScript resolves dependencies based on imports and references.
|
||||
|
||||
For global definitions, you can use the `typeRoots` compiler option. This requires that your type definitions be structured as type packages (not loose TypeScript definition files). More details on how this works can be found in the [TypeScript Handbook](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html#types-typeroots-and-types).
|
||||
|
||||
Example `tsconfig.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"compilerOptions": {
|
||||
"typeRoots" : ["./node_modules/@types", "./typings"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Example project structure:
|
||||
|
||||
```text
|
||||
<project_root>/
|
||||
-- tsconfig.json
|
||||
-- typings/
|
||||
-- <module_name>/
|
||||
-- index.d.ts
|
||||
```
|
||||
|
||||
Example module declaration file:
|
||||
|
||||
```typescript
|
||||
declare module '<module_name>' {
|
||||
// module definitions go here
|
||||
}
|
||||
```
|
||||
|
||||
For module definitions, you can use [`paths`](https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping):
|
||||
|
||||
```json
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"custom-module-type": ["types/custom-module-type"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
An alternative approach for definitions of third-party libraries are [triple-slash directives](https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html). This may be helpful if you prefer not to change your TypeScript `compilerOptions` or structure your custom type definitions when using `typeRoots`. Below is an example of the triple-slash directive as a relative path within your project:
|
||||
|
||||
```typescript
|
||||
/// <reference types="./types/untyped_js_lib" />
|
||||
import UntypedJsLib from "untyped_js_lib"
|
||||
```
|
||||
|
||||
**Tip:** If you _must_ use `files`, `include`, or `exclude`, enable `--files` flags or set `TS_NODE_FILES=true`.
|
||||
|
||||
## Watching and Restarting
|
||||
|
||||
**TypeScript Node** compiles source code via `require()`, watching files and code reloads are out of scope for the project. If you want to restart the `ts-node` process on file change, existing node.js tools such as [nodemon](https://github.com/remy/nodemon), [onchange](https://github.com/Qard/onchange) and [node-dev](https://github.com/fgnass/node-dev) work.
|
||||
|
||||
There's also [`ts-node-dev`](https://github.com/whitecolor/ts-node-dev), a modified version of [`node-dev`](https://github.com/fgnass/node-dev) using `ts-node` for compilation that will restart the process on file change.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/ts-node.svg?style=flat
|
||||
[npm-url]: https://npmjs.org/package/ts-node
|
||||
[downloads-image]: https://img.shields.io/npm/dm/ts-node.svg?style=flat
|
||||
[downloads-url]: https://npmjs.org/package/ts-node
|
||||
[github-actions-image]: https://img.shields.io/github/workflow/status/TypeStrong/ts-node/Continuous%20Integration
|
||||
[github-actions-url]: https://github.com/TypeStrong/ts-node/actions?query=workflow%3A%22Continuous+Integration%22
|
||||
[codecov-image]: https://codecov.io/gh/TypeStrong/ts-node/branch/master/graph/badge.svg
|
||||
[codecov-url]: https://codecov.io/gh/TypeStrong/ts-node
|
13
node_modules/ts-node/dist-raw/README.md
generated
vendored
Normal file
13
node_modules/ts-node/dist-raw/README.md
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
The `dist-raw` directory contains JS sources that are distributed verbatim, not compiled nor typechecked via TS.
|
||||
|
||||
To implement ESM support, we unfortunately must duplicate some of node's built-in functionality that is not
|
||||
exposed via an API. We have copy-pasted the necessary code from https://github.com/nodejs/node/tree/master/lib
|
||||
then modified it to suite our needs.
|
||||
|
||||
Formatting may be intentionally bad to keep the diff as small as possible, to make it easier to merge
|
||||
upstream changes and understand our modifications. For example, when we need to wrap node's source code
|
||||
in a factory function, we will not indent the function body, to avoid whitespace changes in the diff.
|
||||
|
||||
One obvious problem with this approach: the code has been pulled from one version of node, whereas users of ts-node
|
||||
run multiple versions of node.
|
||||
Users running node 12 may see that ts-node behaves like node 14, for example.
|
122
node_modules/ts-node/dist-raw/node-cjs-loader-utils.js
generated
vendored
Normal file
122
node_modules/ts-node/dist-raw/node-cjs-loader-utils.js
generated
vendored
Normal file
@ -0,0 +1,122 @@
|
||||
// Copied from several files in node's source code.
|
||||
// https://github.com/nodejs/node/blob/2d5d77306f6dff9110c1f77fefab25f973415770/lib/internal/modules/cjs/loader.js
|
||||
// Each function and variable below must have a comment linking to the source in node's github repo.
|
||||
|
||||
const path = require('path');
|
||||
const packageJsonReader = require('./node-package-json-reader');
|
||||
const {JSONParse} = require('./node-primordials');
|
||||
|
||||
module.exports.assertScriptCanLoadAsCJSImpl = assertScriptCanLoadAsCJSImpl;
|
||||
|
||||
// copied from Module._extensions['.js']
|
||||
// https://github.com/nodejs/node/blob/v15.3.0/lib/internal/modules/cjs/loader.js#L1113-L1120
|
||||
function assertScriptCanLoadAsCJSImpl(filename) {
|
||||
const pkg = readPackageScope(filename);
|
||||
// Function require shouldn't be used in ES modules.
|
||||
if (pkg && pkg.data && pkg.data.type === 'module') {
|
||||
const parentPath = module.parent && module.parent.filename;
|
||||
const packageJsonPath = path.resolve(pkg.path, 'package.json');
|
||||
throw createErrRequireEsm(filename, parentPath, packageJsonPath);
|
||||
}
|
||||
}
|
||||
|
||||
// Copied from https://github.com/nodejs/node/blob/2d5d77306f6dff9110c1f77fefab25f973415770/lib/internal/modules/cjs/loader.js#L285-L301
|
||||
function readPackageScope(checkPath) {
|
||||
const rootSeparatorIndex = checkPath.indexOf(path.sep);
|
||||
let separatorIndex;
|
||||
while (
|
||||
(separatorIndex = checkPath.lastIndexOf(path.sep)) > rootSeparatorIndex
|
||||
) {
|
||||
checkPath = checkPath.slice(0, separatorIndex);
|
||||
if (checkPath.endsWith(path.sep + 'node_modules'))
|
||||
return false;
|
||||
const pjson = readPackage(checkPath);
|
||||
if (pjson) return {
|
||||
path: checkPath,
|
||||
data: pjson
|
||||
};
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Copied from https://github.com/nodejs/node/blob/2d5d77306f6dff9110c1f77fefab25f973415770/lib/internal/modules/cjs/loader.js#L249
|
||||
const packageJsonCache = new Map();
|
||||
|
||||
// Copied from https://github.com/nodejs/node/blob/v15.3.0/lib/internal/modules/cjs/loader.js#L275-L304
|
||||
function readPackage(requestPath) {
|
||||
const jsonPath = path.resolve(requestPath, 'package.json');
|
||||
|
||||
const existing = packageJsonCache.get(jsonPath);
|
||||
if (existing !== undefined) return existing;
|
||||
|
||||
const result = packageJsonReader.read(jsonPath);
|
||||
const json = result.containsKeys === false ? '{}' : result.string;
|
||||
if (json === undefined) {
|
||||
packageJsonCache.set(jsonPath, false);
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = JSONParse(json);
|
||||
const filtered = {
|
||||
name: parsed.name,
|
||||
main: parsed.main,
|
||||
exports: parsed.exports,
|
||||
imports: parsed.imports,
|
||||
type: parsed.type
|
||||
};
|
||||
packageJsonCache.set(jsonPath, filtered);
|
||||
return filtered;
|
||||
} catch (e) {
|
||||
e.path = jsonPath;
|
||||
e.message = 'Error parsing ' + jsonPath + ': ' + e.message;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
// Native ERR_REQUIRE_ESM Error is declared here:
|
||||
// https://github.com/nodejs/node/blob/2d5d77306f6dff9110c1f77fefab25f973415770/lib/internal/errors.js#L1294-L1313
|
||||
// Error class factory is implemented here:
|
||||
// function E: https://github.com/nodejs/node/blob/2d5d77306f6dff9110c1f77fefab25f973415770/lib/internal/errors.js#L323-L341
|
||||
// function makeNodeErrorWithCode: https://github.com/nodejs/node/blob/2d5d77306f6dff9110c1f77fefab25f973415770/lib/internal/errors.js#L251-L278
|
||||
// The code below should create an error that matches the native error as closely as possible.
|
||||
// Third-party libraries which attempt to catch the native ERR_REQUIRE_ESM should recognize our imitation error.
|
||||
function createErrRequireEsm(filename, parentPath, packageJsonPath) {
|
||||
const code = 'ERR_REQUIRE_ESM'
|
||||
const err = new Error(getMessage(filename, parentPath, packageJsonPath))
|
||||
// Set `name` to be used in stack trace, generate stack trace with that name baked in, then re-declare the `name` field.
|
||||
// This trick is copied from node's source.
|
||||
err.name = `Error [${ code }]`
|
||||
err.stack
|
||||
Object.defineProperty(err, 'name', {
|
||||
value: 'Error',
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
})
|
||||
err.code = code
|
||||
return err
|
||||
|
||||
// Copy-pasted from https://github.com/nodejs/node/blob/b533fb3508009e5f567cc776daba8fbf665386a6/lib/internal/errors.js#L1293-L1311
|
||||
// so that our error message is identical to the native message.
|
||||
function getMessage(filename, parentPath = null, packageJsonPath = null) {
|
||||
const ext = path.extname(filename)
|
||||
let msg = `Must use import to load ES Module: ${filename}`;
|
||||
if (parentPath && packageJsonPath) {
|
||||
const path = require('path');
|
||||
const basename = path.basename(filename) === path.basename(parentPath) ?
|
||||
filename : path.basename(filename);
|
||||
msg +=
|
||||
'\nrequire() of ES modules is not supported.\nrequire() of ' +
|
||||
`${filename} ${parentPath ? `from ${parentPath} ` : ''}` +
|
||||
`is an ES module file as it is a ${ext} file whose nearest parent ` +
|
||||
`package.json contains "type": "module" which defines all ${ext} ` +
|
||||
'files in that package scope as ES modules.\nInstead ' +
|
||||
'change the requiring code to use ' +
|
||||
'import(), or remove "type": "module" from ' +
|
||||
`${packageJsonPath}.\n`;
|
||||
return msg;
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
}
|
21
node_modules/ts-node/dist-raw/node-errors.js
generated
vendored
Normal file
21
node_modules/ts-node/dist-raw/node-errors.js
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
exports.codes = {
|
||||
ERR_INPUT_TYPE_NOT_ALLOWED: createErrorCtor('ERR_INPUT_TYPE_NOT_ALLOWED'),
|
||||
ERR_INVALID_ARG_VALUE: createErrorCtor('ERR_INVALID_ARG_VALUE'),
|
||||
ERR_INVALID_MODULE_SPECIFIER: createErrorCtor('ERR_INVALID_MODULE_SPECIFIER'),
|
||||
ERR_INVALID_PACKAGE_CONFIG: createErrorCtor('ERR_INVALID_PACKAGE_CONFIG'),
|
||||
ERR_INVALID_PACKAGE_TARGET: createErrorCtor('ERR_INVALID_PACKAGE_TARGET'),
|
||||
ERR_MANIFEST_DEPENDENCY_MISSING: createErrorCtor('ERR_MANIFEST_DEPENDENCY_MISSING'),
|
||||
ERR_MODULE_NOT_FOUND: createErrorCtor('ERR_MODULE_NOT_FOUND'),
|
||||
ERR_PACKAGE_IMPORT_NOT_DEFINED: createErrorCtor('ERR_PACKAGE_IMPORT_NOT_DEFINED'),
|
||||
ERR_PACKAGE_PATH_NOT_EXPORTED: createErrorCtor('ERR_PACKAGE_PATH_NOT_EXPORTED'),
|
||||
ERR_UNSUPPORTED_DIR_IMPORT: createErrorCtor('ERR_UNSUPPORTED_DIR_IMPORT'),
|
||||
ERR_UNSUPPORTED_ESM_URL_SCHEME: createErrorCtor('ERR_UNSUPPORTED_ESM_URL_SCHEME'),
|
||||
}
|
||||
|
||||
function createErrorCtor(name) {
|
||||
return class CustomError extends Error {
|
||||
constructor(...args) {
|
||||
super([name, ...args].join(' '))
|
||||
}
|
||||
}
|
||||
}
|
970
node_modules/ts-node/dist-raw/node-esm-resolve-implementation.js
generated
vendored
Normal file
970
node_modules/ts-node/dist-raw/node-esm-resolve-implementation.js
generated
vendored
Normal file
@ -0,0 +1,970 @@
|
||||
// Copied from https://raw.githubusercontent.com/nodejs/node/v15.3.0/lib/internal/modules/esm/resolve.js
|
||||
// Then modified to suite our needs.
|
||||
// Formatting is intentionally bad to keep the diff as small as possible, to make it easier to merge
|
||||
// upstream changes and understand our modifications.
|
||||
'use strict';
|
||||
|
||||
const [nodeMajor, nodeMinor, nodePatch] = process.versions.node.split('.').map(s => parseInt(s, 10))
|
||||
// Test for 14.13.1 or higher
|
||||
const builtinModuleProtocol = nodeMajor > 14 || (
|
||||
nodeMajor === 14 && (
|
||||
nodeMinor > 13 || (
|
||||
nodeMinor === 13 && nodePatch > 0
|
||||
)
|
||||
)
|
||||
)
|
||||
? 'node:'
|
||||
: 'nodejs:';
|
||||
|
||||
const {
|
||||
ArrayIsArray,
|
||||
ArrayPrototypeJoin,
|
||||
ArrayPrototypeShift,
|
||||
JSONParse,
|
||||
JSONStringify,
|
||||
ObjectFreeze,
|
||||
ObjectGetOwnPropertyNames,
|
||||
ObjectPrototypeHasOwnProperty,
|
||||
// RegExp,
|
||||
RegExpPrototypeTest,
|
||||
SafeMap,
|
||||
SafeSet,
|
||||
// String,
|
||||
StringPrototypeEndsWith,
|
||||
StringPrototypeIndexOf,
|
||||
StringPrototypeLastIndexOf,
|
||||
StringPrototypeReplace,
|
||||
StringPrototypeSlice,
|
||||
StringPrototypeSplit,
|
||||
StringPrototypeStartsWith,
|
||||
StringPrototypeSubstr,
|
||||
} = require('./node-primordials');
|
||||
|
||||
// const internalFS = require('internal/fs/utils');
|
||||
// const { NativeModule } = require('internal/bootstrap/loaders');
|
||||
const Module = require('module')
|
||||
const NativeModule = {
|
||||
canBeRequiredByUsers(specifier) {
|
||||
return Module.builtinModules.includes(specifier)
|
||||
}
|
||||
}
|
||||
const {
|
||||
realpathSync,
|
||||
statSync,
|
||||
Stats,
|
||||
} = require('fs');
|
||||
// const { getOptionValue } = require('internal/options');
|
||||
const { getOptionValue } = require('./node-options');
|
||||
// // Do not eagerly grab .manifest, it may be in TDZ
|
||||
// const policy = getOptionValue('--experimental-policy') ?
|
||||
// require('internal/process/policy') :
|
||||
// null;
|
||||
// disabled for now. I am not sure if/how we should support this
|
||||
const policy = null;
|
||||
const { sep, relative } = require('path');
|
||||
const preserveSymlinks = getOptionValue('--preserve-symlinks');
|
||||
const preserveSymlinksMain = getOptionValue('--preserve-symlinks-main');
|
||||
const typeFlag = getOptionValue('--input-type');
|
||||
// const { URL, pathToFileURL, fileURLToPath } = require('internal/url');
|
||||
const { URL, pathToFileURL, fileURLToPath } = require('url');
|
||||
const {
|
||||
ERR_INPUT_TYPE_NOT_ALLOWED,
|
||||
ERR_INVALID_ARG_VALUE,
|
||||
ERR_INVALID_MODULE_SPECIFIER,
|
||||
ERR_INVALID_PACKAGE_CONFIG,
|
||||
ERR_INVALID_PACKAGE_TARGET,
|
||||
ERR_MANIFEST_DEPENDENCY_MISSING,
|
||||
ERR_MODULE_NOT_FOUND,
|
||||
ERR_PACKAGE_IMPORT_NOT_DEFINED,
|
||||
ERR_PACKAGE_PATH_NOT_EXPORTED,
|
||||
ERR_UNSUPPORTED_DIR_IMPORT,
|
||||
ERR_UNSUPPORTED_ESM_URL_SCHEME,
|
||||
// } = require('internal/errors').codes;
|
||||
} = require('./node-errors').codes;
|
||||
|
||||
// const { Module: CJSModule } = require('internal/modules/cjs/loader');
|
||||
const CJSModule = Module;
|
||||
|
||||
// const packageJsonReader = require('internal/modules/package_json_reader');
|
||||
const packageJsonReader = require('./node-package-json-reader');
|
||||
const userConditions = getOptionValue('--conditions');
|
||||
const DEFAULT_CONDITIONS = ObjectFreeze(['node', 'import', ...userConditions]);
|
||||
const DEFAULT_CONDITIONS_SET = new SafeSet(DEFAULT_CONDITIONS);
|
||||
|
||||
const pendingDeprecation = getOptionValue('--pending-deprecation');
|
||||
|
||||
function createResolve(opts) {
|
||||
// TODO receive cached fs implementations here
|
||||
const {tsExtensions, jsExtensions, preferTsExts} = opts;
|
||||
|
||||
const emittedPackageWarnings = new SafeSet();
|
||||
function emitFolderMapDeprecation(match, pjsonUrl, isExports, base) {
|
||||
const pjsonPath = fileURLToPath(pjsonUrl);
|
||||
if (!pendingDeprecation) {
|
||||
const nodeModulesIndex = StringPrototypeLastIndexOf(pjsonPath,
|
||||
'/node_modules/');
|
||||
if (nodeModulesIndex !== -1) {
|
||||
const afterNodeModulesPath = StringPrototypeSlice(pjsonPath,
|
||||
nodeModulesIndex + 14,
|
||||
-13);
|
||||
try {
|
||||
const { packageSubpath } = parsePackageName(afterNodeModulesPath);
|
||||
if (packageSubpath === '.')
|
||||
return;
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
if (emittedPackageWarnings.has(pjsonPath + '|' + match))
|
||||
return;
|
||||
emittedPackageWarnings.add(pjsonPath + '|' + match);
|
||||
process.emitWarning(
|
||||
`Use of deprecated folder mapping "${match}" in the ${isExports ?
|
||||
'"exports"' : '"imports"'} field module resolution of the package at ${
|
||||
pjsonPath}${base ? ` imported from ${fileURLToPath(base)}` : ''}.\n` +
|
||||
`Update this package.json to use a subpath pattern like "${match}*".`,
|
||||
'DeprecationWarning',
|
||||
'DEP0148'
|
||||
);
|
||||
}
|
||||
|
||||
function getConditionsSet(conditions) {
|
||||
if (conditions !== undefined && conditions !== DEFAULT_CONDITIONS) {
|
||||
if (!ArrayIsArray(conditions)) {
|
||||
throw new ERR_INVALID_ARG_VALUE('conditions', conditions,
|
||||
'expected an array');
|
||||
}
|
||||
return new SafeSet(conditions);
|
||||
}
|
||||
return DEFAULT_CONDITIONS_SET;
|
||||
}
|
||||
|
||||
const realpathCache = new SafeMap();
|
||||
const packageJSONCache = new SafeMap(); /* string -> PackageConfig */
|
||||
|
||||
function tryStatSync(path) {
|
||||
try {
|
||||
return statSync(path);
|
||||
} catch {
|
||||
return new Stats();
|
||||
}
|
||||
}
|
||||
|
||||
function getPackageConfig(path, specifier, base) {
|
||||
const existing = packageJSONCache.get(path);
|
||||
if (existing !== undefined) {
|
||||
return existing;
|
||||
}
|
||||
const source = packageJsonReader.read(path).string;
|
||||
if (source === undefined) {
|
||||
const packageConfig = {
|
||||
pjsonPath: path,
|
||||
exists: false,
|
||||
main: undefined,
|
||||
name: undefined,
|
||||
type: 'none',
|
||||
exports: undefined,
|
||||
imports: undefined,
|
||||
};
|
||||
packageJSONCache.set(path, packageConfig);
|
||||
return packageConfig;
|
||||
}
|
||||
|
||||
let packageJSON;
|
||||
try {
|
||||
packageJSON = JSONParse(source);
|
||||
} catch (error) {
|
||||
throw new ERR_INVALID_PACKAGE_CONFIG(
|
||||
path,
|
||||
(base ? `"${specifier}" from ` : '') + fileURLToPath(base || specifier),
|
||||
error.message
|
||||
);
|
||||
}
|
||||
|
||||
let { imports, main, name, type } = packageJSON;
|
||||
const { exports } = packageJSON;
|
||||
if (typeof imports !== 'object' || imports === null) imports = undefined;
|
||||
if (typeof main !== 'string') main = undefined;
|
||||
if (typeof name !== 'string') name = undefined;
|
||||
// Ignore unknown types for forwards compatibility
|
||||
if (type !== 'module' && type !== 'commonjs') type = 'none';
|
||||
|
||||
const packageConfig = {
|
||||
pjsonPath: path,
|
||||
exists: true,
|
||||
main,
|
||||
name,
|
||||
type,
|
||||
exports,
|
||||
imports,
|
||||
};
|
||||
packageJSONCache.set(path, packageConfig);
|
||||
return packageConfig;
|
||||
}
|
||||
|
||||
function getPackageScopeConfig(resolved) {
|
||||
let packageJSONUrl = new URL('./package.json', resolved);
|
||||
while (true) {
|
||||
const packageJSONPath = packageJSONUrl.pathname;
|
||||
if (StringPrototypeEndsWith(packageJSONPath, 'node_modules/package.json'))
|
||||
break;
|
||||
const packageConfig = getPackageConfig(fileURLToPath(packageJSONUrl),
|
||||
resolved);
|
||||
if (packageConfig.exists) return packageConfig;
|
||||
|
||||
const lastPackageJSONUrl = packageJSONUrl;
|
||||
packageJSONUrl = new URL('../package.json', packageJSONUrl);
|
||||
|
||||
// Terminates at root where ../package.json equals ../../package.json
|
||||
// (can't just check "/package.json" for Windows support).
|
||||
if (packageJSONUrl.pathname === lastPackageJSONUrl.pathname) break;
|
||||
}
|
||||
const packageJSONPath = fileURLToPath(packageJSONUrl);
|
||||
const packageConfig = {
|
||||
pjsonPath: packageJSONPath,
|
||||
exists: false,
|
||||
main: undefined,
|
||||
name: undefined,
|
||||
type: 'none',
|
||||
exports: undefined,
|
||||
imports: undefined,
|
||||
};
|
||||
packageJSONCache.set(packageJSONPath, packageConfig);
|
||||
return packageConfig;
|
||||
}
|
||||
|
||||
/*
|
||||
* Legacy CommonJS main resolution:
|
||||
* 1. let M = pkg_url + (json main field)
|
||||
* 2. TRY(M, M.js, M.json, M.node)
|
||||
* 3. TRY(M/index.js, M/index.json, M/index.node)
|
||||
* 4. TRY(pkg_url/index.js, pkg_url/index.json, pkg_url/index.node)
|
||||
* 5. NOT_FOUND
|
||||
*/
|
||||
function fileExists(url) {
|
||||
return tryStatSync(fileURLToPath(url)).isFile();
|
||||
}
|
||||
|
||||
function legacyMainResolve(packageJSONUrl, packageConfig, base) {
|
||||
let guess;
|
||||
if (packageConfig.main !== undefined) {
|
||||
// Note: fs check redundances will be handled by Descriptor cache here.
|
||||
if (fileExists(guess = new URL(`./${packageConfig.main}`,
|
||||
packageJSONUrl))) {
|
||||
return guess;
|
||||
}
|
||||
if (fileExists(guess = new URL(`./${packageConfig.main}.js`,
|
||||
packageJSONUrl))) {
|
||||
return guess;
|
||||
}
|
||||
if (fileExists(guess = new URL(`./${packageConfig.main}.json`,
|
||||
packageJSONUrl))) {
|
||||
return guess;
|
||||
}
|
||||
if (fileExists(guess = new URL(`./${packageConfig.main}.node`,
|
||||
packageJSONUrl))) {
|
||||
return guess;
|
||||
}
|
||||
if (fileExists(guess = new URL(`./${packageConfig.main}/index.js`,
|
||||
packageJSONUrl))) {
|
||||
return guess;
|
||||
}
|
||||
if (fileExists(guess = new URL(`./${packageConfig.main}/index.json`,
|
||||
packageJSONUrl))) {
|
||||
return guess;
|
||||
}
|
||||
if (fileExists(guess = new URL(`./${packageConfig.main}/index.node`,
|
||||
packageJSONUrl))) {
|
||||
return guess;
|
||||
}
|
||||
// Fallthrough.
|
||||
}
|
||||
if (fileExists(guess = new URL('./index.js', packageJSONUrl))) {
|
||||
return guess;
|
||||
}
|
||||
// So fs.
|
||||
if (fileExists(guess = new URL('./index.json', packageJSONUrl))) {
|
||||
return guess;
|
||||
}
|
||||
if (fileExists(guess = new URL('./index.node', packageJSONUrl))) {
|
||||
return guess;
|
||||
}
|
||||
// Not found.
|
||||
throw new ERR_MODULE_NOT_FOUND(
|
||||
fileURLToPath(new URL('.', packageJSONUrl)), fileURLToPath(base));
|
||||
}
|
||||
|
||||
function resolveExtensionsWithTryExactName(search) {
|
||||
if (fileExists(search)) return search;
|
||||
const resolvedReplacementExtension = resolveReplacementExtensions(search);
|
||||
if(resolvedReplacementExtension) return resolvedReplacementExtension;
|
||||
return resolveExtensions(search);
|
||||
}
|
||||
|
||||
const extensions = Array.from(new Set([
|
||||
...(preferTsExts ? tsExtensions : []),
|
||||
'.js',
|
||||
...jsExtensions,
|
||||
'.json', '.node', '.mjs',
|
||||
...tsExtensions
|
||||
]));
|
||||
|
||||
function resolveExtensions(search) {
|
||||
for (let i = 0; i < extensions.length; i++) {
|
||||
const extension = extensions[i];
|
||||
const guess = new URL(`${search.pathname}${extension}`, search);
|
||||
if (fileExists(guess)) return guess;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* TS's resolver can resolve foo.js to foo.ts, by replacing .js extension with several source extensions.
|
||||
* IMPORTANT: preserve ordering according to preferTsExts; this affects resolution behavior!
|
||||
*/
|
||||
const replacementExtensions = extensions.filter(ext => ['.js', '.jsx', '.ts', '.tsx'].includes(ext));
|
||||
|
||||
function resolveReplacementExtensions(search) {
|
||||
if (search.pathname.match(/\.js$/)) {
|
||||
const pathnameWithoutExtension = search.pathname.slice(0, search.pathname.length - 3);
|
||||
for (let i = 0; i < replacementExtensions.length; i++) {
|
||||
const extension = replacementExtensions[i];
|
||||
const guess = new URL(search.toString());
|
||||
guess.pathname = `${pathnameWithoutExtension}${extension}`;
|
||||
if (fileExists(guess)) return guess;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function resolveIndex(search) {
|
||||
return resolveExtensions(new URL('index', search));
|
||||
}
|
||||
|
||||
const encodedSepRegEx = /%2F|%2C/i;
|
||||
function finalizeResolution(resolved, base) {
|
||||
if (RegExpPrototypeTest(encodedSepRegEx, resolved.pathname))
|
||||
throw new ERR_INVALID_MODULE_SPECIFIER(
|
||||
resolved.pathname, 'must not include encoded "/" or "\\" characters',
|
||||
fileURLToPath(base));
|
||||
|
||||
if (getOptionValue('--experimental-specifier-resolution') === 'node') {
|
||||
const path = fileURLToPath(resolved);
|
||||
let file = resolveExtensionsWithTryExactName(resolved);
|
||||
if (file !== undefined) return file;
|
||||
if (!StringPrototypeEndsWith(path, '/')) {
|
||||
file = resolveIndex(new URL(`${resolved}/`));
|
||||
if (file !== undefined) return file;
|
||||
} else {
|
||||
return resolveIndex(resolved) || resolved;
|
||||
}
|
||||
throw new ERR_MODULE_NOT_FOUND(
|
||||
resolved.pathname, fileURLToPath(base), 'module');
|
||||
}
|
||||
|
||||
const file = resolveReplacementExtensions(resolved) || resolved;
|
||||
const path = fileURLToPath(file);
|
||||
|
||||
const stats = tryStatSync(StringPrototypeEndsWith(path, '/') ?
|
||||
StringPrototypeSlice(path, -1) : path);
|
||||
if (stats.isDirectory()) {
|
||||
const err = new ERR_UNSUPPORTED_DIR_IMPORT(path, fileURLToPath(base));
|
||||
err.url = String(resolved);
|
||||
throw err;
|
||||
} else if (!stats.isFile()) {
|
||||
throw new ERR_MODULE_NOT_FOUND(
|
||||
path || resolved.pathname, fileURLToPath(base), 'module');
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
function throwImportNotDefined(specifier, packageJSONUrl, base) {
|
||||
throw new ERR_PACKAGE_IMPORT_NOT_DEFINED(
|
||||
specifier, packageJSONUrl && fileURLToPath(new URL('.', packageJSONUrl)),
|
||||
fileURLToPath(base));
|
||||
}
|
||||
|
||||
function throwExportsNotFound(subpath, packageJSONUrl, base) {
|
||||
throw new ERR_PACKAGE_PATH_NOT_EXPORTED(
|
||||
fileURLToPath(new URL('.', packageJSONUrl)), subpath,
|
||||
base && fileURLToPath(base));
|
||||
}
|
||||
|
||||
function throwInvalidSubpath(subpath, packageJSONUrl, internal, base) {
|
||||
const reason = `request is not a valid subpath for the "${internal ?
|
||||
'imports' : 'exports'}" resolution of ${fileURLToPath(packageJSONUrl)}`;
|
||||
throw new ERR_INVALID_MODULE_SPECIFIER(subpath, reason,
|
||||
base && fileURLToPath(base));
|
||||
}
|
||||
|
||||
function throwInvalidPackageTarget(
|
||||
subpath, target, packageJSONUrl, internal, base) {
|
||||
if (typeof target === 'object' && target !== null) {
|
||||
target = JSONStringify(target, null, '');
|
||||
} else {
|
||||
target = `${target}`;
|
||||
}
|
||||
throw new ERR_INVALID_PACKAGE_TARGET(
|
||||
fileURLToPath(new URL('.', packageJSONUrl)), subpath, target,
|
||||
internal, base && fileURLToPath(base));
|
||||
}
|
||||
|
||||
const invalidSegmentRegEx = /(^|\\|\/)(\.\.?|node_modules)(\\|\/|$)/;
|
||||
const patternRegEx = /\*/g;
|
||||
|
||||
function resolvePackageTargetString(
|
||||
target, subpath, match, packageJSONUrl, base, pattern, internal, conditions) {
|
||||
if (subpath !== '' && !pattern && target[target.length - 1] !== '/')
|
||||
throwInvalidPackageTarget(match, target, packageJSONUrl, internal, base);
|
||||
|
||||
if (!StringPrototypeStartsWith(target, './')) {
|
||||
if (internal && !StringPrototypeStartsWith(target, '../') &&
|
||||
!StringPrototypeStartsWith(target, '/')) {
|
||||
let isURL = false;
|
||||
try {
|
||||
new URL(target);
|
||||
isURL = true;
|
||||
} catch {}
|
||||
if (!isURL) {
|
||||
const exportTarget = pattern ?
|
||||
StringPrototypeReplace(target, patternRegEx, subpath) :
|
||||
target + subpath;
|
||||
return packageResolve(exportTarget, packageJSONUrl, conditions);
|
||||
}
|
||||
}
|
||||
throwInvalidPackageTarget(match, target, packageJSONUrl, internal, base);
|
||||
}
|
||||
|
||||
if (RegExpPrototypeTest(invalidSegmentRegEx, StringPrototypeSlice(target, 2)))
|
||||
throwInvalidPackageTarget(match, target, packageJSONUrl, internal, base);
|
||||
|
||||
const resolved = new URL(target, packageJSONUrl);
|
||||
const resolvedPath = resolved.pathname;
|
||||
const packagePath = new URL('.', packageJSONUrl).pathname;
|
||||
|
||||
if (!StringPrototypeStartsWith(resolvedPath, packagePath))
|
||||
throwInvalidPackageTarget(match, target, packageJSONUrl, internal, base);
|
||||
|
||||
if (subpath === '') return resolved;
|
||||
|
||||
if (RegExpPrototypeTest(invalidSegmentRegEx, subpath))
|
||||
throwInvalidSubpath(match + subpath, packageJSONUrl, internal, base);
|
||||
|
||||
if (pattern)
|
||||
return new URL(StringPrototypeReplace(resolved.href, patternRegEx,
|
||||
subpath));
|
||||
return new URL(subpath, resolved);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} key
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isArrayIndex(key) {
|
||||
const keyNum = +key;
|
||||
if (`${keyNum}` !== key) return false;
|
||||
return keyNum >= 0 && keyNum < 0xFFFF_FFFF;
|
||||
}
|
||||
|
||||
function resolvePackageTarget(packageJSONUrl, target, subpath, packageSubpath,
|
||||
base, pattern, internal, conditions) {
|
||||
if (typeof target === 'string') {
|
||||
return resolvePackageTargetString(
|
||||
target, subpath, packageSubpath, packageJSONUrl, base, pattern, internal,
|
||||
conditions);
|
||||
} else if (ArrayIsArray(target)) {
|
||||
if (target.length === 0)
|
||||
return null;
|
||||
|
||||
let lastException;
|
||||
for (let i = 0; i < target.length; i++) {
|
||||
const targetItem = target[i];
|
||||
let resolved;
|
||||
try {
|
||||
resolved = resolvePackageTarget(
|
||||
packageJSONUrl, targetItem, subpath, packageSubpath, base, pattern,
|
||||
internal, conditions);
|
||||
} catch (e) {
|
||||
lastException = e;
|
||||
if (e.code === 'ERR_INVALID_PACKAGE_TARGET')
|
||||
continue;
|
||||
throw e;
|
||||
}
|
||||
if (resolved === undefined)
|
||||
continue;
|
||||
if (resolved === null) {
|
||||
lastException = null;
|
||||
continue;
|
||||
}
|
||||
return resolved;
|
||||
}
|
||||
if (lastException === undefined || lastException === null)
|
||||
return lastException;
|
||||
throw lastException;
|
||||
} else if (typeof target === 'object' && target !== null) {
|
||||
const keys = ObjectGetOwnPropertyNames(target);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
if (isArrayIndex(key)) {
|
||||
throw new ERR_INVALID_PACKAGE_CONFIG(
|
||||
fileURLToPath(packageJSONUrl), base,
|
||||
'"exports" cannot contain numeric property keys.');
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
if (key === 'default' || conditions.has(key)) {
|
||||
const conditionalTarget = target[key];
|
||||
const resolved = resolvePackageTarget(
|
||||
packageJSONUrl, conditionalTarget, subpath, packageSubpath, base,
|
||||
pattern, internal, conditions);
|
||||
if (resolved === undefined)
|
||||
continue;
|
||||
return resolved;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
} else if (target === null) {
|
||||
return null;
|
||||
}
|
||||
throwInvalidPackageTarget(packageSubpath, target, packageJSONUrl, internal,
|
||||
base);
|
||||
}
|
||||
|
||||
function isConditionalExportsMainSugar(exports, packageJSONUrl, base) {
|
||||
if (typeof exports === 'string' || ArrayIsArray(exports)) return true;
|
||||
if (typeof exports !== 'object' || exports === null) return false;
|
||||
|
||||
const keys = ObjectGetOwnPropertyNames(exports);
|
||||
let isConditionalSugar = false;
|
||||
let i = 0;
|
||||
for (let j = 0; j < keys.length; j++) {
|
||||
const key = keys[j];
|
||||
const curIsConditionalSugar = key === '' || key[0] !== '.';
|
||||
if (i++ === 0) {
|
||||
isConditionalSugar = curIsConditionalSugar;
|
||||
} else if (isConditionalSugar !== curIsConditionalSugar) {
|
||||
throw new ERR_INVALID_PACKAGE_CONFIG(
|
||||
fileURLToPath(packageJSONUrl), base,
|
||||
'"exports" cannot contain some keys starting with \'.\' and some not.' +
|
||||
' The exports object must either be an object of package subpath keys' +
|
||||
' or an object of main entry condition name keys only.');
|
||||
}
|
||||
}
|
||||
return isConditionalSugar;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {URL} packageJSONUrl
|
||||
* @param {string} packageSubpath
|
||||
* @param {object} packageConfig
|
||||
* @param {string} base
|
||||
* @param {Set<string>} conditions
|
||||
* @returns {URL}
|
||||
*/
|
||||
function packageExportsResolve(
|
||||
packageJSONUrl, packageSubpath, packageConfig, base, conditions) {
|
||||
let exports = packageConfig.exports;
|
||||
if (isConditionalExportsMainSugar(exports, packageJSONUrl, base))
|
||||
exports = { '.': exports };
|
||||
|
||||
if (ObjectPrototypeHasOwnProperty(exports, packageSubpath)) {
|
||||
const target = exports[packageSubpath];
|
||||
const resolved = resolvePackageTarget(
|
||||
packageJSONUrl, target, '', packageSubpath, base, false, false, conditions
|
||||
);
|
||||
if (resolved === null || resolved === undefined)
|
||||
throwExportsNotFound(packageSubpath, packageJSONUrl, base);
|
||||
return { resolved, exact: true };
|
||||
}
|
||||
|
||||
let bestMatch = '';
|
||||
const keys = ObjectGetOwnPropertyNames(exports);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
if (key[key.length - 1] === '*' &&
|
||||
StringPrototypeStartsWith(packageSubpath,
|
||||
StringPrototypeSlice(key, 0, -1)) &&
|
||||
packageSubpath.length >= key.length &&
|
||||
key.length > bestMatch.length) {
|
||||
bestMatch = key;
|
||||
} else if (key[key.length - 1] === '/' &&
|
||||
StringPrototypeStartsWith(packageSubpath, key) &&
|
||||
key.length > bestMatch.length) {
|
||||
bestMatch = key;
|
||||
}
|
||||
}
|
||||
|
||||
if (bestMatch) {
|
||||
const target = exports[bestMatch];
|
||||
const pattern = bestMatch[bestMatch.length - 1] === '*';
|
||||
const subpath = StringPrototypeSubstr(packageSubpath, bestMatch.length -
|
||||
(pattern ? 1 : 0));
|
||||
const resolved = resolvePackageTarget(packageJSONUrl, target, subpath,
|
||||
bestMatch, base, pattern, false,
|
||||
conditions);
|
||||
if (resolved === null || resolved === undefined)
|
||||
throwExportsNotFound(packageSubpath, packageJSONUrl, base);
|
||||
if (!pattern)
|
||||
emitFolderMapDeprecation(bestMatch, packageJSONUrl, true, base);
|
||||
return { resolved, exact: pattern };
|
||||
}
|
||||
|
||||
throwExportsNotFound(packageSubpath, packageJSONUrl, base);
|
||||
}
|
||||
|
||||
function packageImportsResolve(name, base, conditions) {
|
||||
if (name === '#' || StringPrototypeStartsWith(name, '#/')) {
|
||||
const reason = 'is not a valid internal imports specifier name';
|
||||
throw new ERR_INVALID_MODULE_SPECIFIER(name, reason, fileURLToPath(base));
|
||||
}
|
||||
let packageJSONUrl;
|
||||
const packageConfig = getPackageScopeConfig(base);
|
||||
if (packageConfig.exists) {
|
||||
packageJSONUrl = pathToFileURL(packageConfig.pjsonPath);
|
||||
const imports = packageConfig.imports;
|
||||
if (imports) {
|
||||
if (ObjectPrototypeHasOwnProperty(imports, name)) {
|
||||
const resolved = resolvePackageTarget(
|
||||
packageJSONUrl, imports[name], '', name, base, false, true, conditions
|
||||
);
|
||||
if (resolved !== null)
|
||||
return { resolved, exact: true };
|
||||
} else {
|
||||
let bestMatch = '';
|
||||
const keys = ObjectGetOwnPropertyNames(imports);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
if (key[key.length - 1] === '*' &&
|
||||
StringPrototypeStartsWith(name,
|
||||
StringPrototypeSlice(key, 0, -1)) &&
|
||||
name.length >= key.length &&
|
||||
key.length > bestMatch.length) {
|
||||
bestMatch = key;
|
||||
} else if (key[key.length - 1] === '/' &&
|
||||
StringPrototypeStartsWith(name, key) &&
|
||||
key.length > bestMatch.length) {
|
||||
bestMatch = key;
|
||||
}
|
||||
}
|
||||
|
||||
if (bestMatch) {
|
||||
const target = imports[bestMatch];
|
||||
const pattern = bestMatch[bestMatch.length - 1] === '*';
|
||||
const subpath = StringPrototypeSubstr(name, bestMatch.length -
|
||||
(pattern ? 1 : 0));
|
||||
const resolved = resolvePackageTarget(
|
||||
packageJSONUrl, target, subpath, bestMatch, base, pattern, true,
|
||||
conditions);
|
||||
if (resolved !== null) {
|
||||
if (!pattern)
|
||||
emitFolderMapDeprecation(bestMatch, packageJSONUrl, false, base);
|
||||
return { resolved, exact: pattern };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
throwImportNotDefined(name, packageJSONUrl, base);
|
||||
}
|
||||
|
||||
function getPackageType(url) {
|
||||
const packageConfig = getPackageScopeConfig(url);
|
||||
return packageConfig.type;
|
||||
}
|
||||
|
||||
function parsePackageName(specifier, base) {
|
||||
let separatorIndex = StringPrototypeIndexOf(specifier, '/');
|
||||
let validPackageName = true;
|
||||
let isScoped = false;
|
||||
if (specifier[0] === '@') {
|
||||
isScoped = true;
|
||||
if (separatorIndex === -1 || specifier.length === 0) {
|
||||
validPackageName = false;
|
||||
} else {
|
||||
separatorIndex = StringPrototypeIndexOf(
|
||||
specifier, '/', separatorIndex + 1);
|
||||
}
|
||||
}
|
||||
|
||||
const packageName = separatorIndex === -1 ?
|
||||
specifier : StringPrototypeSlice(specifier, 0, separatorIndex);
|
||||
|
||||
// Package name cannot have leading . and cannot have percent-encoding or
|
||||
// separators.
|
||||
for (let i = 0; i < packageName.length; i++) {
|
||||
if (packageName[i] === '%' || packageName[i] === '\\') {
|
||||
validPackageName = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!validPackageName) {
|
||||
throw new ERR_INVALID_MODULE_SPECIFIER(
|
||||
specifier, 'is not a valid package name', fileURLToPath(base));
|
||||
}
|
||||
|
||||
const packageSubpath = '.' + (separatorIndex === -1 ? '' :
|
||||
StringPrototypeSlice(specifier, separatorIndex));
|
||||
|
||||
return { packageName, packageSubpath, isScoped };
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} specifier
|
||||
* @param {URL} base
|
||||
* @param {Set<string>} conditions
|
||||
* @returns {URL}
|
||||
*/
|
||||
function packageResolve(specifier, base, conditions) {
|
||||
const { packageName, packageSubpath, isScoped } =
|
||||
parsePackageName(specifier, base);
|
||||
|
||||
// ResolveSelf
|
||||
const packageConfig = getPackageScopeConfig(base);
|
||||
if (packageConfig.exists) {
|
||||
const packageJSONUrl = pathToFileURL(packageConfig.pjsonPath);
|
||||
if (packageConfig.name === packageName &&
|
||||
packageConfig.exports !== undefined && packageConfig.exports !== null) {
|
||||
return packageExportsResolve(
|
||||
packageJSONUrl, packageSubpath, packageConfig, base, conditions
|
||||
).resolved;
|
||||
}
|
||||
}
|
||||
|
||||
let packageJSONUrl =
|
||||
new URL('./node_modules/' + packageName + '/package.json', base);
|
||||
let packageJSONPath = fileURLToPath(packageJSONUrl);
|
||||
let lastPath;
|
||||
do {
|
||||
const stat = tryStatSync(StringPrototypeSlice(packageJSONPath, 0,
|
||||
packageJSONPath.length - 13));
|
||||
if (!stat.isDirectory()) {
|
||||
lastPath = packageJSONPath;
|
||||
packageJSONUrl = new URL((isScoped ?
|
||||
'../../../../node_modules/' : '../../../node_modules/') +
|
||||
packageName + '/package.json', packageJSONUrl);
|
||||
packageJSONPath = fileURLToPath(packageJSONUrl);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Package match.
|
||||
const packageConfig = getPackageConfig(packageJSONPath, specifier, base);
|
||||
if (packageConfig.exports !== undefined && packageConfig.exports !== null)
|
||||
return packageExportsResolve(
|
||||
packageJSONUrl, packageSubpath, packageConfig, base, conditions
|
||||
).resolved;
|
||||
if (packageSubpath === '.')
|
||||
return legacyMainResolve(packageJSONUrl, packageConfig, base);
|
||||
return new URL(packageSubpath, packageJSONUrl);
|
||||
// Cross-platform root check.
|
||||
} while (packageJSONPath.length !== lastPath.length);
|
||||
|
||||
// eslint can't handle the above code.
|
||||
// eslint-disable-next-line no-unreachable
|
||||
throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base));
|
||||
}
|
||||
|
||||
function isBareSpecifier(specifier) {
|
||||
return specifier[0] && specifier[0] !== '/' && specifier[0] !== '.';
|
||||
}
|
||||
|
||||
function isRelativeSpecifier(specifier) {
|
||||
if (specifier[0] === '.') {
|
||||
if (specifier.length === 1 || specifier[1] === '/') return true;
|
||||
if (specifier[1] === '.') {
|
||||
if (specifier.length === 2 || specifier[2] === '/') return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function shouldBeTreatedAsRelativeOrAbsolutePath(specifier) {
|
||||
if (specifier === '') return false;
|
||||
if (specifier[0] === '/') return true;
|
||||
return isRelativeSpecifier(specifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} specifier
|
||||
* @param {URL} base
|
||||
* @param {Set<string>} conditions
|
||||
* @returns {URL}
|
||||
*/
|
||||
function moduleResolve(specifier, base, conditions) {
|
||||
// Order swapped from spec for minor perf gain.
|
||||
// Ok since relative URLs cannot parse as URLs.
|
||||
let resolved;
|
||||
if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) {
|
||||
resolved = new URL(specifier, base);
|
||||
} else if (specifier[0] === '#') {
|
||||
({ resolved } = packageImportsResolve(specifier, base, conditions));
|
||||
} else {
|
||||
try {
|
||||
resolved = new URL(specifier);
|
||||
} catch {
|
||||
resolved = packageResolve(specifier, base, conditions);
|
||||
}
|
||||
}
|
||||
return finalizeResolution(resolved, base);
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to resolve an import as a CommonJS module
|
||||
* @param {string} specifier
|
||||
* @param {string} parentURL
|
||||
* @returns {boolean|string}
|
||||
*/
|
||||
function resolveAsCommonJS(specifier, parentURL) {
|
||||
try {
|
||||
const parent = fileURLToPath(parentURL);
|
||||
const tmpModule = new CJSModule(parent, null);
|
||||
tmpModule.paths = CJSModule._nodeModulePaths(parent);
|
||||
|
||||
let found = CJSModule._resolveFilename(specifier, tmpModule, false);
|
||||
|
||||
// If it is a relative specifier return the relative path
|
||||
// to the parent
|
||||
if (isRelativeSpecifier(specifier)) {
|
||||
found = relative(parent, found);
|
||||
// Add '.separator if the path does not start with '..separator'
|
||||
// This should be a safe assumption because when loading
|
||||
// esm modules there should be always a file specified so
|
||||
// there should not be a specifier like '..' or '.'
|
||||
if (!StringPrototypeStartsWith(found, `..${sep}`)) {
|
||||
found = `.${sep}${found}`;
|
||||
}
|
||||
} else if (isBareSpecifier(specifier)) {
|
||||
// If it is a bare specifier return the relative path within the
|
||||
// module
|
||||
const pkg = StringPrototypeSplit(specifier, '/')[0];
|
||||
const index = StringPrototypeIndexOf(found, pkg);
|
||||
if (index !== -1) {
|
||||
found = StringPrototypeSlice(found, index);
|
||||
}
|
||||
}
|
||||
// Normalize the path separator to give a valid suggestion
|
||||
// on Windows
|
||||
if (process.platform === 'win32') {
|
||||
found = StringPrototypeReplace(found, new RegExp(`\\${sep}`, 'g'), '/');
|
||||
}
|
||||
return found;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function defaultResolve(specifier, context = {}, defaultResolveUnused) {
|
||||
let { parentURL, conditions } = context;
|
||||
if (parentURL && policy != null && policy.manifest) {
|
||||
const redirects = policy.manifest.getDependencyMapper(parentURL);
|
||||
if (redirects) {
|
||||
const { resolve, reaction } = redirects;
|
||||
const destination = resolve(specifier, new SafeSet(conditions));
|
||||
let missing = true;
|
||||
if (destination === true) {
|
||||
missing = false;
|
||||
} else if (destination) {
|
||||
const href = destination.href;
|
||||
return { url: href };
|
||||
}
|
||||
if (missing) {
|
||||
reaction(new ERR_MANIFEST_DEPENDENCY_MISSING(
|
||||
parentURL,
|
||||
specifier,
|
||||
ArrayPrototypeJoin([...conditions], ', '))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
let parsed;
|
||||
try {
|
||||
parsed = new URL(specifier);
|
||||
if (parsed.protocol === 'data:') {
|
||||
return {
|
||||
url: specifier
|
||||
};
|
||||
}
|
||||
} catch {}
|
||||
if (parsed && parsed.protocol === builtinModuleProtocol)
|
||||
return { url: specifier };
|
||||
if (parsed && parsed.protocol !== 'file:' && parsed.protocol !== 'data:')
|
||||
throw new ERR_UNSUPPORTED_ESM_URL_SCHEME(parsed);
|
||||
if (NativeModule.canBeRequiredByUsers(specifier)) {
|
||||
return {
|
||||
url: builtinModuleProtocol + specifier
|
||||
};
|
||||
}
|
||||
if (parentURL && StringPrototypeStartsWith(parentURL, 'data:')) {
|
||||
// This is gonna blow up, we want the error
|
||||
new URL(specifier, parentURL);
|
||||
}
|
||||
|
||||
const isMain = parentURL === undefined;
|
||||
if (isMain) {
|
||||
parentURL = pathToFileURL(`${process.cwd()}/`).href;
|
||||
|
||||
// This is the initial entry point to the program, and --input-type has
|
||||
// been passed as an option; but --input-type can only be used with
|
||||
// --eval, --print or STDIN string input. It is not allowed with file
|
||||
// input, to avoid user confusion over how expansive the effect of the
|
||||
// flag should be (i.e. entry point only, package scope surrounding the
|
||||
// entry point, etc.).
|
||||
if (typeFlag)
|
||||
throw new ERR_INPUT_TYPE_NOT_ALLOWED();
|
||||
}
|
||||
|
||||
conditions = getConditionsSet(conditions);
|
||||
let url;
|
||||
try {
|
||||
url = moduleResolve(specifier, parentURL, conditions);
|
||||
} catch (error) {
|
||||
// Try to give the user a hint of what would have been the
|
||||
// resolved CommonJS module
|
||||
if (error.code === 'ERR_MODULE_NOT_FOUND' ||
|
||||
error.code === 'ERR_UNSUPPORTED_DIR_IMPORT') {
|
||||
if (StringPrototypeStartsWith(specifier, 'file://')) {
|
||||
specifier = fileURLToPath(specifier);
|
||||
}
|
||||
const found = resolveAsCommonJS(specifier, parentURL);
|
||||
if (found) {
|
||||
// Modify the stack and message string to include the hint
|
||||
const lines = StringPrototypeSplit(error.stack, '\n');
|
||||
const hint = `Did you mean to import ${found}?`;
|
||||
error.stack =
|
||||
ArrayPrototypeShift(lines) + '\n' +
|
||||
hint + '\n' +
|
||||
ArrayPrototypeJoin(lines, '\n');
|
||||
error.message += `\n${hint}`;
|
||||
}
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (isMain ? !preserveSymlinksMain : !preserveSymlinks) {
|
||||
const urlPath = fileURLToPath(url);
|
||||
const real = realpathSync(urlPath, {
|
||||
// [internalFS.realpathCacheKey]: realpathCache
|
||||
});
|
||||
const old = url;
|
||||
url = pathToFileURL(
|
||||
real + (StringPrototypeEndsWith(urlPath, sep) ? '/' : ''));
|
||||
url.search = old.search;
|
||||
url.hash = old.hash;
|
||||
}
|
||||
|
||||
return { url: `${url}` };
|
||||
}
|
||||
|
||||
return {
|
||||
DEFAULT_CONDITIONS,
|
||||
defaultResolve,
|
||||
encodedSepRegEx,
|
||||
getPackageType,
|
||||
packageExportsResolve,
|
||||
packageImportsResolve
|
||||
};
|
||||
}
|
||||
module.exports = {
|
||||
createResolve
|
||||
};
|
22
node_modules/ts-node/dist-raw/node-internal-fs.js
generated
vendored
Normal file
22
node_modules/ts-node/dist-raw/node-internal-fs.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
const fs = require('fs');
|
||||
|
||||
// In node's core, this is implemented in C
|
||||
// https://github.com/nodejs/node/blob/v15.3.0/src/node_file.cc#L891-L985
|
||||
function internalModuleReadJSON(path) {
|
||||
let string
|
||||
try {
|
||||
string = fs.readFileSync(path, 'utf8')
|
||||
} catch (e) {
|
||||
if (e.code === 'ENOENT') return []
|
||||
throw e
|
||||
}
|
||||
// Node's implementation checks for the presence of relevant keys: main, name, type, exports, imports
|
||||
// Node does this for performance to skip unnecessary parsing.
|
||||
// This would slow us down and, based on our usage, we can skip it.
|
||||
const containsKeys = true
|
||||
return [string, containsKeys]
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
internalModuleReadJSON
|
||||
};
|
101
node_modules/ts-node/dist-raw/node-options.js
generated
vendored
Normal file
101
node_modules/ts-node/dist-raw/node-options.js
generated
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
// Replacement for node's internal 'internal/options' module
|
||||
|
||||
exports.getOptionValue = getOptionValue;
|
||||
function getOptionValue(opt) {
|
||||
parseOptions();
|
||||
return options[opt];
|
||||
}
|
||||
|
||||
let options;
|
||||
function parseOptions() {
|
||||
if (!options) {
|
||||
options = {
|
||||
'--preserve-symlinks': false,
|
||||
'--preserve-symlinks-main': false,
|
||||
'--input-type': undefined,
|
||||
'--experimental-specifier-resolution': 'explicit',
|
||||
'--experimental-policy': undefined,
|
||||
'--conditions': [],
|
||||
'--pending-deprecation': false,
|
||||
...parseArgv(getNodeOptionsEnvArgv()),
|
||||
...parseArgv(process.execArgv),
|
||||
...getOptionValuesFromOtherEnvVars()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function parseArgv(argv) {
|
||||
return require('arg')({
|
||||
'--preserve-symlinks': Boolean,
|
||||
'--preserve-symlinks-main': Boolean,
|
||||
'--input-type': String,
|
||||
'--experimental-specifier-resolution': String,
|
||||
// Legacy alias for node versions prior to 12.16
|
||||
'--es-module-specifier-resolution': '--experimental-specifier-resolution',
|
||||
'--experimental-policy': String,
|
||||
'--conditions': [String],
|
||||
'--pending-deprecation': Boolean
|
||||
}, {
|
||||
argv,
|
||||
permissive: true
|
||||
});
|
||||
}
|
||||
|
||||
function getNodeOptionsEnvArgv() {
|
||||
const errors = [];
|
||||
const envArgv = ParseNodeOptionsEnvVar(process.env.NODE_OPTIONS || '', errors);
|
||||
if (errors.length !== 0) {
|
||||
// TODO: handle errors somehow
|
||||
}
|
||||
return envArgv;
|
||||
}
|
||||
|
||||
// Direct JS port of C implementation: https://github.com/nodejs/node/blob/67ba825037b4082d5d16f922fb9ce54516b4a869/src/node_options.cc#L1024-L1063
|
||||
function ParseNodeOptionsEnvVar(node_options, errors) {
|
||||
const env_argv = [];
|
||||
|
||||
let is_in_string = false;
|
||||
let will_start_new_arg = true;
|
||||
for (let index = 0; index < node_options.length; ++index) {
|
||||
let c = node_options[index];
|
||||
|
||||
// Backslashes escape the following character
|
||||
if (c === '\\' && is_in_string) {
|
||||
if (index + 1 === node_options.length) {
|
||||
errors.push("invalid value for NODE_OPTIONS " +
|
||||
"(invalid escape)\n");
|
||||
return env_argv;
|
||||
} else {
|
||||
c = node_options[++index];
|
||||
}
|
||||
} else if (c === ' ' && !is_in_string) {
|
||||
will_start_new_arg = true;
|
||||
continue;
|
||||
} else if (c === '"') {
|
||||
is_in_string = !is_in_string;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (will_start_new_arg) {
|
||||
env_argv.push(c);
|
||||
will_start_new_arg = false;
|
||||
} else {
|
||||
env_argv[env_argv.length - 1] += c;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_in_string) {
|
||||
errors.push("invalid value for NODE_OPTIONS " +
|
||||
"(unterminated string)\n");
|
||||
}
|
||||
return env_argv;
|
||||
}
|
||||
|
||||
// Get option values that can be specified via env vars besides NODE_OPTIONS
|
||||
function getOptionValuesFromOtherEnvVars() {
|
||||
const options = {};
|
||||
if(process.env.NODE_PENDING_DEPRECATION === '1') {
|
||||
options['--pending-deprecation'] = true;
|
||||
}
|
||||
return options;
|
||||
}
|
44
node_modules/ts-node/dist-raw/node-package-json-reader.js
generated
vendored
Normal file
44
node_modules/ts-node/dist-raw/node-package-json-reader.js
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
// copied from https://github.com/nodejs/node/blob/v15.3.0/lib/internal/modules/package_json_reader.js
|
||||
'use strict';
|
||||
|
||||
const { SafeMap } = require('./node-primordials');
|
||||
const { internalModuleReadJSON } = require('./node-internal-fs');
|
||||
const { pathToFileURL } = require('url');
|
||||
const { toNamespacedPath } = require('path');
|
||||
|
||||
const cache = new SafeMap();
|
||||
|
||||
let manifest;
|
||||
|
||||
/**
|
||||
* @param {string} jsonPath
|
||||
* @return {[string, boolean]}
|
||||
*/
|
||||
function read(jsonPath) {
|
||||
if (cache.has(jsonPath)) {
|
||||
return cache.get(jsonPath);
|
||||
}
|
||||
|
||||
const [string, containsKeys] = internalModuleReadJSON(
|
||||
toNamespacedPath(jsonPath)
|
||||
);
|
||||
const result = { string, containsKeys };
|
||||
const { getOptionValue } = require('./node-options');
|
||||
if (string !== undefined) {
|
||||
if (manifest === undefined) {
|
||||
// manifest = getOptionValue('--experimental-policy') ?
|
||||
// require('internal/process/policy').manifest :
|
||||
// null;
|
||||
// disabled for now. I am not sure if/how we should support this
|
||||
manifest = null;
|
||||
}
|
||||
if (manifest !== null) {
|
||||
const jsonURL = pathToFileURL(jsonPath);
|
||||
manifest.assertIntegrity(jsonURL, string);
|
||||
}
|
||||
}
|
||||
cache.set(jsonPath, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
module.exports = { read };
|
22
node_modules/ts-node/dist-raw/node-primordials.js
generated
vendored
Normal file
22
node_modules/ts-node/dist-raw/node-primordials.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
module.exports = {
|
||||
ArrayIsArray: Array.isArray,
|
||||
ArrayPrototypeJoin: (obj, separator) => Array.prototype.join.call(obj, separator),
|
||||
ArrayPrototypeShift: (obj) => Array.prototype.shift.call(obj),
|
||||
JSONParse: JSON.parse,
|
||||
JSONStringify: JSON.stringify,
|
||||
ObjectFreeze: Object.freeze,
|
||||
ObjectGetOwnPropertyNames: Object.getOwnPropertyNames,
|
||||
ObjectPrototypeHasOwnProperty: (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop),
|
||||
RegExpPrototypeTest: (obj, string) => RegExp.prototype.test.call(obj, string),
|
||||
SafeMap: Map,
|
||||
SafeSet: Set,
|
||||
StringPrototypeEndsWith: (str, ...rest) => String.prototype.endsWith.apply(str, rest),
|
||||
StringPrototypeIncludes: (str, ...rest) => String.prototype.includes.apply(str, rest),
|
||||
StringPrototypeLastIndexOf: (str, ...rest) => String.prototype.lastIndexOf.apply(str, rest),
|
||||
StringPrototypeIndexOf: (str, ...rest) => String.prototype.indexOf.apply(str, rest),
|
||||
StringPrototypeReplace: (str, ...rest) => String.prototype.replace.apply(str, rest),
|
||||
StringPrototypeSlice: (str, ...rest) => String.prototype.slice.apply(str, rest),
|
||||
StringPrototypeSplit: (str, ...rest) => String.prototype.split.apply(str, rest),
|
||||
StringPrototypeStartsWith: (str, ...rest) => String.prototype.startsWith.apply(str, rest),
|
||||
StringPrototypeSubstr: (str, ...rest) => String.prototype.substr.apply(str, rest)
|
||||
};
|
2
node_modules/ts-node/dist/bin-script-deprecated.d.ts
generated
vendored
Normal file
2
node_modules/ts-node/dist/bin-script-deprecated.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
export {};
|
7
node_modules/ts-node/dist/bin-script-deprecated.js
generated
vendored
Executable file
7
node_modules/ts-node/dist/bin-script-deprecated.js
generated
vendored
Executable file
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env node
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const bin_1 = require("./bin");
|
||||
console.warn('ts-script has been deprecated and will be removed in the next major release.', 'Please use ts-node-script instead');
|
||||
bin_1.main(undefined, { '--script-mode': true });
|
||||
//# sourceMappingURL=bin-script-deprecated.js.map
|
1
node_modules/ts-node/dist/bin-script-deprecated.js.map
generated
vendored
Normal file
1
node_modules/ts-node/dist/bin-script-deprecated.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"bin-script-deprecated.js","sourceRoot":"","sources":["../src/bin-script-deprecated.ts"],"names":[],"mappings":";;;AAEA,+BAA4B;AAE5B,OAAO,CAAC,IAAI,CACV,8EAA8E,EAC9E,mCAAmC,CACpC,CAAA;AAED,UAAI,CAAC,SAAS,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAA","sourcesContent":["#!/usr/bin/env node\n\nimport { main } from './bin'\n\nconsole.warn(\n 'ts-script has been deprecated and will be removed in the next major release.',\n 'Please use ts-node-script instead'\n)\n\nmain(undefined, { '--script-mode': true })\n"]}
|
2
node_modules/ts-node/dist/bin-script.d.ts
generated
vendored
Normal file
2
node_modules/ts-node/dist/bin-script.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
export {};
|
6
node_modules/ts-node/dist/bin-script.js
generated
vendored
Executable file
6
node_modules/ts-node/dist/bin-script.js
generated
vendored
Executable file
@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const bin_1 = require("./bin");
|
||||
bin_1.main(undefined, { '--script-mode': true });
|
||||
//# sourceMappingURL=bin-script.js.map
|
1
node_modules/ts-node/dist/bin-script.js.map
generated
vendored
Normal file
1
node_modules/ts-node/dist/bin-script.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"bin-script.js","sourceRoot":"","sources":["../src/bin-script.ts"],"names":[],"mappings":";;;AAEA,+BAA4B;AAE5B,UAAI,CAAC,SAAS,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAA","sourcesContent":["#!/usr/bin/env node\n\nimport { main } from './bin'\n\nmain(undefined, { '--script-mode': true })\n"]}
|
2
node_modules/ts-node/dist/bin-transpile.d.ts
generated
vendored
Normal file
2
node_modules/ts-node/dist/bin-transpile.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
export {};
|
6
node_modules/ts-node/dist/bin-transpile.js
generated
vendored
Executable file
6
node_modules/ts-node/dist/bin-transpile.js
generated
vendored
Executable file
@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const bin_1 = require("./bin");
|
||||
bin_1.main(undefined, { '--transpile-only': true });
|
||||
//# sourceMappingURL=bin-transpile.js.map
|
1
node_modules/ts-node/dist/bin-transpile.js.map
generated
vendored
Normal file
1
node_modules/ts-node/dist/bin-transpile.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"bin-transpile.js","sourceRoot":"","sources":["../src/bin-transpile.ts"],"names":[],"mappings":";;;AAEA,+BAA4B;AAE5B,UAAI,CAAC,SAAS,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAA","sourcesContent":["#!/usr/bin/env node\n\nimport { main } from './bin'\n\nmain(undefined, { '--transpile-only': true })\n"]}
|
5
node_modules/ts-node/dist/bin.d.ts
generated
vendored
Normal file
5
node_modules/ts-node/dist/bin.d.ts
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Main `bin` functionality.
|
||||
*/
|
||||
export declare function main(argv?: string[], entrypointArgs?: Record<string, any>): void;
|
240
node_modules/ts-node/dist/bin.js
generated
vendored
Executable file
240
node_modules/ts-node/dist/bin.js
generated
vendored
Executable file
@ -0,0 +1,240 @@
|
||||
#!/usr/bin/env node
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.main = void 0;
|
||||
const path_1 = require("path");
|
||||
const util_1 = require("util");
|
||||
const Module = require("module");
|
||||
const arg = require("arg");
|
||||
const repl_1 = require("./repl");
|
||||
const index_1 = require("./index");
|
||||
/**
|
||||
* Main `bin` functionality.
|
||||
*/
|
||||
function main(argv = process.argv.slice(2), entrypointArgs = {}) {
|
||||
const args = Object.assign(Object.assign({}, entrypointArgs), arg({
|
||||
// Node.js-like options.
|
||||
'--eval': String,
|
||||
'--interactive': Boolean,
|
||||
'--print': Boolean,
|
||||
'--require': [String],
|
||||
// CLI options.
|
||||
'--help': Boolean,
|
||||
'--script-mode': Boolean,
|
||||
'--version': arg.COUNT,
|
||||
// Project options.
|
||||
'--dir': String,
|
||||
'--files': Boolean,
|
||||
'--compiler': String,
|
||||
'--compiler-options': index_1.parse,
|
||||
'--project': String,
|
||||
'--ignore-diagnostics': [String],
|
||||
'--ignore': [String],
|
||||
'--transpile-only': Boolean,
|
||||
'--type-check': Boolean,
|
||||
'--compiler-host': Boolean,
|
||||
'--pretty': Boolean,
|
||||
'--skip-project': Boolean,
|
||||
'--skip-ignore': Boolean,
|
||||
'--prefer-ts-exts': Boolean,
|
||||
'--log-error': Boolean,
|
||||
'--emit': Boolean,
|
||||
// Aliases.
|
||||
'-e': '--eval',
|
||||
'-i': '--interactive',
|
||||
'-p': '--print',
|
||||
'-r': '--require',
|
||||
'-h': '--help',
|
||||
'-s': '--script-mode',
|
||||
'-v': '--version',
|
||||
'-T': '--transpile-only',
|
||||
'-H': '--compiler-host',
|
||||
'-I': '--ignore',
|
||||
'-P': '--project',
|
||||
'-C': '--compiler',
|
||||
'-D': '--ignore-diagnostics',
|
||||
'-O': '--compiler-options'
|
||||
}, {
|
||||
argv,
|
||||
stopAtPositional: true
|
||||
}));
|
||||
// Only setting defaults for CLI-specific flags
|
||||
// Anything passed to `register()` can be `undefined`; `create()` will apply
|
||||
// defaults.
|
||||
const { '--dir': dir, '--help': help = false, '--script-mode': scriptMode = false, '--version': version = 0, '--require': argsRequire = [], '--eval': code = undefined, '--print': print = false, '--interactive': interactive = false, '--files': files, '--compiler': compiler, '--compiler-options': compilerOptions, '--project': project, '--ignore-diagnostics': ignoreDiagnostics, '--ignore': ignore, '--transpile-only': transpileOnly, '--type-check': typeCheck, '--compiler-host': compilerHost, '--pretty': pretty, '--skip-project': skipProject, '--skip-ignore': skipIgnore, '--prefer-ts-exts': preferTsExts, '--log-error': logError, '--emit': emit } = args;
|
||||
if (help) {
|
||||
console.log(`
|
||||
Usage: ts-node [options] [ -e script | script.ts ] [arguments]
|
||||
|
||||
Options:
|
||||
|
||||
-e, --eval [code] Evaluate code
|
||||
-p, --print Print result of \`--eval\`
|
||||
-r, --require [path] Require a node module before execution
|
||||
-i, --interactive Opens the REPL even if stdin does not appear to be a terminal
|
||||
|
||||
-h, --help Print CLI usage
|
||||
-v, --version Print module version information
|
||||
-s, --script-mode Use cwd from <script.ts> instead of current directory
|
||||
|
||||
-T, --transpile-only Use TypeScript's faster \`transpileModule\`
|
||||
-H, --compiler-host Use TypeScript's compiler host API
|
||||
-I, --ignore [pattern] Override the path patterns to skip compilation
|
||||
-P, --project [path] Path to TypeScript JSON project file
|
||||
-C, --compiler [name] Specify a custom TypeScript compiler
|
||||
-D, --ignore-diagnostics [code] Ignore TypeScript warnings by diagnostic code
|
||||
-O, --compiler-options [opts] JSON object to merge with compiler options
|
||||
|
||||
--dir Specify working directory for config resolution
|
||||
--scope Scope compiler to files within \`cwd\` only
|
||||
--files Load \`files\`, \`include\` and \`exclude\` from \`tsconfig.json\` on startup
|
||||
--pretty Use pretty diagnostic formatter (usually enabled by default)
|
||||
--skip-project Skip reading \`tsconfig.json\`
|
||||
--skip-ignore Skip \`--ignore\` checks
|
||||
--prefer-ts-exts Prefer importing TypeScript files over JavaScript files
|
||||
--log-error Logs TypeScript errors to stderr instead of throwing exceptions
|
||||
`);
|
||||
process.exit(0);
|
||||
}
|
||||
// Output project information.
|
||||
if (version === 1) {
|
||||
console.log(`v${index_1.VERSION}`);
|
||||
process.exit(0);
|
||||
}
|
||||
const cwd = dir || process.cwd();
|
||||
/** Unresolved. May point to a symlink, not realpath. May be missing file extension */
|
||||
const scriptPath = args._.length ? path_1.resolve(cwd, args._[0]) : undefined;
|
||||
const state = new repl_1.EvalState(scriptPath || path_1.join(cwd, repl_1.EVAL_FILENAME));
|
||||
const replService = repl_1.createRepl({ state });
|
||||
const { evalAwarePartialHost } = replService;
|
||||
// Register the TypeScript compiler instance.
|
||||
const service = index_1.register({
|
||||
dir: getCwd(dir, scriptMode, scriptPath),
|
||||
emit,
|
||||
files,
|
||||
pretty,
|
||||
transpileOnly,
|
||||
typeCheck,
|
||||
compilerHost,
|
||||
ignore,
|
||||
preferTsExts,
|
||||
logError,
|
||||
project,
|
||||
skipProject,
|
||||
skipIgnore,
|
||||
compiler,
|
||||
ignoreDiagnostics,
|
||||
compilerOptions,
|
||||
require: argsRequire,
|
||||
readFile: code !== undefined ? evalAwarePartialHost.readFile : undefined,
|
||||
fileExists: code !== undefined ? evalAwarePartialHost.fileExists : undefined
|
||||
});
|
||||
// Bind REPL service to ts-node compiler service (chicken-and-egg problem)
|
||||
replService.setService(service);
|
||||
// Output project information.
|
||||
if (version >= 2) {
|
||||
console.log(`ts-node v${index_1.VERSION}`);
|
||||
console.log(`node ${process.version}`);
|
||||
console.log(`compiler v${service.ts.version}`);
|
||||
process.exit(0);
|
||||
}
|
||||
// Create a local module instance based on `cwd`.
|
||||
const module = new Module(state.path);
|
||||
module.filename = state.path;
|
||||
module.paths = Module._nodeModulePaths(cwd);
|
||||
// Prepend `ts-node` arguments to CLI for child processes.
|
||||
process.execArgv.unshift(__filename, ...process.argv.slice(2, process.argv.length - args._.length));
|
||||
process.argv = [process.argv[1]].concat(scriptPath || []).concat(args._.slice(1));
|
||||
// Execute the main contents (either eval, script or piped).
|
||||
if (code !== undefined && !interactive) {
|
||||
evalAndExit(replService, module, code, print);
|
||||
}
|
||||
else {
|
||||
if (args._.length) {
|
||||
Module.runMain();
|
||||
}
|
||||
else {
|
||||
// Piping of execution _only_ occurs when no other script is specified.
|
||||
// --interactive flag forces REPL
|
||||
if (interactive || process.stdin.isTTY) {
|
||||
replService.start(code);
|
||||
}
|
||||
else {
|
||||
let buffer = code || '';
|
||||
process.stdin.on('data', (chunk) => buffer += chunk);
|
||||
process.stdin.on('end', () => evalAndExit(replService, module, buffer, print));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.main = main;
|
||||
/**
|
||||
* Get project path from args.
|
||||
*/
|
||||
function getCwd(dir, scriptMode, scriptPath) {
|
||||
// Validate `--script-mode` usage is correct.
|
||||
if (scriptMode) {
|
||||
if (!scriptPath) {
|
||||
throw new TypeError('Script mode must be used with a script name, e.g. `ts-node -s <script.ts>`');
|
||||
}
|
||||
if (dir) {
|
||||
throw new TypeError('Script mode cannot be combined with `--dir`');
|
||||
}
|
||||
// Use node's own resolution behavior to ensure we follow symlinks.
|
||||
// scriptPath may omit file extension or point to a directory with or without package.json.
|
||||
// This happens before we are registered, so we tell node's resolver to consider ts, tsx, and jsx files.
|
||||
// In extremely rare cases, is is technically possible to resolve the wrong directory,
|
||||
// because we do not yet know preferTsExts, jsx, nor allowJs.
|
||||
// See also, justification why this will not happen in real-world situations:
|
||||
// https://github.com/TypeStrong/ts-node/pull/1009#issuecomment-613017081
|
||||
const exts = ['.js', '.jsx', '.ts', '.tsx'];
|
||||
const extsTemporarilyInstalled = [];
|
||||
for (const ext of exts) {
|
||||
if (!hasOwnProperty(require.extensions, ext)) { // tslint:disable-line
|
||||
extsTemporarilyInstalled.push(ext);
|
||||
require.extensions[ext] = function () { }; // tslint:disable-line
|
||||
}
|
||||
}
|
||||
try {
|
||||
return path_1.dirname(require.resolve(scriptPath));
|
||||
}
|
||||
finally {
|
||||
for (const ext of extsTemporarilyInstalled) {
|
||||
delete require.extensions[ext]; // tslint:disable-line
|
||||
}
|
||||
}
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
/**
|
||||
* Evaluate a script.
|
||||
*/
|
||||
function evalAndExit(replService, module, code, isPrinted) {
|
||||
let result;
|
||||
global.__filename = module.filename;
|
||||
global.__dirname = path_1.dirname(module.filename);
|
||||
global.exports = module.exports;
|
||||
global.module = module;
|
||||
global.require = module.require.bind(module);
|
||||
try {
|
||||
result = replService.evalCode(code);
|
||||
}
|
||||
catch (error) {
|
||||
if (error instanceof index_1.TSError) {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
if (isPrinted) {
|
||||
console.log(typeof result === 'string' ? result : util_1.inspect(result));
|
||||
}
|
||||
}
|
||||
/** Safe `hasOwnProperty` */
|
||||
function hasOwnProperty(object, property) {
|
||||
return Object.prototype.hasOwnProperty.call(object, property);
|
||||
}
|
||||
if (require.main === module) {
|
||||
main();
|
||||
}
|
||||
//# sourceMappingURL=bin.js.map
|
1
node_modules/ts-node/dist/bin.js.map
generated
vendored
Normal file
1
node_modules/ts-node/dist/bin.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
18
node_modules/ts-node/dist/esm.d.ts
generated
vendored
Normal file
18
node_modules/ts-node/dist/esm.d.ts
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
/// <reference types="node" />
|
||||
import { RegisterOptions } from './index';
|
||||
export declare function registerAndCreateEsmHooks(opts?: RegisterOptions): {
|
||||
resolve: (specifier: string, context: {
|
||||
parentURL: string;
|
||||
}, defaultResolve: any) => Promise<{
|
||||
url: string;
|
||||
}>;
|
||||
getFormat: (url: string, context: {}, defaultGetFormat: any) => Promise<{
|
||||
format: "module" | "json" | "builtin" | "commonjs" | "dynamic" | "wasm";
|
||||
}>;
|
||||
transformSource: (source: string | Buffer, context: {
|
||||
url: string;
|
||||
format: "module" | "json" | "builtin" | "commonjs" | "dynamic" | "wasm";
|
||||
}, defaultTransformSource: any) => Promise<{
|
||||
source: string | Buffer;
|
||||
}>;
|
||||
};
|
90
node_modules/ts-node/dist/esm.js
generated
vendored
Normal file
90
node_modules/ts-node/dist/esm.js
generated
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.registerAndCreateEsmHooks = void 0;
|
||||
const index_1 = require("./index");
|
||||
const url_1 = require("url");
|
||||
const path_1 = require("path");
|
||||
const assert = require("assert");
|
||||
const { createResolve } = require('../dist-raw/node-esm-resolve-implementation');
|
||||
// Note: On Windows, URLs look like this: file:///D:/dev/@TypeStrong/ts-node-examples/foo.ts
|
||||
function registerAndCreateEsmHooks(opts) {
|
||||
// Automatically performs registration just like `-r ts-node/register`
|
||||
const tsNodeInstance = index_1.register(Object.assign(Object.assign({}, opts), { experimentalEsmLoader: true }));
|
||||
// Custom implementation that considers additional file extensions and automatically adds file extensions
|
||||
const nodeResolveImplementation = createResolve(Object.assign(Object.assign({}, index_1.getExtensions(tsNodeInstance.config)), { preferTsExts: tsNodeInstance.options.preferTsExts }));
|
||||
return { resolve, getFormat, transformSource };
|
||||
function isFileUrlOrNodeStyleSpecifier(parsed) {
|
||||
// We only understand file:// URLs, but in node, the specifier can be a node-style `./foo` or `foo`
|
||||
const { protocol } = parsed;
|
||||
return protocol === null || protocol === 'file:';
|
||||
}
|
||||
function resolve(specifier, context, defaultResolve) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const defer = () => __awaiter(this, void 0, void 0, function* () {
|
||||
const r = yield defaultResolve(specifier, context, defaultResolve);
|
||||
return r;
|
||||
});
|
||||
const parsed = url_1.parse(specifier);
|
||||
const { pathname, protocol, hostname } = parsed;
|
||||
if (!isFileUrlOrNodeStyleSpecifier(parsed)) {
|
||||
return defer();
|
||||
}
|
||||
if (protocol !== null && protocol !== 'file:') {
|
||||
return defer();
|
||||
}
|
||||
// Malformed file:// URL? We should always see `null` or `''`
|
||||
if (hostname) {
|
||||
// TODO file://./foo sets `hostname` to `'.'`. Perhaps we should special-case this.
|
||||
return defer();
|
||||
}
|
||||
// pathname is the path to be resolved
|
||||
return nodeResolveImplementation.defaultResolve(specifier, context, defaultResolve);
|
||||
});
|
||||
}
|
||||
function getFormat(url, context, defaultGetFormat) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const defer = (overrideUrl = url) => defaultGetFormat(overrideUrl, context, defaultGetFormat);
|
||||
const parsed = url_1.parse(url);
|
||||
if (!isFileUrlOrNodeStyleSpecifier(parsed)) {
|
||||
return defer();
|
||||
}
|
||||
const { pathname } = parsed;
|
||||
assert(pathname !== null, 'ESM getFormat() hook: URL should never have null pathname');
|
||||
const nativePath = url_1.fileURLToPath(url);
|
||||
// If file has .ts, .tsx, or .jsx extension, then ask node how it would treat this file if it were .js
|
||||
const ext = path_1.extname(nativePath);
|
||||
if (ext !== '.js' && !tsNodeInstance.ignored(nativePath)) {
|
||||
return defer(url_1.format(url_1.pathToFileURL(nativePath + '.js')));
|
||||
}
|
||||
return defer();
|
||||
});
|
||||
}
|
||||
function transformSource(source, context, defaultTransformSource) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const defer = () => defaultTransformSource(source, context, defaultTransformSource);
|
||||
const sourceAsString = typeof source === 'string' ? source : source.toString('utf8');
|
||||
const { url } = context;
|
||||
const parsed = url_1.parse(url);
|
||||
if (!isFileUrlOrNodeStyleSpecifier(parsed)) {
|
||||
return defer();
|
||||
}
|
||||
const nativePath = url_1.fileURLToPath(url);
|
||||
if (tsNodeInstance.ignored(nativePath)) {
|
||||
return defer();
|
||||
}
|
||||
const emittedJs = tsNodeInstance.compile(sourceAsString, nativePath);
|
||||
return { source: emittedJs };
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.registerAndCreateEsmHooks = registerAndCreateEsmHooks;
|
||||
//# sourceMappingURL=esm.js.map
|
1
node_modules/ts-node/dist/esm.js.map
generated
vendored
Normal file
1
node_modules/ts-node/dist/esm.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
227
node_modules/ts-node/dist/index.d.ts
generated
vendored
Normal file
227
node_modules/ts-node/dist/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,227 @@
|
||||
import { BaseError } from 'make-error';
|
||||
import type * as _ts from 'typescript';
|
||||
export { createRepl, CreateReplOptions, ReplService } from './repl';
|
||||
/**
|
||||
* Registered `ts-node` instance information.
|
||||
*/
|
||||
export declare const REGISTER_INSTANCE: unique symbol;
|
||||
/**
|
||||
* Expose `REGISTER_INSTANCE` information on node.js `process`.
|
||||
*/
|
||||
declare global {
|
||||
namespace NodeJS {
|
||||
interface Process {
|
||||
[REGISTER_INSTANCE]?: Service;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Common TypeScript interfaces between versions.
|
||||
*/
|
||||
export interface TSCommon {
|
||||
version: typeof _ts.version;
|
||||
sys: typeof _ts.sys;
|
||||
ScriptSnapshot: typeof _ts.ScriptSnapshot;
|
||||
displayPartsToString: typeof _ts.displayPartsToString;
|
||||
createLanguageService: typeof _ts.createLanguageService;
|
||||
getDefaultLibFilePath: typeof _ts.getDefaultLibFilePath;
|
||||
getPreEmitDiagnostics: typeof _ts.getPreEmitDiagnostics;
|
||||
flattenDiagnosticMessageText: typeof _ts.flattenDiagnosticMessageText;
|
||||
transpileModule: typeof _ts.transpileModule;
|
||||
ModuleKind: typeof _ts.ModuleKind;
|
||||
ScriptTarget: typeof _ts.ScriptTarget;
|
||||
findConfigFile: typeof _ts.findConfigFile;
|
||||
readConfigFile: typeof _ts.readConfigFile;
|
||||
parseJsonConfigFileContent: typeof _ts.parseJsonConfigFileContent;
|
||||
formatDiagnostics: typeof _ts.formatDiagnostics;
|
||||
formatDiagnosticsWithColorAndContext: typeof _ts.formatDiagnosticsWithColorAndContext;
|
||||
}
|
||||
/**
|
||||
* Export the current version.
|
||||
*/
|
||||
export declare const VERSION: any;
|
||||
/**
|
||||
* Options for creating a new TypeScript compiler instance.
|
||||
*/
|
||||
export interface CreateOptions {
|
||||
/**
|
||||
* Specify working directory for config resolution.
|
||||
*
|
||||
* @default process.cwd()
|
||||
*/
|
||||
dir?: string;
|
||||
/**
|
||||
* Emit output files into `.ts-node` directory.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
emit?: boolean;
|
||||
/**
|
||||
* Scope compiler to files within `cwd`.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
scope?: boolean;
|
||||
/**
|
||||
* Use pretty diagnostic formatter.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
pretty?: boolean;
|
||||
/**
|
||||
* Use TypeScript's faster `transpileModule`.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
transpileOnly?: boolean;
|
||||
/**
|
||||
* **DEPRECATED** Specify type-check is enabled (e.g. `transpileOnly == false`).
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
typeCheck?: boolean;
|
||||
/**
|
||||
* Use TypeScript's compiler host API.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
compilerHost?: boolean;
|
||||
/**
|
||||
* Logs TypeScript errors to stderr instead of throwing exceptions.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
logError?: boolean;
|
||||
/**
|
||||
* Load files from `tsconfig.json` on startup.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
files?: boolean;
|
||||
/**
|
||||
* Specify a custom TypeScript compiler.
|
||||
*
|
||||
* @default "typescript"
|
||||
*/
|
||||
compiler?: string;
|
||||
/**
|
||||
* Override the path patterns to skip compilation.
|
||||
*
|
||||
* @default /node_modules/
|
||||
* @docsDefault "/node_modules/"
|
||||
*/
|
||||
ignore?: string[];
|
||||
/**
|
||||
* Path to TypeScript JSON project file.
|
||||
*/
|
||||
project?: string;
|
||||
/**
|
||||
* Skip project config resolution and loading.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
skipProject?: boolean;
|
||||
/**
|
||||
* Skip ignore check.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
skipIgnore?: boolean;
|
||||
/**
|
||||
* JSON object to merge with compiler options.
|
||||
*
|
||||
* @allOf [{"$ref": "https://schemastore.azurewebsites.net/schemas/json/tsconfig.json#definitions/compilerOptionsDefinition/properties/compilerOptions"}]
|
||||
*/
|
||||
compilerOptions?: object;
|
||||
/**
|
||||
* Ignore TypeScript warnings by diagnostic code.
|
||||
*/
|
||||
ignoreDiagnostics?: Array<number | string>;
|
||||
/**
|
||||
* Modules to require, like node's `--require` flag.
|
||||
*
|
||||
* If specified in tsconfig.json, the modules will be resolved relative to the tsconfig.json file.
|
||||
*
|
||||
* If specified programmatically, each input string should be pre-resolved to an absolute path for
|
||||
* best results.
|
||||
*/
|
||||
require?: Array<string>;
|
||||
readFile?: (path: string) => string | undefined;
|
||||
fileExists?: (path: string) => boolean;
|
||||
transformers?: _ts.CustomTransformers | ((p: _ts.Program) => _ts.CustomTransformers);
|
||||
}
|
||||
/**
|
||||
* Options for registering a TypeScript compiler instance globally.
|
||||
*/
|
||||
export interface RegisterOptions extends CreateOptions {
|
||||
/**
|
||||
* Re-order file extensions so that TypeScript imports are preferred.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
preferTsExts?: boolean;
|
||||
}
|
||||
/**
|
||||
* Must be an interface to support `typescript-json-schema`.
|
||||
*/
|
||||
export interface TsConfigOptions extends Omit<RegisterOptions, 'transformers' | 'readFile' | 'fileExists' | 'skipProject' | 'project' | 'dir'> {
|
||||
}
|
||||
/**
|
||||
* Information retrieved from type info check.
|
||||
*/
|
||||
export interface TypeInfo {
|
||||
name: string;
|
||||
comment: string;
|
||||
}
|
||||
/**
|
||||
* Default register options, including values specified via environment
|
||||
* variables.
|
||||
*/
|
||||
export declare const DEFAULTS: RegisterOptions;
|
||||
/**
|
||||
* Split a string array of values.
|
||||
*/
|
||||
export declare function split(value: string | undefined): string[] | undefined;
|
||||
/**
|
||||
* Parse a string as JSON.
|
||||
*/
|
||||
export declare function parse(value: string | undefined): object | undefined;
|
||||
/**
|
||||
* Replace backslashes with forward slashes.
|
||||
*/
|
||||
export declare function normalizeSlashes(value: string): string;
|
||||
/**
|
||||
* TypeScript diagnostics error.
|
||||
*/
|
||||
export declare class TSError extends BaseError {
|
||||
diagnosticText: string;
|
||||
diagnosticCodes: number[];
|
||||
name: string;
|
||||
constructor(diagnosticText: string, diagnosticCodes: number[]);
|
||||
}
|
||||
/**
|
||||
* Primary ts-node service, which wraps the TypeScript API and can compile TypeScript to JavaScript
|
||||
*/
|
||||
export interface Service {
|
||||
ts: TSCommon;
|
||||
config: _ts.ParsedCommandLine;
|
||||
options: RegisterOptions;
|
||||
enabled(enabled?: boolean): boolean;
|
||||
ignored(fileName: string): boolean;
|
||||
compile(code: string, fileName: string, lineOffset?: number): string;
|
||||
getTypeInfo(code: string, fileName: string, position: number): TypeInfo;
|
||||
}
|
||||
/**
|
||||
* Re-export of `Service` interface for backwards-compatibility
|
||||
* @deprecated use `Service` instead
|
||||
* @see Service
|
||||
*/
|
||||
export declare type Register = Service;
|
||||
/**
|
||||
* Register TypeScript compiler instance onto node.js
|
||||
*/
|
||||
export declare function register(opts?: RegisterOptions): Service;
|
||||
/**
|
||||
* Create TypeScript compiler instance.
|
||||
*/
|
||||
export declare function create(rawOptions?: CreateOptions): Service;
|
833
node_modules/ts-node/dist/index.js
generated
vendored
Normal file
833
node_modules/ts-node/dist/index.js
generated
vendored
Normal file
@ -0,0 +1,833 @@
|
||||
"use strict";
|
||||
var _a;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.create = exports.register = exports.getExtensions = exports.TSError = exports.normalizeSlashes = exports.parse = exports.split = exports.DEFAULTS = exports.VERSION = exports.debug = exports.INSPECT_CUSTOM = exports.REGISTER_INSTANCE = exports.createRepl = void 0;
|
||||
const path_1 = require("path");
|
||||
const sourceMapSupport = require("source-map-support");
|
||||
const ynModule = require("yn");
|
||||
const make_error_1 = require("make-error");
|
||||
const util = require("util");
|
||||
const url_1 = require("url");
|
||||
const module_1 = require("module");
|
||||
// tslint:disable-next-line
|
||||
const createRequire = (_a = module_1.createRequire !== null && module_1.createRequire !== void 0 ? module_1.createRequire : module_1.createRequireFromPath) !== null && _a !== void 0 ? _a : require('create-require');
|
||||
var repl_1 = require("./repl");
|
||||
Object.defineProperty(exports, "createRepl", { enumerable: true, get: function () { return repl_1.createRepl; } });
|
||||
/**
|
||||
* Does this version of node obey the package.json "type" field
|
||||
* and throw ERR_REQUIRE_ESM when attempting to require() an ESM modules.
|
||||
*/
|
||||
const engineSupportsPackageTypeField = parseInt(process.versions.node.split('.')[0], 10) >= 12;
|
||||
// Loaded conditionally so we don't need to support older node versions
|
||||
let assertScriptCanLoadAsCJSImpl;
|
||||
/**
|
||||
* Assert that script can be loaded as CommonJS when we attempt to require it.
|
||||
* If it should be loaded as ESM, throw ERR_REQUIRE_ESM like node does.
|
||||
*/
|
||||
function assertScriptCanLoadAsCJS(filename) {
|
||||
if (!engineSupportsPackageTypeField)
|
||||
return;
|
||||
if (!assertScriptCanLoadAsCJSImpl)
|
||||
assertScriptCanLoadAsCJSImpl = require('../dist-raw/node-cjs-loader-utils').assertScriptCanLoadAsCJSImpl;
|
||||
assertScriptCanLoadAsCJSImpl(filename);
|
||||
}
|
||||
/**
|
||||
* Registered `ts-node` instance information.
|
||||
*/
|
||||
exports.REGISTER_INSTANCE = Symbol.for('ts-node.register.instance');
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
exports.INSPECT_CUSTOM = util.inspect.custom || 'inspect';
|
||||
/**
|
||||
* Wrapper around yn module that returns `undefined` instead of `null`.
|
||||
* This is implemented by yn v4, but we're staying on v3 to avoid v4's node 10 requirement.
|
||||
*/
|
||||
function yn(value) {
|
||||
var _a;
|
||||
return (_a = ynModule(value)) !== null && _a !== void 0 ? _a : undefined;
|
||||
}
|
||||
/**
|
||||
* Debugging `ts-node`.
|
||||
*/
|
||||
const shouldDebug = yn(process.env.TS_NODE_DEBUG);
|
||||
/** @internal */
|
||||
exports.debug = shouldDebug ?
|
||||
(...args) => console.log(`[ts-node ${new Date().toISOString()}]`, ...args)
|
||||
: () => undefined;
|
||||
const debugFn = shouldDebug ?
|
||||
(key, fn) => {
|
||||
let i = 0;
|
||||
return (x) => {
|
||||
exports.debug(key, x, ++i);
|
||||
return fn(x);
|
||||
};
|
||||
} :
|
||||
(_, fn) => fn;
|
||||
/**
|
||||
* Export the current version.
|
||||
*/
|
||||
exports.VERSION = require('../package.json').version;
|
||||
/**
|
||||
* Like `Object.assign`, but ignores `undefined` properties.
|
||||
*/
|
||||
function assign(initialValue, ...sources) {
|
||||
for (const source of sources) {
|
||||
for (const key of Object.keys(source)) {
|
||||
const value = source[key];
|
||||
if (value !== undefined)
|
||||
initialValue[key] = value;
|
||||
}
|
||||
}
|
||||
return initialValue;
|
||||
}
|
||||
/**
|
||||
* Default register options, including values specified via environment
|
||||
* variables.
|
||||
*/
|
||||
exports.DEFAULTS = {
|
||||
dir: process.env.TS_NODE_DIR,
|
||||
emit: yn(process.env.TS_NODE_EMIT),
|
||||
scope: yn(process.env.TS_NODE_SCOPE),
|
||||
files: yn(process.env.TS_NODE_FILES),
|
||||
pretty: yn(process.env.TS_NODE_PRETTY),
|
||||
compiler: process.env.TS_NODE_COMPILER,
|
||||
compilerOptions: parse(process.env.TS_NODE_COMPILER_OPTIONS),
|
||||
ignore: split(process.env.TS_NODE_IGNORE),
|
||||
project: process.env.TS_NODE_PROJECT,
|
||||
skipProject: yn(process.env.TS_NODE_SKIP_PROJECT),
|
||||
skipIgnore: yn(process.env.TS_NODE_SKIP_IGNORE),
|
||||
preferTsExts: yn(process.env.TS_NODE_PREFER_TS_EXTS),
|
||||
ignoreDiagnostics: split(process.env.TS_NODE_IGNORE_DIAGNOSTICS),
|
||||
transpileOnly: yn(process.env.TS_NODE_TRANSPILE_ONLY),
|
||||
typeCheck: yn(process.env.TS_NODE_TYPE_CHECK),
|
||||
compilerHost: yn(process.env.TS_NODE_COMPILER_HOST),
|
||||
logError: yn(process.env.TS_NODE_LOG_ERROR),
|
||||
experimentalEsmLoader: false
|
||||
};
|
||||
/**
|
||||
* TypeScript compiler option values required by `ts-node` which cannot be overridden.
|
||||
*/
|
||||
const TS_NODE_COMPILER_OPTIONS = {
|
||||
sourceMap: true,
|
||||
inlineSourceMap: false,
|
||||
inlineSources: true,
|
||||
declaration: false,
|
||||
noEmit: false,
|
||||
outDir: '.ts-node'
|
||||
};
|
||||
/**
|
||||
* Split a string array of values.
|
||||
*/
|
||||
function split(value) {
|
||||
return typeof value === 'string' ? value.split(/ *, */g) : undefined;
|
||||
}
|
||||
exports.split = split;
|
||||
/**
|
||||
* Parse a string as JSON.
|
||||
*/
|
||||
function parse(value) {
|
||||
return typeof value === 'string' ? JSON.parse(value) : undefined;
|
||||
}
|
||||
exports.parse = parse;
|
||||
/**
|
||||
* Replace backslashes with forward slashes.
|
||||
*/
|
||||
function normalizeSlashes(value) {
|
||||
return value.replace(/\\/g, '/');
|
||||
}
|
||||
exports.normalizeSlashes = normalizeSlashes;
|
||||
/**
|
||||
* TypeScript diagnostics error.
|
||||
*/
|
||||
class TSError extends make_error_1.BaseError {
|
||||
constructor(diagnosticText, diagnosticCodes) {
|
||||
super(`⨯ Unable to compile TypeScript:\n${diagnosticText}`);
|
||||
this.diagnosticText = diagnosticText;
|
||||
this.diagnosticCodes = diagnosticCodes;
|
||||
this.name = 'TSError';
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
[exports.INSPECT_CUSTOM]() {
|
||||
return this.diagnosticText;
|
||||
}
|
||||
}
|
||||
exports.TSError = TSError;
|
||||
/**
|
||||
* Cached fs operation wrapper.
|
||||
*/
|
||||
function cachedLookup(fn) {
|
||||
const cache = new Map();
|
||||
return (arg) => {
|
||||
if (!cache.has(arg)) {
|
||||
cache.set(arg, fn(arg));
|
||||
}
|
||||
return cache.get(arg);
|
||||
};
|
||||
}
|
||||
/** @internal */
|
||||
function getExtensions(config) {
|
||||
const tsExtensions = ['.ts'];
|
||||
const jsExtensions = [];
|
||||
// Enable additional extensions when JSX or `allowJs` is enabled.
|
||||
if (config.options.jsx)
|
||||
tsExtensions.push('.tsx');
|
||||
if (config.options.allowJs)
|
||||
jsExtensions.push('.js');
|
||||
if (config.options.jsx && config.options.allowJs)
|
||||
jsExtensions.push('.jsx');
|
||||
return { tsExtensions, jsExtensions };
|
||||
}
|
||||
exports.getExtensions = getExtensions;
|
||||
/**
|
||||
* Register TypeScript compiler instance onto node.js
|
||||
*/
|
||||
function register(opts = {}) {
|
||||
const originalJsHandler = require.extensions['.js']; // tslint:disable-line
|
||||
const service = create(opts);
|
||||
const { tsExtensions, jsExtensions } = getExtensions(service.config);
|
||||
const extensions = [...tsExtensions, ...jsExtensions];
|
||||
// Expose registered instance globally.
|
||||
process[exports.REGISTER_INSTANCE] = service;
|
||||
// Register the extensions.
|
||||
registerExtensions(service.options.preferTsExts, extensions, service, originalJsHandler);
|
||||
module_1.Module._preloadModules(service.options.require);
|
||||
return service;
|
||||
}
|
||||
exports.register = register;
|
||||
/**
|
||||
* Create TypeScript compiler instance.
|
||||
*/
|
||||
function create(rawOptions = {}) {
|
||||
var _a, _b;
|
||||
const dir = (_a = rawOptions.dir) !== null && _a !== void 0 ? _a : exports.DEFAULTS.dir;
|
||||
const compilerName = (_b = rawOptions.compiler) !== null && _b !== void 0 ? _b : exports.DEFAULTS.compiler;
|
||||
const cwd = dir ? path_1.resolve(dir) : process.cwd();
|
||||
/**
|
||||
* Load the typescript compiler. It is required to load the tsconfig but might
|
||||
* be changed by the tsconfig, so we sometimes have to do this twice.
|
||||
*/
|
||||
function loadCompiler(name) {
|
||||
const compiler = require.resolve(name || 'typescript', { paths: [cwd, __dirname] });
|
||||
const ts = require(compiler);
|
||||
return { compiler, ts };
|
||||
}
|
||||
// Compute minimum options to read the config file.
|
||||
let { compiler, ts } = loadCompiler(compilerName);
|
||||
// Read config file and merge new options between env and CLI options.
|
||||
const { config, options: tsconfigOptions } = readConfig(cwd, ts, rawOptions);
|
||||
const options = assign({}, exports.DEFAULTS, tsconfigOptions || {}, rawOptions);
|
||||
options.require = [
|
||||
...tsconfigOptions.require || [],
|
||||
...rawOptions.require || []
|
||||
];
|
||||
// If `compiler` option changed based on tsconfig, re-load the compiler.
|
||||
if (options.compiler !== compilerName) {
|
||||
({ compiler, ts } = loadCompiler(options.compiler));
|
||||
}
|
||||
const readFile = options.readFile || ts.sys.readFile;
|
||||
const fileExists = options.fileExists || ts.sys.fileExists;
|
||||
// typeCheck can override transpileOnly, useful for CLI flag to override config file
|
||||
const transpileOnly = options.transpileOnly === true && options.typeCheck !== true;
|
||||
const transformers = options.transformers || undefined;
|
||||
const ignoreDiagnostics = [
|
||||
6059,
|
||||
18002,
|
||||
18003,
|
||||
...(options.ignoreDiagnostics || [])
|
||||
].map(Number);
|
||||
const configDiagnosticList = filterDiagnostics(config.errors, ignoreDiagnostics);
|
||||
const outputCache = new Map();
|
||||
const isScoped = options.scope ? (relname) => relname.charAt(0) !== '.' : () => true;
|
||||
const shouldIgnore = createIgnore(options.skipIgnore ? [] : (options.ignore || ['(?:^|/)node_modules/']).map(str => new RegExp(str)));
|
||||
const diagnosticHost = {
|
||||
getNewLine: () => ts.sys.newLine,
|
||||
getCurrentDirectory: () => cwd,
|
||||
getCanonicalFileName: ts.sys.useCaseSensitiveFileNames ? x => x : x => x.toLowerCase()
|
||||
};
|
||||
// Install source map support and read from memory cache.
|
||||
sourceMapSupport.install({
|
||||
environment: 'node',
|
||||
retrieveFile(pathOrUrl) {
|
||||
var _a;
|
||||
let path = pathOrUrl;
|
||||
// If it's a file URL, convert to local path
|
||||
// Note: fileURLToPath does not exist on early node v10
|
||||
// I could not find a way to handle non-URLs except to swallow an error
|
||||
if (options.experimentalEsmLoader && path.startsWith('file://')) {
|
||||
try {
|
||||
path = url_1.fileURLToPath(path);
|
||||
}
|
||||
catch (e) { /* swallow error */ }
|
||||
}
|
||||
path = normalizeSlashes(path);
|
||||
return ((_a = outputCache.get(path)) === null || _a === void 0 ? void 0 : _a.content) || '';
|
||||
}
|
||||
});
|
||||
const formatDiagnostics = process.stdout.isTTY || options.pretty
|
||||
? (ts.formatDiagnosticsWithColorAndContext || ts.formatDiagnostics)
|
||||
: ts.formatDiagnostics;
|
||||
function createTSError(diagnostics) {
|
||||
const diagnosticText = formatDiagnostics(diagnostics, diagnosticHost);
|
||||
const diagnosticCodes = diagnostics.map(x => x.code);
|
||||
return new TSError(diagnosticText, diagnosticCodes);
|
||||
}
|
||||
function reportTSError(configDiagnosticList) {
|
||||
const error = createTSError(configDiagnosticList);
|
||||
if (options.logError) {
|
||||
// Print error in red color and continue execution.
|
||||
console.error('\x1b[31m%s\x1b[0m', error);
|
||||
}
|
||||
else {
|
||||
// Throw error and exit the script.
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
// Render the configuration errors.
|
||||
if (configDiagnosticList.length)
|
||||
reportTSError(configDiagnosticList);
|
||||
/**
|
||||
* Get the extension for a transpiled file.
|
||||
*/
|
||||
const getExtension = config.options.jsx === ts.JsxEmit.Preserve ?
|
||||
((path) => /\.[tj]sx$/.test(path) ? '.jsx' : '.js') :
|
||||
((_) => '.js');
|
||||
/**
|
||||
* Create the basic required function using transpile mode.
|
||||
*/
|
||||
let getOutput;
|
||||
let getTypeInfo;
|
||||
const getCanonicalFileName = ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames);
|
||||
// In a factory because these are shared across both CompilerHost and LanguageService codepaths
|
||||
function createResolverFunctions(serviceHost) {
|
||||
const moduleResolutionCache = ts.createModuleResolutionCache(cwd, getCanonicalFileName, config.options);
|
||||
const knownInternalFilenames = new Set();
|
||||
/** "Buckets" (module directories) whose contents should be marked "internal" */
|
||||
const internalBuckets = new Set();
|
||||
// Get bucket for a source filename. Bucket is the containing `./node_modules/*/` directory
|
||||
// For '/project/node_modules/foo/node_modules/bar/lib/index.js' bucket is '/project/node_modules/foo/node_modules/bar/'
|
||||
// For '/project/node_modules/foo/node_modules/@scope/bar/lib/index.js' bucket is '/project/node_modules/foo/node_modules/@scope/bar/'
|
||||
const moduleBucketRe = /.*\/node_modules\/(?:@[^\/]+\/)?[^\/]+\//;
|
||||
function getModuleBucket(filename) {
|
||||
const find = moduleBucketRe.exec(filename);
|
||||
if (find)
|
||||
return find[0];
|
||||
return '';
|
||||
}
|
||||
// Mark that this file and all siblings in its bucket should be "internal"
|
||||
function markBucketOfFilenameInternal(filename) {
|
||||
internalBuckets.add(getModuleBucket(filename));
|
||||
}
|
||||
function isFileInInternalBucket(filename) {
|
||||
return internalBuckets.has(getModuleBucket(filename));
|
||||
}
|
||||
function isFileKnownToBeInternal(filename) {
|
||||
return knownInternalFilenames.has(filename);
|
||||
}
|
||||
/**
|
||||
* If we need to emit JS for a file, force TS to consider it non-external
|
||||
*/
|
||||
const fixupResolvedModule = (resolvedModule) => {
|
||||
const { resolvedFileName } = resolvedModule;
|
||||
if (resolvedFileName === undefined)
|
||||
return;
|
||||
// .ts is always switched to internal
|
||||
// .js is switched on-demand
|
||||
if (resolvedModule.isExternalLibraryImport && ((resolvedFileName.endsWith('.ts') && !resolvedFileName.endsWith('.d.ts')) ||
|
||||
isFileKnownToBeInternal(resolvedFileName) ||
|
||||
isFileInInternalBucket(resolvedFileName))) {
|
||||
resolvedModule.isExternalLibraryImport = false;
|
||||
}
|
||||
if (!resolvedModule.isExternalLibraryImport) {
|
||||
knownInternalFilenames.add(resolvedFileName);
|
||||
}
|
||||
};
|
||||
/*
|
||||
* NOTE:
|
||||
* Older ts versions do not pass `redirectedReference` nor `options`.
|
||||
* We must pass `redirectedReference` to newer ts versions, but cannot rely on `options`, hence the weird argument name
|
||||
*/
|
||||
const resolveModuleNames = (moduleNames, containingFile, reusedNames, redirectedReference, optionsOnlyWithNewerTsVersions) => {
|
||||
return moduleNames.map(moduleName => {
|
||||
const { resolvedModule } = ts.resolveModuleName(moduleName, containingFile, config.options, serviceHost, moduleResolutionCache, redirectedReference);
|
||||
if (resolvedModule) {
|
||||
fixupResolvedModule(resolvedModule);
|
||||
}
|
||||
return resolvedModule;
|
||||
});
|
||||
};
|
||||
// language service never calls this, but TS docs recommend that we implement it
|
||||
const getResolvedModuleWithFailedLookupLocationsFromCache = (moduleName, containingFile) => {
|
||||
const ret = ts.resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache);
|
||||
if (ret && ret.resolvedModule) {
|
||||
fixupResolvedModule(ret.resolvedModule);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
const resolveTypeReferenceDirectives = (typeDirectiveNames, containingFile, redirectedReference, options) => {
|
||||
// Note: seems to be called with empty typeDirectiveNames array for all files.
|
||||
return typeDirectiveNames.map(typeDirectiveName => {
|
||||
const { resolvedTypeReferenceDirective } = ts.resolveTypeReferenceDirective(typeDirectiveName, containingFile, config.options, serviceHost, redirectedReference);
|
||||
if (resolvedTypeReferenceDirective) {
|
||||
fixupResolvedModule(resolvedTypeReferenceDirective);
|
||||
}
|
||||
return resolvedTypeReferenceDirective;
|
||||
});
|
||||
};
|
||||
return {
|
||||
resolveModuleNames,
|
||||
getResolvedModuleWithFailedLookupLocationsFromCache,
|
||||
resolveTypeReferenceDirectives,
|
||||
isFileKnownToBeInternal,
|
||||
markBucketOfFilenameInternal
|
||||
};
|
||||
}
|
||||
// Use full language services when the fast option is disabled.
|
||||
if (!transpileOnly) {
|
||||
const fileContents = new Map();
|
||||
const rootFileNames = new Set(config.fileNames);
|
||||
const cachedReadFile = cachedLookup(debugFn('readFile', readFile));
|
||||
// Use language services by default (TODO: invert next major version).
|
||||
if (!options.compilerHost) {
|
||||
let projectVersion = 1;
|
||||
const fileVersions = new Map(Array.from(rootFileNames).map(fileName => [fileName, 0]));
|
||||
const getCustomTransformers = () => {
|
||||
if (typeof transformers === 'function') {
|
||||
const program = service.getProgram();
|
||||
return program ? transformers(program) : undefined;
|
||||
}
|
||||
return transformers;
|
||||
};
|
||||
// Create the compiler host for type checking.
|
||||
const serviceHost = {
|
||||
getProjectVersion: () => String(projectVersion),
|
||||
getScriptFileNames: () => Array.from(rootFileNames),
|
||||
getScriptVersion: (fileName) => {
|
||||
const version = fileVersions.get(fileName);
|
||||
return version ? version.toString() : '';
|
||||
},
|
||||
getScriptSnapshot(fileName) {
|
||||
// TODO ordering of this with getScriptVersion? Should they sync up?
|
||||
let contents = fileContents.get(fileName);
|
||||
// Read contents into TypeScript memory cache.
|
||||
if (contents === undefined) {
|
||||
contents = cachedReadFile(fileName);
|
||||
if (contents === undefined)
|
||||
return;
|
||||
fileVersions.set(fileName, 1);
|
||||
fileContents.set(fileName, contents);
|
||||
projectVersion++;
|
||||
}
|
||||
return ts.ScriptSnapshot.fromString(contents);
|
||||
},
|
||||
readFile: cachedReadFile,
|
||||
readDirectory: ts.sys.readDirectory,
|
||||
getDirectories: cachedLookup(debugFn('getDirectories', ts.sys.getDirectories)),
|
||||
fileExists: cachedLookup(debugFn('fileExists', fileExists)),
|
||||
directoryExists: cachedLookup(debugFn('directoryExists', ts.sys.directoryExists)),
|
||||
realpath: ts.sys.realpath ? cachedLookup(debugFn('realpath', ts.sys.realpath)) : undefined,
|
||||
getNewLine: () => ts.sys.newLine,
|
||||
useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames,
|
||||
getCurrentDirectory: () => cwd,
|
||||
getCompilationSettings: () => config.options,
|
||||
getDefaultLibFileName: () => ts.getDefaultLibFilePath(config.options),
|
||||
getCustomTransformers: getCustomTransformers
|
||||
};
|
||||
const { resolveModuleNames, getResolvedModuleWithFailedLookupLocationsFromCache, resolveTypeReferenceDirectives, isFileKnownToBeInternal, markBucketOfFilenameInternal } = createResolverFunctions(serviceHost);
|
||||
serviceHost.resolveModuleNames = resolveModuleNames;
|
||||
serviceHost.getResolvedModuleWithFailedLookupLocationsFromCache = getResolvedModuleWithFailedLookupLocationsFromCache;
|
||||
serviceHost.resolveTypeReferenceDirectives = resolveTypeReferenceDirectives;
|
||||
const registry = ts.createDocumentRegistry(ts.sys.useCaseSensitiveFileNames, cwd);
|
||||
const service = ts.createLanguageService(serviceHost, registry);
|
||||
const updateMemoryCache = (contents, fileName) => {
|
||||
// Add to `rootFiles` as necessary, either to make TS include a file it has not seen,
|
||||
// or to trigger a re-classification of files from external to internal.
|
||||
if (!rootFileNames.has(fileName) && !isFileKnownToBeInternal(fileName)) {
|
||||
markBucketOfFilenameInternal(fileName);
|
||||
rootFileNames.add(fileName);
|
||||
// Increment project version for every change to rootFileNames.
|
||||
projectVersion++;
|
||||
}
|
||||
const previousVersion = fileVersions.get(fileName) || 0;
|
||||
const previousContents = fileContents.get(fileName);
|
||||
// Avoid incrementing cache when nothing has changed.
|
||||
if (contents !== previousContents) {
|
||||
fileVersions.set(fileName, previousVersion + 1);
|
||||
fileContents.set(fileName, contents);
|
||||
// Increment project version for every file change.
|
||||
projectVersion++;
|
||||
}
|
||||
};
|
||||
let previousProgram = undefined;
|
||||
getOutput = (code, fileName) => {
|
||||
updateMemoryCache(code, fileName);
|
||||
const programBefore = service.getProgram();
|
||||
if (programBefore !== previousProgram) {
|
||||
exports.debug(`compiler rebuilt Program instance when getting output for ${fileName}`);
|
||||
}
|
||||
const output = service.getEmitOutput(fileName);
|
||||
// Get the relevant diagnostics - this is 3x faster than `getPreEmitDiagnostics`.
|
||||
const diagnostics = service.getSemanticDiagnostics(fileName)
|
||||
.concat(service.getSyntacticDiagnostics(fileName));
|
||||
const programAfter = service.getProgram();
|
||||
exports.debug('invariant: Is service.getProject() identical before and after getting emit output and diagnostics? (should always be true) ', programBefore === programAfter);
|
||||
previousProgram = programAfter;
|
||||
const diagnosticList = filterDiagnostics(diagnostics, ignoreDiagnostics);
|
||||
if (diagnosticList.length)
|
||||
reportTSError(diagnosticList);
|
||||
if (output.emitSkipped) {
|
||||
throw new TypeError(`${path_1.relative(cwd, fileName)}: Emit skipped`);
|
||||
}
|
||||
// Throw an error when requiring `.d.ts` files.
|
||||
if (output.outputFiles.length === 0) {
|
||||
throw new TypeError(`Unable to require file: ${path_1.relative(cwd, fileName)}\n` +
|
||||
'This is usually the result of a faulty configuration or import. ' +
|
||||
'Make sure there is a `.js`, `.json` or other executable extension with ' +
|
||||
'loader attached before `ts-node` available.');
|
||||
}
|
||||
return [output.outputFiles[1].text, output.outputFiles[0].text];
|
||||
};
|
||||
getTypeInfo = (code, fileName, position) => {
|
||||
updateMemoryCache(code, fileName);
|
||||
const info = service.getQuickInfoAtPosition(fileName, position);
|
||||
const name = ts.displayPartsToString(info ? info.displayParts : []);
|
||||
const comment = ts.displayPartsToString(info ? info.documentation : []);
|
||||
return { name, comment };
|
||||
};
|
||||
}
|
||||
else {
|
||||
const sys = Object.assign(Object.assign(Object.assign({}, ts.sys), diagnosticHost), { readFile: (fileName) => {
|
||||
const cacheContents = fileContents.get(fileName);
|
||||
if (cacheContents !== undefined)
|
||||
return cacheContents;
|
||||
const contents = cachedReadFile(fileName);
|
||||
if (contents)
|
||||
fileContents.set(fileName, contents);
|
||||
return contents;
|
||||
}, readDirectory: ts.sys.readDirectory, getDirectories: cachedLookup(debugFn('getDirectories', ts.sys.getDirectories)), fileExists: cachedLookup(debugFn('fileExists', fileExists)), directoryExists: cachedLookup(debugFn('directoryExists', ts.sys.directoryExists)), resolvePath: cachedLookup(debugFn('resolvePath', ts.sys.resolvePath)), realpath: ts.sys.realpath ? cachedLookup(debugFn('realpath', ts.sys.realpath)) : undefined });
|
||||
const host = ts.createIncrementalCompilerHost
|
||||
? ts.createIncrementalCompilerHost(config.options, sys)
|
||||
: Object.assign(Object.assign({}, sys), { getSourceFile: (fileName, languageVersion) => {
|
||||
const contents = sys.readFile(fileName);
|
||||
if (contents === undefined)
|
||||
return;
|
||||
return ts.createSourceFile(fileName, contents, languageVersion);
|
||||
}, getDefaultLibLocation: () => normalizeSlashes(path_1.dirname(compiler)), getDefaultLibFileName: () => normalizeSlashes(path_1.join(path_1.dirname(compiler), ts.getDefaultLibFileName(config.options))), useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames });
|
||||
const { resolveModuleNames, resolveTypeReferenceDirectives, isFileKnownToBeInternal, markBucketOfFilenameInternal } = createResolverFunctions(host);
|
||||
host.resolveModuleNames = resolveModuleNames;
|
||||
host.resolveTypeReferenceDirectives = resolveTypeReferenceDirectives;
|
||||
// Fallback for older TypeScript releases without incremental API.
|
||||
let builderProgram = ts.createIncrementalProgram
|
||||
? ts.createIncrementalProgram({
|
||||
rootNames: Array.from(rootFileNames),
|
||||
options: config.options,
|
||||
host: host,
|
||||
configFileParsingDiagnostics: config.errors,
|
||||
projectReferences: config.projectReferences
|
||||
})
|
||||
: ts.createEmitAndSemanticDiagnosticsBuilderProgram(Array.from(rootFileNames), config.options, host, undefined, config.errors, config.projectReferences);
|
||||
// Read and cache custom transformers.
|
||||
const customTransformers = typeof transformers === 'function'
|
||||
? transformers(builderProgram.getProgram())
|
||||
: transformers;
|
||||
// Set the file contents into cache manually.
|
||||
const updateMemoryCache = (contents, fileName) => {
|
||||
const previousContents = fileContents.get(fileName);
|
||||
const contentsChanged = previousContents !== contents;
|
||||
if (contentsChanged) {
|
||||
fileContents.set(fileName, contents);
|
||||
}
|
||||
// Add to `rootFiles` when discovered by compiler for the first time.
|
||||
let addedToRootFileNames = false;
|
||||
if (!rootFileNames.has(fileName) && !isFileKnownToBeInternal(fileName)) {
|
||||
markBucketOfFilenameInternal(fileName);
|
||||
rootFileNames.add(fileName);
|
||||
addedToRootFileNames = true;
|
||||
}
|
||||
// Update program when file changes.
|
||||
if (addedToRootFileNames || contentsChanged) {
|
||||
builderProgram = ts.createEmitAndSemanticDiagnosticsBuilderProgram(Array.from(rootFileNames), config.options, host, builderProgram, config.errors, config.projectReferences);
|
||||
}
|
||||
};
|
||||
getOutput = (code, fileName) => {
|
||||
const output = ['', ''];
|
||||
updateMemoryCache(code, fileName);
|
||||
const sourceFile = builderProgram.getSourceFile(fileName);
|
||||
if (!sourceFile)
|
||||
throw new TypeError(`Unable to read file: ${fileName}`);
|
||||
const program = builderProgram.getProgram();
|
||||
const diagnostics = ts.getPreEmitDiagnostics(program, sourceFile);
|
||||
const diagnosticList = filterDiagnostics(diagnostics, ignoreDiagnostics);
|
||||
if (diagnosticList.length)
|
||||
reportTSError(diagnosticList);
|
||||
const result = builderProgram.emit(sourceFile, (path, file, writeByteOrderMark) => {
|
||||
if (path.endsWith('.map')) {
|
||||
output[1] = file;
|
||||
}
|
||||
else {
|
||||
output[0] = file;
|
||||
}
|
||||
if (options.emit)
|
||||
sys.writeFile(path, file, writeByteOrderMark);
|
||||
}, undefined, undefined, customTransformers);
|
||||
if (result.emitSkipped) {
|
||||
throw new TypeError(`${path_1.relative(cwd, fileName)}: Emit skipped`);
|
||||
}
|
||||
// Throw an error when requiring files that cannot be compiled.
|
||||
if (output[0] === '') {
|
||||
if (program.isSourceFileFromExternalLibrary(sourceFile)) {
|
||||
throw new TypeError(`Unable to compile file from external library: ${path_1.relative(cwd, fileName)}`);
|
||||
}
|
||||
throw new TypeError(`Unable to require file: ${path_1.relative(cwd, fileName)}\n` +
|
||||
'This is usually the result of a faulty configuration or import. ' +
|
||||
'Make sure there is a `.js`, `.json` or other executable extension with ' +
|
||||
'loader attached before `ts-node` available.');
|
||||
}
|
||||
return output;
|
||||
};
|
||||
getTypeInfo = (code, fileName, position) => {
|
||||
updateMemoryCache(code, fileName);
|
||||
const sourceFile = builderProgram.getSourceFile(fileName);
|
||||
if (!sourceFile)
|
||||
throw new TypeError(`Unable to read file: ${fileName}`);
|
||||
const node = getTokenAtPosition(ts, sourceFile, position);
|
||||
const checker = builderProgram.getProgram().getTypeChecker();
|
||||
const symbol = checker.getSymbolAtLocation(node);
|
||||
if (!symbol)
|
||||
return { name: '', comment: '' };
|
||||
const type = checker.getTypeOfSymbolAtLocation(symbol, node);
|
||||
const signatures = [...type.getConstructSignatures(), ...type.getCallSignatures()];
|
||||
return {
|
||||
name: signatures.length ? signatures.map(x => checker.signatureToString(x)).join('\n') : checker.typeToString(type),
|
||||
comment: ts.displayPartsToString(symbol ? symbol.getDocumentationComment(checker) : [])
|
||||
};
|
||||
};
|
||||
// Write `.tsbuildinfo` when `--build` is enabled.
|
||||
if (options.emit && config.options.incremental) {
|
||||
process.on('exit', () => {
|
||||
// Emits `.tsbuildinfo` to filesystem.
|
||||
builderProgram.getProgram().emitBuildInfo();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (typeof transformers === 'function') {
|
||||
throw new TypeError('Transformers function is unavailable in "--transpile-only"');
|
||||
}
|
||||
getOutput = (code, fileName) => {
|
||||
const result = ts.transpileModule(code, {
|
||||
fileName,
|
||||
compilerOptions: config.options,
|
||||
reportDiagnostics: true,
|
||||
transformers: transformers
|
||||
});
|
||||
const diagnosticList = filterDiagnostics(result.diagnostics || [], ignoreDiagnostics);
|
||||
if (diagnosticList.length)
|
||||
reportTSError(diagnosticList);
|
||||
return [result.outputText, result.sourceMapText];
|
||||
};
|
||||
getTypeInfo = () => {
|
||||
throw new TypeError('Type information is unavailable in "--transpile-only"');
|
||||
};
|
||||
}
|
||||
// Create a simple TypeScript compiler proxy.
|
||||
function compile(code, fileName, lineOffset = 0) {
|
||||
const normalizedFileName = normalizeSlashes(fileName);
|
||||
const [value, sourceMap] = getOutput(code, normalizedFileName);
|
||||
const output = updateOutput(value, normalizedFileName, sourceMap, getExtension);
|
||||
outputCache.set(normalizedFileName, { content: output });
|
||||
return output;
|
||||
}
|
||||
let active = true;
|
||||
const enabled = (enabled) => enabled === undefined ? active : (active = !!enabled);
|
||||
const extensions = getExtensions(config);
|
||||
const ignored = (fileName) => {
|
||||
if (!active)
|
||||
return true;
|
||||
const ext = path_1.extname(fileName);
|
||||
if (extensions.tsExtensions.includes(ext) || extensions.jsExtensions.includes(ext)) {
|
||||
const relname = path_1.relative(cwd, fileName);
|
||||
return !isScoped(relname) || shouldIgnore(relname);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
return { ts, config, compile, getTypeInfo, ignored, enabled, options };
|
||||
}
|
||||
exports.create = create;
|
||||
/**
|
||||
* Check if the filename should be ignored.
|
||||
*/
|
||||
function createIgnore(ignore) {
|
||||
return (relname) => {
|
||||
const path = normalizeSlashes(relname);
|
||||
return ignore.some(x => x.test(path));
|
||||
};
|
||||
}
|
||||
/**
|
||||
* "Refreshes" an extension on `require.extensions`.
|
||||
*
|
||||
* @param {string} ext
|
||||
*/
|
||||
function reorderRequireExtension(ext) {
|
||||
const old = require.extensions[ext]; // tslint:disable-line
|
||||
delete require.extensions[ext]; // tslint:disable-line
|
||||
require.extensions[ext] = old; // tslint:disable-line
|
||||
}
|
||||
/**
|
||||
* Register the extensions to support when importing files.
|
||||
*/
|
||||
function registerExtensions(preferTsExts, extensions, service, originalJsHandler) {
|
||||
// Register new extensions.
|
||||
for (const ext of extensions) {
|
||||
registerExtension(ext, service, originalJsHandler);
|
||||
}
|
||||
if (preferTsExts) {
|
||||
// tslint:disable-next-line
|
||||
const preferredExtensions = new Set([...extensions, ...Object.keys(require.extensions)]);
|
||||
for (const ext of preferredExtensions)
|
||||
reorderRequireExtension(ext);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Register the extension for node.
|
||||
*/
|
||||
function registerExtension(ext, service, originalHandler) {
|
||||
const old = require.extensions[ext] || originalHandler; // tslint:disable-line
|
||||
require.extensions[ext] = function (m, filename) {
|
||||
if (service.ignored(filename))
|
||||
return old(m, filename);
|
||||
if (service.options.experimentalEsmLoader) {
|
||||
assertScriptCanLoadAsCJS(filename);
|
||||
}
|
||||
const _compile = m._compile;
|
||||
m._compile = function (code, fileName) {
|
||||
exports.debug('module._compile', fileName);
|
||||
return _compile.call(this, service.compile(code, fileName), fileName);
|
||||
};
|
||||
return old(m, filename);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Do post-processing on config options to support `ts-node`.
|
||||
*/
|
||||
function fixConfig(ts, config) {
|
||||
// Delete options that *should not* be passed through.
|
||||
delete config.options.out;
|
||||
delete config.options.outFile;
|
||||
delete config.options.composite;
|
||||
delete config.options.declarationDir;
|
||||
delete config.options.declarationMap;
|
||||
delete config.options.emitDeclarationOnly;
|
||||
// Target ES5 output by default (instead of ES3).
|
||||
if (config.options.target === undefined) {
|
||||
config.options.target = ts.ScriptTarget.ES5;
|
||||
}
|
||||
// Target CommonJS modules by default (instead of magically switching to ES6 when the target is ES6).
|
||||
if (config.options.module === undefined) {
|
||||
config.options.module = ts.ModuleKind.CommonJS;
|
||||
}
|
||||
return config;
|
||||
}
|
||||
/**
|
||||
* Load TypeScript configuration. Returns the parsed TypeScript config and
|
||||
* any `ts-node` options specified in the config file.
|
||||
*/
|
||||
function readConfig(cwd, ts, rawOptions) {
|
||||
var _a, _b;
|
||||
let config = { compilerOptions: {} };
|
||||
let basePath = cwd;
|
||||
let configFileName = undefined;
|
||||
const { fileExists = ts.sys.fileExists, readFile = ts.sys.readFile, skipProject = exports.DEFAULTS.skipProject, project = exports.DEFAULTS.project } = rawOptions;
|
||||
// Read project configuration when available.
|
||||
if (!skipProject) {
|
||||
configFileName = project
|
||||
? path_1.resolve(cwd, project)
|
||||
: ts.findConfigFile(cwd, fileExists);
|
||||
if (configFileName) {
|
||||
const result = ts.readConfigFile(configFileName, readFile);
|
||||
// Return diagnostics.
|
||||
if (result.error) {
|
||||
return {
|
||||
config: { errors: [result.error], fileNames: [], options: {} },
|
||||
options: {}
|
||||
};
|
||||
}
|
||||
config = result.config;
|
||||
basePath = path_1.dirname(configFileName);
|
||||
}
|
||||
}
|
||||
// Fix ts-node options that come from tsconfig.json
|
||||
const tsconfigOptions = Object.assign({}, config['ts-node']);
|
||||
// Remove resolution of "files".
|
||||
const files = (_b = (_a = rawOptions.files) !== null && _a !== void 0 ? _a : tsconfigOptions.files) !== null && _b !== void 0 ? _b : exports.DEFAULTS.files;
|
||||
if (!files) {
|
||||
config.files = [];
|
||||
config.include = [];
|
||||
}
|
||||
// Override default configuration options `ts-node` requires.
|
||||
config.compilerOptions = Object.assign({}, config.compilerOptions, exports.DEFAULTS.compilerOptions, tsconfigOptions.compilerOptions, rawOptions.compilerOptions, TS_NODE_COMPILER_OPTIONS);
|
||||
const fixedConfig = fixConfig(ts, ts.parseJsonConfigFileContent(config, {
|
||||
fileExists,
|
||||
readFile,
|
||||
readDirectory: ts.sys.readDirectory,
|
||||
useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames
|
||||
}, basePath, undefined, configFileName));
|
||||
if (tsconfigOptions.require) {
|
||||
// Modules are found relative to the tsconfig file, not the `dir` option
|
||||
const tsconfigRelativeRequire = createRequire(configFileName);
|
||||
tsconfigOptions.require = tsconfigOptions.require.map((path) => {
|
||||
return tsconfigRelativeRequire.resolve(path);
|
||||
});
|
||||
}
|
||||
return { config: fixedConfig, options: tsconfigOptions };
|
||||
}
|
||||
/**
|
||||
* Update the output remapping the source map.
|
||||
*/
|
||||
function updateOutput(outputText, fileName, sourceMap, getExtension) {
|
||||
const base64Map = Buffer.from(updateSourceMap(sourceMap, fileName), 'utf8').toString('base64');
|
||||
const sourceMapContent = `data:application/json;charset=utf-8;base64,${base64Map}`;
|
||||
const sourceMapLength = `${path_1.basename(fileName)}.map`.length + (getExtension(fileName).length - path_1.extname(fileName).length);
|
||||
return outputText.slice(0, -sourceMapLength) + sourceMapContent;
|
||||
}
|
||||
/**
|
||||
* Update the source map contents for improved output.
|
||||
*/
|
||||
function updateSourceMap(sourceMapText, fileName) {
|
||||
const sourceMap = JSON.parse(sourceMapText);
|
||||
sourceMap.file = fileName;
|
||||
sourceMap.sources = [fileName];
|
||||
delete sourceMap.sourceRoot;
|
||||
return JSON.stringify(sourceMap);
|
||||
}
|
||||
/**
|
||||
* Filter diagnostics.
|
||||
*/
|
||||
function filterDiagnostics(diagnostics, ignore) {
|
||||
return diagnostics.filter(x => ignore.indexOf(x.code) === -1);
|
||||
}
|
||||
/**
|
||||
* Get token at file position.
|
||||
*
|
||||
* Reference: https://github.com/microsoft/TypeScript/blob/fcd9334f57d85b73dd66ad2d21c02e84822f4841/src/services/utilities.ts#L705-L731
|
||||
*/
|
||||
function getTokenAtPosition(ts, sourceFile, position) {
|
||||
let current = sourceFile;
|
||||
outer: while (true) {
|
||||
for (const child of current.getChildren(sourceFile)) {
|
||||
const start = child.getFullStart();
|
||||
if (start > position)
|
||||
break;
|
||||
const end = child.getEnd();
|
||||
if (position <= end) {
|
||||
current = child;
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
return current;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/ts-node/dist/index.js.map
generated
vendored
Normal file
1
node_modules/ts-node/dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/ts-node/dist/index.spec.d.ts
generated
vendored
Normal file
1
node_modules/ts-node/dist/index.spec.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
817
node_modules/ts-node/dist/index.spec.js
generated
vendored
Normal file
817
node_modules/ts-node/dist/index.spec.js
generated
vendored
Normal file
@ -0,0 +1,817 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const chai_1 = require("chai");
|
||||
const child_process_1 = require("child_process");
|
||||
const path_1 = require("path");
|
||||
const semver = require("semver");
|
||||
const ts = require("typescript");
|
||||
const proxyquire = require("proxyquire");
|
||||
const fs_1 = require("fs");
|
||||
const promisify = require("util.promisify");
|
||||
const rimraf_1 = require("rimraf");
|
||||
const createRequire = require('create-require');
|
||||
const url_1 = require("url");
|
||||
const stream_1 = require("stream");
|
||||
const getStream = require("get-stream");
|
||||
const execP = promisify(child_process_1.exec);
|
||||
const TEST_DIR = path_1.join(__dirname, '../tests');
|
||||
const PROJECT = path_1.join(TEST_DIR, 'tsconfig.json');
|
||||
const BIN_PATH = path_1.join(TEST_DIR, 'node_modules/.bin/ts-node');
|
||||
const BIN_SCRIPT_PATH = path_1.join(TEST_DIR, 'node_modules/.bin/ts-node-script');
|
||||
const SOURCE_MAP_REGEXP = /\/\/# sourceMappingURL=data:application\/json;charset=utf\-8;base64,[\w\+]+=*$/;
|
||||
// `createRequire` does not exist on older node versions
|
||||
const testsDirRequire = createRequire(path_1.join(TEST_DIR, 'index.js')); // tslint:disable-line
|
||||
// Set after ts-node is installed locally
|
||||
let { register, create, VERSION, createRepl } = {};
|
||||
// Pack and install ts-node locally, necessary to test package "exports"
|
||||
before(function () {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
this.timeout(5 * 60e3);
|
||||
rimraf_1.sync(path_1.join(TEST_DIR, 'node_modules'));
|
||||
yield execP(`npm install`, { cwd: TEST_DIR });
|
||||
const packageLockPath = path_1.join(TEST_DIR, 'package-lock.json');
|
||||
fs_1.existsSync(packageLockPath) && fs_1.unlinkSync(packageLockPath);
|
||||
({ register, create, VERSION, createRepl } = testsDirRequire('ts-node'));
|
||||
});
|
||||
});
|
||||
describe('ts-node', function () {
|
||||
const cmd = `"${BIN_PATH}" --project "${PROJECT}"`;
|
||||
const cmdNoProject = `"${BIN_PATH}"`;
|
||||
this.timeout(10000);
|
||||
it('should export the correct version', function () {
|
||||
chai_1.expect(VERSION).to.equal(require('../package.json').version);
|
||||
});
|
||||
it('should export all CJS entrypoints', function () {
|
||||
// Ensure our package.json "exports" declaration allows `require()`ing all our entrypoints
|
||||
// https://github.com/TypeStrong/ts-node/pull/1026
|
||||
testsDirRequire.resolve('ts-node');
|
||||
// only reliably way to ask node for the root path of a dependency is Path.resolve(require.resolve('ts-node/package'), '..')
|
||||
testsDirRequire.resolve('ts-node/package');
|
||||
testsDirRequire.resolve('ts-node/package.json');
|
||||
// All bin entrypoints for people who need to augment our CLI: `node -r otherstuff ./node_modules/ts-node/dist/bin`
|
||||
testsDirRequire.resolve('ts-node/dist/bin');
|
||||
testsDirRequire.resolve('ts-node/dist/bin.js');
|
||||
testsDirRequire.resolve('ts-node/dist/bin-transpile');
|
||||
testsDirRequire.resolve('ts-node/dist/bin-transpile.js');
|
||||
testsDirRequire.resolve('ts-node/dist/bin-script');
|
||||
testsDirRequire.resolve('ts-node/dist/bin-script.js');
|
||||
// Must be `require()`able obviously
|
||||
testsDirRequire.resolve('ts-node/register');
|
||||
testsDirRequire.resolve('ts-node/register/files');
|
||||
testsDirRequire.resolve('ts-node/register/transpile-only');
|
||||
testsDirRequire.resolve('ts-node/register/type-check');
|
||||
// `node --loader ts-node/esm`
|
||||
testsDirRequire.resolve('ts-node/esm');
|
||||
testsDirRequire.resolve('ts-node/esm.mjs');
|
||||
testsDirRequire.resolve('ts-node/esm/transpile-only');
|
||||
testsDirRequire.resolve('ts-node/esm/transpile-only.mjs');
|
||||
});
|
||||
describe('cli', function () {
|
||||
this.slow(1000);
|
||||
it('should execute cli', function (done) {
|
||||
child_process_1.exec(`${cmd} tests/hello-world`, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('Hello, world!\n');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('shows usage via --help', function (done) {
|
||||
child_process_1.exec(`${cmdNoProject} --help`, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.match(/Usage: ts-node /);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('shows version via -v', function (done) {
|
||||
child_process_1.exec(`${cmdNoProject} -v`, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout.trim()).to.equal('v' + testsDirRequire('ts-node/package').version);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('shows version of compiler via -vv', function (done) {
|
||||
child_process_1.exec(`${cmdNoProject} -vv`, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout.trim()).to.equal(`ts-node v${testsDirRequire('ts-node/package').version}\n` +
|
||||
`node ${process.version}\n` +
|
||||
`compiler v${testsDirRequire('typescript/package').version}`);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should register via cli', function (done) {
|
||||
child_process_1.exec(`node -r ts-node/register hello-world.ts`, {
|
||||
cwd: TEST_DIR
|
||||
}, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('Hello, world!\n');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should execute cli with absolute path', function (done) {
|
||||
child_process_1.exec(`${cmd} "${path_1.join(TEST_DIR, 'hello-world')}"`, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('Hello, world!\n');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should print scripts', function (done) {
|
||||
child_process_1.exec(`${cmd} -pe "import { example } from './tests/complex/index';example()"`, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('example\n');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should provide registered information globally', function (done) {
|
||||
child_process_1.exec(`${cmd} tests/env`, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('object\n');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should provide registered information on register', function (done) {
|
||||
child_process_1.exec(`node -r ts-node/register env.ts`, {
|
||||
cwd: TEST_DIR
|
||||
}, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('object\n');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
if (semver.gte(ts.version, '1.8.0')) {
|
||||
it('should allow js', function (done) {
|
||||
child_process_1.exec([
|
||||
cmd,
|
||||
'-O "{\\\"allowJs\\\":true}"',
|
||||
'-pe "import { main } from \'./tests/allow-js/run\';main()"'
|
||||
].join(' '), function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('hello world\n');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should include jsx when `allow-js` true', function (done) {
|
||||
child_process_1.exec([
|
||||
cmd,
|
||||
'-O "{\\\"allowJs\\\":true}"',
|
||||
'-pe "import { Foo2 } from \'./tests/allow-js/with-jsx\'; Foo2.sayHi()"'
|
||||
].join(' '), function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('hello world\n');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
}
|
||||
it('should eval code', function (done) {
|
||||
child_process_1.exec(`${cmd} -e "import * as m from './tests/module';console.log(m.example('test'))"`, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('TEST\n');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should import empty files', function (done) {
|
||||
child_process_1.exec(`${cmd} -e "import './tests/empty'"`, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should throw errors', function (done) {
|
||||
child_process_1.exec(`${cmd} -e "import * as m from './tests/module';console.log(m.example(123))"`, function (err) {
|
||||
if (err === null) {
|
||||
return done('Command was expected to fail, but it succeeded.');
|
||||
}
|
||||
chai_1.expect(err.message).to.match(new RegExp('TS2345: Argument of type \'(?:number|123)\' ' +
|
||||
'is not assignable to parameter of type \'string\'\\.'));
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should be able to ignore diagnostic', function (done) {
|
||||
child_process_1.exec(`${cmd} --ignore-diagnostics 2345 -e "import * as m from './tests/module';console.log(m.example(123))"`, function (err) {
|
||||
if (err === null) {
|
||||
return done('Command was expected to fail, but it succeeded.');
|
||||
}
|
||||
chai_1.expect(err.message).to.match(/TypeError: (?:(?:undefined|foo\.toUpperCase) is not a function|.*has no method \'toUpperCase\')/);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should work with source maps', function (done) {
|
||||
child_process_1.exec(`${cmd} tests/throw`, function (err) {
|
||||
if (err === null) {
|
||||
return done('Command was expected to fail, but it succeeded.');
|
||||
}
|
||||
chai_1.expect(err.message).to.contain([
|
||||
`${path_1.join(__dirname, '../tests/throw.ts')}:100`,
|
||||
' bar () { throw new Error(\'this is a demo\') }',
|
||||
' ^',
|
||||
'Error: this is a demo'
|
||||
].join('\n'));
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('eval should work with source maps', function (done) {
|
||||
child_process_1.exec(`${cmd} -pe "import './tests/throw'"`, function (err) {
|
||||
if (err === null) {
|
||||
return done('Command was expected to fail, but it succeeded.');
|
||||
}
|
||||
chai_1.expect(err.message).to.contain([
|
||||
`${path_1.join(__dirname, '../tests/throw.ts')}:100`,
|
||||
' bar () { throw new Error(\'this is a demo\') }',
|
||||
' ^'
|
||||
].join('\n'));
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should support transpile only mode', function (done) {
|
||||
child_process_1.exec(`${cmd} --transpile-only -pe "x"`, function (err) {
|
||||
if (err === null) {
|
||||
return done('Command was expected to fail, but it succeeded.');
|
||||
}
|
||||
chai_1.expect(err.message).to.contain('ReferenceError: x is not defined');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should throw error even in transpileOnly mode', function (done) {
|
||||
child_process_1.exec(`${cmd} --transpile-only -pe "console."`, function (err) {
|
||||
if (err === null) {
|
||||
return done('Command was expected to fail, but it succeeded.');
|
||||
}
|
||||
chai_1.expect(err.message).to.contain('error TS1003: Identifier expected');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should pipe into `ts-node` and evaluate', function (done) {
|
||||
const cp = child_process_1.exec(cmd, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('hello\n');
|
||||
return done();
|
||||
});
|
||||
cp.stdin.end("console.log('hello')");
|
||||
});
|
||||
it('should pipe into `ts-node`', function (done) {
|
||||
const cp = child_process_1.exec(`${cmd} -p`, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('true\n');
|
||||
return done();
|
||||
});
|
||||
cp.stdin.end('true');
|
||||
});
|
||||
it('should pipe into an eval script', function (done) {
|
||||
const cp = child_process_1.exec(`${cmd} --transpile-only -pe "process.stdin.isTTY"`, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('undefined\n');
|
||||
return done();
|
||||
});
|
||||
cp.stdin.end('true');
|
||||
});
|
||||
it('should run REPL when --interactive passed and stdin is not a TTY', function (done) {
|
||||
const cp = child_process_1.exec(`${cmd} --interactive`, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('> 123\n' +
|
||||
'undefined\n' +
|
||||
'> ');
|
||||
return done();
|
||||
});
|
||||
cp.stdin.end('console.log("123")\n');
|
||||
});
|
||||
it('REPL has command to get type information', function (done) {
|
||||
const cp = child_process_1.exec(`${cmd} --interactive`, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('> undefined\n' +
|
||||
'> undefined\n' +
|
||||
'> const a: 123\n' +
|
||||
'> ');
|
||||
return done();
|
||||
});
|
||||
cp.stdin.end('\nconst a = 123\n.type a');
|
||||
});
|
||||
it('REPL can be created via API', () => __awaiter(this, void 0, void 0, function* () {
|
||||
const stdin = new stream_1.PassThrough();
|
||||
const stdout = new stream_1.PassThrough();
|
||||
const stderr = new stream_1.PassThrough();
|
||||
const replService = createRepl({
|
||||
stdin,
|
||||
stdout,
|
||||
stderr
|
||||
});
|
||||
const service = create(replService.evalAwarePartialHost);
|
||||
replService.setService(service);
|
||||
replService.start();
|
||||
stdin.write('\nconst a = 123\n.type a\n');
|
||||
stdin.end();
|
||||
yield promisify(setTimeout)(1e3);
|
||||
stdout.end();
|
||||
stderr.end();
|
||||
chai_1.expect(yield getStream(stderr)).to.equal('');
|
||||
chai_1.expect(yield getStream(stdout)).to.equal('> \'use strict\'\n' +
|
||||
'> undefined\n' +
|
||||
'> const a: 123\n' +
|
||||
'> ');
|
||||
}));
|
||||
it('should support require flags', function (done) {
|
||||
child_process_1.exec(`${cmd} -r ./tests/hello-world -pe "console.log('success')"`, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('Hello, world!\nsuccess\nundefined\n');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should support require from node modules', function (done) {
|
||||
child_process_1.exec(`${cmd} -r typescript -e "console.log('success')"`, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('success\n');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should use source maps with react tsx', function (done) {
|
||||
child_process_1.exec(`${cmd} tests/throw-react-tsx.tsx`, function (err, stdout) {
|
||||
chai_1.expect(err).not.to.equal(null);
|
||||
chai_1.expect(err.message).to.contain([
|
||||
`${path_1.join(__dirname, '../tests/throw-react-tsx.tsx')}:100`,
|
||||
' bar () { throw new Error(\'this is a demo\') }',
|
||||
' ^',
|
||||
'Error: this is a demo'
|
||||
].join('\n'));
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should allow custom typings', function (done) {
|
||||
child_process_1.exec(`${cmd} tests/custom-types`, function (err, stdout) {
|
||||
chai_1.expect(err).to.match(/Error: Cannot find module 'does-not-exist'/);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should preserve `ts-node` context with child process', function (done) {
|
||||
child_process_1.exec(`${cmd} tests/child-process`, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('Hello, world!\n');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should import js before ts by default', function (done) {
|
||||
child_process_1.exec(`${cmd} tests/import-order/compiled`, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('Hello, JavaScript!\n');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should import ts before js when --prefer-ts-exts flag is present', function (done) {
|
||||
child_process_1.exec(`${cmd} --prefer-ts-exts tests/import-order/compiled`, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('Hello, TypeScript!\n');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should import ts before js when TS_NODE_PREFER_TS_EXTS env is present', function (done) {
|
||||
child_process_1.exec(`${cmd} tests/import-order/compiled`, { env: Object.assign(Object.assign({}, process.env), { TS_NODE_PREFER_TS_EXTS: 'true' }) }, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('Hello, TypeScript!\n');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should ignore .d.ts files', function (done) {
|
||||
child_process_1.exec(`${cmd} tests/import-order/importer`, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('Hello, World!\n');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
describe('issue #884', function () {
|
||||
it('should compile', function (done) {
|
||||
// TODO disabled because it consistently fails on Windows on TS 2.7
|
||||
if (process.platform === 'win32' && semver.satisfies(ts.version, '2.7')) {
|
||||
this.skip();
|
||||
}
|
||||
else {
|
||||
child_process_1.exec(`"${BIN_PATH}" --project tests/issue-884/tsconfig.json tests/issue-884`, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('');
|
||||
return done();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
describe('issue #986', function () {
|
||||
it('should not compile', function (done) {
|
||||
child_process_1.exec(`"${BIN_PATH}" --project tests/issue-986/tsconfig.json tests/issue-986`, function (err, stdout, stderr) {
|
||||
chai_1.expect(err).not.to.equal(null);
|
||||
chai_1.expect(stderr).to.contain('Cannot find name \'TEST\''); // TypeScript error.
|
||||
chai_1.expect(stdout).to.equal('');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should compile with `--files`', function (done) {
|
||||
child_process_1.exec(`"${BIN_PATH}" --files --project tests/issue-986/tsconfig.json tests/issue-986`, function (err, stdout, stderr) {
|
||||
chai_1.expect(err).not.to.equal(null);
|
||||
chai_1.expect(stderr).to.contain('ReferenceError: TEST is not defined'); // Runtime error.
|
||||
chai_1.expect(stdout).to.equal('');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
});
|
||||
if (semver.gte(ts.version, '2.7.0')) {
|
||||
it('should support script mode', function (done) {
|
||||
child_process_1.exec(`${BIN_SCRIPT_PATH} tests/scope/a/log`, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('.ts\n');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should read tsconfig relative to realpath, not symlink, in scriptMode', function (done) {
|
||||
if (fs_1.lstatSync(path_1.join(TEST_DIR, 'main-realpath/symlink/symlink.tsx')).isSymbolicLink()) {
|
||||
child_process_1.exec(`${BIN_SCRIPT_PATH} tests/main-realpath/symlink/symlink.tsx`, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('');
|
||||
return done();
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.skip();
|
||||
}
|
||||
});
|
||||
}
|
||||
describe('should read ts-node options from tsconfig.json', function () {
|
||||
const BIN_EXEC = `"${BIN_PATH}" --project tests/tsconfig-options/tsconfig.json`;
|
||||
it('should override compiler options from env', function (done) {
|
||||
child_process_1.exec(`${BIN_EXEC} tests/tsconfig-options/log-options1.js`, {
|
||||
env: Object.assign(Object.assign({}, process.env), { TS_NODE_COMPILER_OPTIONS: '{"typeRoots": ["env-typeroots"]}' })
|
||||
}, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
const { config } = JSON.parse(stdout);
|
||||
chai_1.expect(config.options.typeRoots).to.deep.equal([path_1.join(__dirname, '../tests/tsconfig-options/env-typeroots').replace(/\\/g, '/')]);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should use options from `tsconfig.json`', function (done) {
|
||||
child_process_1.exec(`${BIN_EXEC} tests/tsconfig-options/log-options1.js`, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
const { options, config } = JSON.parse(stdout);
|
||||
chai_1.expect(config.options.typeRoots).to.deep.equal([path_1.join(__dirname, '../tests/tsconfig-options/tsconfig-typeroots').replace(/\\/g, '/')]);
|
||||
chai_1.expect(config.options.types).to.deep.equal(['tsconfig-tsnode-types']);
|
||||
chai_1.expect(options.pretty).to.equal(undefined);
|
||||
chai_1.expect(options.skipIgnore).to.equal(false);
|
||||
chai_1.expect(options.transpileOnly).to.equal(true);
|
||||
chai_1.expect(options.require).to.deep.equal([path_1.join(__dirname, '../tests/tsconfig-options/required1.js')]);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should have flags override / merge with `tsconfig.json`', function (done) {
|
||||
child_process_1.exec(`${BIN_EXEC} --skip-ignore --compiler-options "{\\"types\\":[\\"flags-types\\"]}" --require ./tests/tsconfig-options/required2.js tests/tsconfig-options/log-options2.js`, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
const { options, config } = JSON.parse(stdout);
|
||||
chai_1.expect(config.options.typeRoots).to.deep.equal([path_1.join(__dirname, '../tests/tsconfig-options/tsconfig-typeroots').replace(/\\/g, '/')]);
|
||||
chai_1.expect(config.options.types).to.deep.equal(['flags-types']);
|
||||
chai_1.expect(options.pretty).to.equal(undefined);
|
||||
chai_1.expect(options.skipIgnore).to.equal(true);
|
||||
chai_1.expect(options.transpileOnly).to.equal(true);
|
||||
chai_1.expect(options.require).to.deep.equal([
|
||||
path_1.join(__dirname, '../tests/tsconfig-options/required1.js'),
|
||||
'./tests/tsconfig-options/required2.js'
|
||||
]);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should have `tsconfig.json` override environment', function (done) {
|
||||
child_process_1.exec(`${BIN_EXEC} tests/tsconfig-options/log-options1.js`, {
|
||||
env: Object.assign(Object.assign({}, process.env), { TS_NODE_PRETTY: 'true', TS_NODE_SKIP_IGNORE: 'true' })
|
||||
}, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
const { options, config } = JSON.parse(stdout);
|
||||
chai_1.expect(config.options.typeRoots).to.deep.equal([path_1.join(__dirname, '../tests/tsconfig-options/tsconfig-typeroots').replace(/\\/g, '/')]);
|
||||
chai_1.expect(config.options.types).to.deep.equal(['tsconfig-tsnode-types']);
|
||||
chai_1.expect(options.pretty).to.equal(true);
|
||||
chai_1.expect(options.skipIgnore).to.equal(false);
|
||||
chai_1.expect(options.transpileOnly).to.equal(true);
|
||||
chai_1.expect(options.require).to.deep.equal([path_1.join(__dirname, '../tests/tsconfig-options/required1.js')]);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('compiler host', function () {
|
||||
it('should execute cli', function (done) {
|
||||
child_process_1.exec(`${cmd} --compiler-host tests/hello-world`, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('Hello, world!\n');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
});
|
||||
it('should transpile files inside a node_modules directory when not ignored', function (done) {
|
||||
child_process_1.exec(`${cmdNoProject} --script-mode tests/from-node-modules/from-node-modules`, function (err, stdout, stderr) {
|
||||
if (err)
|
||||
return done(`Unexpected error: ${err}\nstdout:\n${stdout}\nstderr:\n${stderr}`);
|
||||
chai_1.expect(JSON.parse(stdout)).to.deep.equal({
|
||||
external: {
|
||||
tsmri: { name: 'typescript-module-required-internally' },
|
||||
jsmri: { name: 'javascript-module-required-internally' },
|
||||
tsmii: { name: 'typescript-module-imported-internally' },
|
||||
jsmii: { name: 'javascript-module-imported-internally' }
|
||||
},
|
||||
tsmie: { name: 'typescript-module-imported-externally' },
|
||||
jsmie: { name: 'javascript-module-imported-externally' },
|
||||
tsmre: { name: 'typescript-module-required-externally' },
|
||||
jsmre: { name: 'javascript-module-required-externally' }
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
describe('should respect maxNodeModulesJsDepth', function () {
|
||||
it('for unscoped modules', function (done) {
|
||||
child_process_1.exec(`${cmdNoProject} --script-mode tests/maxnodemodulesjsdepth`, function (err, stdout, stderr) {
|
||||
chai_1.expect(err).to.not.equal(null);
|
||||
chai_1.expect(stderr.replace(/\r\n/g, '\n')).to.contain('TSError: ⨯ Unable to compile TypeScript:\n' +
|
||||
"other.ts(4,7): error TS2322: Type 'string' is not assignable to type 'boolean'.\n" +
|
||||
'\n');
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('for @scoped modules', function (done) {
|
||||
child_process_1.exec(`${cmdNoProject} --script-mode tests/maxnodemodulesjsdepth-scoped`, function (err, stdout, stderr) {
|
||||
chai_1.expect(err).to.not.equal(null);
|
||||
chai_1.expect(stderr.replace(/\r\n/g, '\n')).to.contain('TSError: ⨯ Unable to compile TypeScript:\n' +
|
||||
"other.ts(7,7): error TS2322: Type 'string' is not assignable to type 'boolean'.\n" +
|
||||
'\n');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('register', function () {
|
||||
let registered;
|
||||
let moduleTestPath;
|
||||
before(() => {
|
||||
registered = register({
|
||||
project: PROJECT,
|
||||
compilerOptions: {
|
||||
jsx: 'preserve'
|
||||
}
|
||||
});
|
||||
moduleTestPath = require.resolve('../tests/module');
|
||||
});
|
||||
afterEach(() => {
|
||||
// Re-enable project after every test.
|
||||
registered.enabled(true);
|
||||
});
|
||||
it('should be able to require typescript', function () {
|
||||
const m = require(moduleTestPath);
|
||||
chai_1.expect(m.example('foo')).to.equal('FOO');
|
||||
});
|
||||
it('should support dynamically disabling', function () {
|
||||
delete require.cache[moduleTestPath];
|
||||
chai_1.expect(registered.enabled(false)).to.equal(false);
|
||||
chai_1.expect(() => require(moduleTestPath)).to.throw(/Unexpected token/);
|
||||
delete require.cache[moduleTestPath];
|
||||
chai_1.expect(registered.enabled()).to.equal(false);
|
||||
chai_1.expect(() => require(moduleTestPath)).to.throw(/Unexpected token/);
|
||||
delete require.cache[moduleTestPath];
|
||||
chai_1.expect(registered.enabled(true)).to.equal(true);
|
||||
chai_1.expect(() => require(moduleTestPath)).to.not.throw();
|
||||
delete require.cache[moduleTestPath];
|
||||
chai_1.expect(registered.enabled()).to.equal(true);
|
||||
chai_1.expect(() => require(moduleTestPath)).to.not.throw();
|
||||
});
|
||||
if (semver.gte(ts.version, '2.7.0')) {
|
||||
it('should support compiler scopes', function () {
|
||||
const calls = [];
|
||||
registered.enabled(false);
|
||||
const compilers = [
|
||||
register({ dir: path_1.join(TEST_DIR, 'scope/a'), scope: true }),
|
||||
register({ dir: path_1.join(TEST_DIR, 'scope/b'), scope: true })
|
||||
];
|
||||
compilers.forEach(c => {
|
||||
const old = c.compile;
|
||||
c.compile = (code, fileName, lineOffset) => {
|
||||
calls.push(fileName);
|
||||
return old(code, fileName, lineOffset);
|
||||
};
|
||||
});
|
||||
try {
|
||||
chai_1.expect(require('../tests/scope/a').ext).to.equal('.ts');
|
||||
chai_1.expect(require('../tests/scope/b').ext).to.equal('.ts');
|
||||
}
|
||||
finally {
|
||||
compilers.forEach(c => c.enabled(false));
|
||||
}
|
||||
chai_1.expect(calls).to.deep.equal([
|
||||
path_1.join(TEST_DIR, 'scope/a/index.ts'),
|
||||
path_1.join(TEST_DIR, 'scope/b/index.ts')
|
||||
]);
|
||||
delete require.cache[moduleTestPath];
|
||||
chai_1.expect(() => require(moduleTestPath)).to.throw();
|
||||
});
|
||||
}
|
||||
it('should compile through js and ts', function () {
|
||||
const m = require('../tests/complex');
|
||||
chai_1.expect(m.example()).to.equal('example');
|
||||
});
|
||||
it('should work with proxyquire', function () {
|
||||
const m = proxyquire('../tests/complex', {
|
||||
'./example': 'hello'
|
||||
});
|
||||
chai_1.expect(m.example()).to.equal('hello');
|
||||
});
|
||||
it('should work with `require.cache`', function () {
|
||||
const { example1, example2 } = require('../tests/require-cache');
|
||||
chai_1.expect(example1).to.not.equal(example2);
|
||||
});
|
||||
it('should use source maps', function (done) {
|
||||
try {
|
||||
require('../tests/throw');
|
||||
}
|
||||
catch (error) {
|
||||
chai_1.expect(error.stack).to.contain([
|
||||
'Error: this is a demo',
|
||||
` at Foo.bar (${path_1.join(__dirname, '../tests/throw.ts')}:100:18)`
|
||||
].join('\n'));
|
||||
done();
|
||||
}
|
||||
});
|
||||
describe('JSX preserve', () => {
|
||||
let old;
|
||||
let compiled;
|
||||
before(function () {
|
||||
old = require.extensions['.tsx']; // tslint:disable-line
|
||||
require.extensions['.tsx'] = (m, fileName) => {
|
||||
const _compile = m._compile;
|
||||
m._compile = (code, fileName) => {
|
||||
compiled = code;
|
||||
return _compile.call(this, code, fileName);
|
||||
};
|
||||
return old(m, fileName);
|
||||
};
|
||||
});
|
||||
after(function () {
|
||||
require.extensions['.tsx'] = old; // tslint:disable-line
|
||||
});
|
||||
it('should use source maps', function (done) {
|
||||
try {
|
||||
require('../tests/with-jsx.tsx');
|
||||
}
|
||||
catch (error) {
|
||||
chai_1.expect(error.stack).to.contain('SyntaxError: Unexpected token');
|
||||
}
|
||||
chai_1.expect(compiled).to.match(SOURCE_MAP_REGEXP);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('create', () => {
|
||||
let service;
|
||||
before(() => {
|
||||
service = create({ compilerOptions: { target: 'es5' }, skipProject: true });
|
||||
});
|
||||
it('should create generic compiler instances', () => {
|
||||
const output = service.compile('const x = 10', 'test.ts');
|
||||
chai_1.expect(output).to.contain('var x = 10;');
|
||||
});
|
||||
describe('should get type information', () => {
|
||||
it('given position of identifier', () => {
|
||||
chai_1.expect(service.getTypeInfo('/**jsdoc here*/const x = 10', 'test.ts', 21)).to.deep.equal({
|
||||
comment: 'jsdoc here',
|
||||
name: 'const x: 10'
|
||||
});
|
||||
});
|
||||
it('given position that does not point to an identifier', () => {
|
||||
chai_1.expect(service.getTypeInfo('/**jsdoc here*/const x = 10', 'test.ts', 0)).to.deep.equal({
|
||||
comment: '',
|
||||
name: ''
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('issue #1098', () => {
|
||||
function testIgnored(ignored, allowed, disallowed) {
|
||||
for (const ext of allowed) {
|
||||
chai_1.expect(ignored(path_1.join(__dirname, `index${ext}`))).equal(false, `should accept ${ext} files`);
|
||||
}
|
||||
for (const ext of disallowed) {
|
||||
chai_1.expect(ignored(path_1.join(__dirname, `index${ext}`))).equal(true, `should ignore ${ext} files`);
|
||||
}
|
||||
}
|
||||
it('correctly filters file extensions from the compiler when allowJs=false and jsx=false', () => {
|
||||
const { ignored } = create({ compilerOptions: {}, skipProject: true });
|
||||
testIgnored(ignored, ['.ts', '.d.ts'], ['.js', '.tsx', '.jsx', '.mjs', '.cjs', '.xyz', '']);
|
||||
});
|
||||
it('correctly filters file extensions from the compiler when allowJs=true and jsx=false', () => {
|
||||
const { ignored } = create({ compilerOptions: { allowJs: true }, skipProject: true });
|
||||
testIgnored(ignored, ['.ts', '.js', '.d.ts'], ['.tsx', '.jsx', '.mjs', '.cjs', '.xyz', '']);
|
||||
});
|
||||
it('correctly filters file extensions from the compiler when allowJs=false and jsx=true', () => {
|
||||
const { ignored } = create({ compilerOptions: { allowJs: false, jsx: 'preserve' }, skipProject: true });
|
||||
testIgnored(ignored, ['.ts', '.tsx', '.d.ts'], ['.js', '.jsx', '.mjs', '.cjs', '.xyz', '']);
|
||||
});
|
||||
it('correctly filters file extensions from the compiler when allowJs=true and jsx=true', () => {
|
||||
const { ignored } = create({ compilerOptions: { allowJs: true, jsx: 'preserve' }, skipProject: true });
|
||||
testIgnored(ignored, ['.ts', '.tsx', '.js', '.jsx', '.d.ts'], ['.mjs', '.cjs', '.xyz', '']);
|
||||
});
|
||||
});
|
||||
describe('esm', () => {
|
||||
this.slow(1000);
|
||||
const cmd = `node --loader ts-node/esm`;
|
||||
if (semver.gte(process.version, '13.0.0')) {
|
||||
it('should compile and execute as ESM', (done) => {
|
||||
child_process_1.exec(`${cmd} index.ts`, { cwd: path_1.join(__dirname, '../tests/esm') }, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('foo bar baz biff libfoo\n');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should use source maps', function (done) {
|
||||
child_process_1.exec(`${cmd} throw.ts`, { cwd: path_1.join(__dirname, '../tests/esm') }, function (err, stdout) {
|
||||
chai_1.expect(err).not.to.equal(null);
|
||||
chai_1.expect(err.message).to.contain([
|
||||
`${url_1.pathToFileURL(path_1.join(__dirname, '../tests/esm/throw.ts'))}:100`,
|
||||
' bar () { throw new Error(\'this is a demo\') }',
|
||||
' ^',
|
||||
'Error: this is a demo'
|
||||
].join('\n'));
|
||||
return done();
|
||||
});
|
||||
});
|
||||
describe('supports experimental-specifier-resolution=node', () => {
|
||||
it('via --experimental-specifier-resolution', (done) => {
|
||||
child_process_1.exec(`${cmd} --experimental-specifier-resolution=node index.ts`, { cwd: path_1.join(__dirname, '../tests/esm-node-resolver') }, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('foo bar baz biff libfoo\n');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('via --es-module-specifier-resolution alias', (done) => {
|
||||
child_process_1.exec(`${cmd} --experimental-modules --es-module-specifier-resolution=node index.ts`, { cwd: path_1.join(__dirname, '../tests/esm-node-resolver') }, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('foo bar baz biff libfoo\n');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('via NODE_OPTIONS', (done) => {
|
||||
child_process_1.exec(`${cmd} index.ts`, {
|
||||
cwd: path_1.join(__dirname, '../tests/esm-node-resolver'),
|
||||
env: Object.assign(Object.assign({}, process.env), { NODE_OPTIONS: '--experimental-specifier-resolution=node' })
|
||||
}, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('foo bar baz biff libfoo\n');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
});
|
||||
it('throws ERR_REQUIRE_ESM when attempting to require() an ESM script while ESM loader is enabled', function (done) {
|
||||
child_process_1.exec(`${cmd} ./index.js`, { cwd: path_1.join(__dirname, '../tests/esm-err-require-esm') }, function (err, stdout, stderr) {
|
||||
chai_1.expect(err).to.not.equal(null);
|
||||
chai_1.expect(stderr).to.contain('Error [ERR_REQUIRE_ESM]: Must use import to load ES Module:');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('defers to fallback loaders when URL should not be handled by ts-node', function (done) {
|
||||
child_process_1.exec(`${cmd} index.mjs`, {
|
||||
cwd: path_1.join(__dirname, '../tests/esm-import-http-url')
|
||||
}, function (err, stdout, stderr) {
|
||||
chai_1.expect(err).to.not.equal(null);
|
||||
// expect error from node's default resolver
|
||||
chai_1.expect(stderr).to.match(/Error \[ERR_UNSUPPORTED_ESM_URL_SCHEME\]:.*(?:\n.*){0,1}\n *at defaultResolve/);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should bypass import cache when changing search params', (done) => {
|
||||
child_process_1.exec(`${cmd} index.ts`, { cwd: path_1.join(__dirname, '../tests/esm-import-cache') }, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('log1\nlog2\nlog2\n');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should support transpile only mode via dedicated loader entrypoint', (done) => {
|
||||
child_process_1.exec(`${cmd}/transpile-only index.ts`, { cwd: path_1.join(__dirname, '../tests/esm-transpile-only') }, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('should throw type errors without transpile-only enabled', (done) => {
|
||||
child_process_1.exec(`${cmd} index.ts`, { cwd: path_1.join(__dirname, '../tests/esm-transpile-only') }, function (err, stdout) {
|
||||
if (err === null) {
|
||||
return done('Command was expected to fail, but it succeeded.');
|
||||
}
|
||||
chai_1.expect(err.message).to.contain('Unable to compile TypeScript');
|
||||
chai_1.expect(err.message).to.match(new RegExp('TS2345: Argument of type \'(?:number|1101)\' is not assignable to parameter of type \'string\'\\.'));
|
||||
chai_1.expect(err.message).to.match(new RegExp('TS2322: Type \'(?:"hello world"|string)\' is not assignable to type \'number\'\\.'));
|
||||
chai_1.expect(stdout).to.equal('');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
}
|
||||
it('executes ESM as CJS, ignoring package.json "types" field (for backwards compatibility; should be changed in next major release to throw ERR_REQUIRE_ESM)', function (done) {
|
||||
child_process_1.exec(`${BIN_PATH} ./tests/esm-err-require-esm/index.js`, function (err, stdout) {
|
||||
chai_1.expect(err).to.equal(null);
|
||||
chai_1.expect(stdout).to.equal('CommonJS\n');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=index.spec.js.map
|
1
node_modules/ts-node/dist/index.spec.js.map
generated
vendored
Normal file
1
node_modules/ts-node/dist/index.spec.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
39
node_modules/ts-node/dist/repl.d.ts
generated
vendored
Normal file
39
node_modules/ts-node/dist/repl.d.ts
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
/// <reference types="node" />
|
||||
import { Service, CreateOptions } from './index';
|
||||
export interface ReplService {
|
||||
readonly state: EvalState;
|
||||
/**
|
||||
* Bind this REPL to a ts-node compiler service. A compiler service must be bound before `eval`-ing code or starting the REPL
|
||||
*/
|
||||
setService(service: Service): void;
|
||||
evalCode(code: string): void;
|
||||
/**
|
||||
* `eval` implementation compatible with node's REPL API
|
||||
*/
|
||||
nodeEval(code: string, _context: any, _filename: string, callback: (err: Error | null, result?: any) => any): void;
|
||||
evalAwarePartialHost: EvalAwarePartialHost;
|
||||
/** Start a node REPL */
|
||||
start(code?: string): void;
|
||||
}
|
||||
export interface CreateReplOptions {
|
||||
service?: Service;
|
||||
state?: EvalState;
|
||||
stdin?: NodeJS.ReadableStream;
|
||||
stdout?: NodeJS.WritableStream;
|
||||
stderr?: NodeJS.WritableStream;
|
||||
}
|
||||
export declare function createRepl(options?: CreateReplOptions): ReplService;
|
||||
/**
|
||||
* Eval state management. Stores virtual `[eval].ts` file
|
||||
*/
|
||||
export declare class EvalState {
|
||||
path: string;
|
||||
__tsNodeEvalStateBrand: unknown;
|
||||
constructor(path: string);
|
||||
}
|
||||
/**
|
||||
* Filesystem host functions which are aware of the "virtual" [eval].ts file used to compile REPL inputs.
|
||||
* Must be passed to `create()` to create a ts-node compiler service which can compile REPL inputs.
|
||||
*/
|
||||
export declare type EvalAwarePartialHost = Pick<CreateOptions, 'readFile' | 'fileExists'>;
|
||||
export declare function createEvalAwarePartialHost(state: EvalState): EvalAwarePartialHost;
|
261
node_modules/ts-node/dist/repl.js
generated
vendored
Normal file
261
node_modules/ts-node/dist/repl.js
generated
vendored
Normal file
@ -0,0 +1,261 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createEvalAwarePartialHost = exports.EvalState = exports.createRepl = exports.EVAL_FILENAME = void 0;
|
||||
const diff_1 = require("diff");
|
||||
const os_1 = require("os");
|
||||
const path_1 = require("path");
|
||||
const repl_1 = require("repl");
|
||||
const vm_1 = require("vm");
|
||||
const index_1 = require("./index");
|
||||
const fs_1 = require("fs");
|
||||
const console_1 = require("console");
|
||||
/**
|
||||
* Eval filename for REPL/debug.
|
||||
* @internal
|
||||
*/
|
||||
exports.EVAL_FILENAME = `[eval].ts`;
|
||||
function createRepl(options = {}) {
|
||||
var _a, _b, _c, _d, _e;
|
||||
let service = options.service;
|
||||
const state = (_a = options.state) !== null && _a !== void 0 ? _a : new EvalState(path_1.join(process.cwd(), exports.EVAL_FILENAME));
|
||||
const evalAwarePartialHost = createEvalAwarePartialHost(state);
|
||||
const stdin = (_b = options.stdin) !== null && _b !== void 0 ? _b : process.stdin;
|
||||
const stdout = (_c = options.stdout) !== null && _c !== void 0 ? _c : process.stdout;
|
||||
const stderr = (_d = options.stderr) !== null && _d !== void 0 ? _d : process.stderr;
|
||||
const _console = stdout === process.stdout && stderr === process.stderr ? console : new console_1.Console(stdout, stderr);
|
||||
const replService = {
|
||||
state: (_e = options.state) !== null && _e !== void 0 ? _e : new EvalState(path_1.join(process.cwd(), exports.EVAL_FILENAME)),
|
||||
setService,
|
||||
evalCode,
|
||||
nodeEval,
|
||||
evalAwarePartialHost,
|
||||
start,
|
||||
stdin,
|
||||
stdout,
|
||||
stderr,
|
||||
console: _console
|
||||
};
|
||||
return replService;
|
||||
function setService(_service) {
|
||||
service = _service;
|
||||
}
|
||||
function evalCode(code) {
|
||||
return _eval(service, state, code);
|
||||
}
|
||||
function nodeEval(code, _context, _filename, callback) {
|
||||
let err = null;
|
||||
let result;
|
||||
// TODO: Figure out how to handle completion here.
|
||||
if (code === '.scope') {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
result = evalCode(code);
|
||||
}
|
||||
catch (error) {
|
||||
if (error instanceof index_1.TSError) {
|
||||
// Support recoverable compilations using >= node 6.
|
||||
if (repl_1.Recoverable && isRecoverable(error)) {
|
||||
err = new repl_1.Recoverable(error);
|
||||
}
|
||||
else {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
else {
|
||||
err = error;
|
||||
}
|
||||
}
|
||||
return callback(err, result);
|
||||
}
|
||||
function start(code) {
|
||||
// TODO assert that service is set; remove all ! postfixes
|
||||
return startRepl(replService, service, state, code);
|
||||
}
|
||||
}
|
||||
exports.createRepl = createRepl;
|
||||
/**
|
||||
* Eval state management. Stores virtual `[eval].ts` file
|
||||
*/
|
||||
class EvalState {
|
||||
constructor(path) {
|
||||
this.path = path;
|
||||
/** @internal */
|
||||
this.input = '';
|
||||
/** @internal */
|
||||
this.output = '';
|
||||
/** @internal */
|
||||
this.version = 0;
|
||||
/** @internal */
|
||||
this.lines = 0;
|
||||
}
|
||||
}
|
||||
exports.EvalState = EvalState;
|
||||
function createEvalAwarePartialHost(state) {
|
||||
function readFile(path) {
|
||||
if (path === state.path)
|
||||
return state.input;
|
||||
try {
|
||||
return fs_1.readFileSync(path, 'utf8');
|
||||
}
|
||||
catch (err) { /* Ignore. */ }
|
||||
}
|
||||
function fileExists(path) {
|
||||
if (path === state.path)
|
||||
return true;
|
||||
try {
|
||||
const stats = fs_1.statSync(path);
|
||||
return stats.isFile() || stats.isFIFO();
|
||||
}
|
||||
catch (err) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return { readFile, fileExists };
|
||||
}
|
||||
exports.createEvalAwarePartialHost = createEvalAwarePartialHost;
|
||||
/**
|
||||
* Evaluate the code snippet.
|
||||
*/
|
||||
function _eval(service, state, input) {
|
||||
const lines = state.lines;
|
||||
const isCompletion = !/\n$/.test(input);
|
||||
const undo = appendEval(state, input);
|
||||
let output;
|
||||
try {
|
||||
output = service.compile(state.input, state.path, -lines);
|
||||
}
|
||||
catch (err) {
|
||||
undo();
|
||||
throw err;
|
||||
}
|
||||
// Use `diff` to check for new JavaScript to execute.
|
||||
const changes = diff_1.diffLines(state.output, output);
|
||||
if (isCompletion) {
|
||||
undo();
|
||||
}
|
||||
else {
|
||||
state.output = output;
|
||||
}
|
||||
return changes.reduce((result, change) => {
|
||||
return change.added ? exec(change.value, state.path) : result;
|
||||
}, undefined);
|
||||
}
|
||||
/**
|
||||
* Execute some code.
|
||||
*/
|
||||
function exec(code, filename) {
|
||||
const script = new vm_1.Script(code, { filename: filename });
|
||||
return script.runInThisContext();
|
||||
}
|
||||
/**
|
||||
* Start a CLI REPL.
|
||||
*/
|
||||
function startRepl(replService, service, state, code) {
|
||||
// Eval incoming code before the REPL starts.
|
||||
if (code) {
|
||||
try {
|
||||
replService.evalCode(`${code}\n`);
|
||||
}
|
||||
catch (err) {
|
||||
replService.console.error(err);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
const repl = repl_1.start({
|
||||
prompt: '> ',
|
||||
input: replService.stdin,
|
||||
output: replService.stdout,
|
||||
// Mimicking node's REPL implementation: https://github.com/nodejs/node/blob/168b22ba073ee1cbf8d0bcb4ded7ff3099335d04/lib/internal/repl.js#L28-L30
|
||||
terminal: replService.stdout.isTTY && !parseInt(process.env.NODE_NO_READLINE, 10),
|
||||
eval: replService.nodeEval,
|
||||
useGlobal: true
|
||||
});
|
||||
// Bookmark the point where we should reset the REPL state.
|
||||
const resetEval = appendEval(state, '');
|
||||
function reset() {
|
||||
resetEval();
|
||||
// Hard fix for TypeScript forcing `Object.defineProperty(exports, ...)`.
|
||||
exec('exports = module.exports', state.path);
|
||||
}
|
||||
reset();
|
||||
repl.on('reset', reset);
|
||||
repl.defineCommand('type', {
|
||||
help: 'Check the type of a TypeScript identifier',
|
||||
action: function (identifier) {
|
||||
if (!identifier) {
|
||||
repl.displayPrompt();
|
||||
return;
|
||||
}
|
||||
const undo = appendEval(state, identifier);
|
||||
const { name, comment } = service.getTypeInfo(state.input, state.path, state.input.length);
|
||||
undo();
|
||||
if (name)
|
||||
repl.outputStream.write(`${name}\n`);
|
||||
if (comment)
|
||||
repl.outputStream.write(`${comment}\n`);
|
||||
repl.displayPrompt();
|
||||
}
|
||||
});
|
||||
// Set up REPL history when available natively via node.js >= 11.
|
||||
if (repl.setupHistory) {
|
||||
const historyPath = process.env.TS_NODE_HISTORY || path_1.join(os_1.homedir(), '.ts_node_repl_history');
|
||||
repl.setupHistory(historyPath, err => {
|
||||
if (!err)
|
||||
return;
|
||||
replService.console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Append to the eval instance and return an undo function.
|
||||
*/
|
||||
function appendEval(state, input) {
|
||||
const undoInput = state.input;
|
||||
const undoVersion = state.version;
|
||||
const undoOutput = state.output;
|
||||
const undoLines = state.lines;
|
||||
// Handle ASI issues with TypeScript re-evaluation.
|
||||
if (undoInput.charAt(undoInput.length - 1) === '\n' && /^\s*[\/\[(`-]/.test(input) && !/;\s*$/.test(undoInput)) {
|
||||
state.input = `${state.input.slice(0, -1)};\n`;
|
||||
}
|
||||
state.input += input;
|
||||
state.lines += lineCount(input);
|
||||
state.version++;
|
||||
return function () {
|
||||
state.input = undoInput;
|
||||
state.output = undoOutput;
|
||||
state.version = undoVersion;
|
||||
state.lines = undoLines;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Count the number of lines.
|
||||
*/
|
||||
function lineCount(value) {
|
||||
let count = 0;
|
||||
for (const char of value) {
|
||||
if (char === '\n') {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
const RECOVERY_CODES = new Set([
|
||||
1003,
|
||||
1005,
|
||||
1109,
|
||||
1126,
|
||||
1160,
|
||||
1161,
|
||||
2355 // "A function whose declared type is neither 'void' nor 'any' must return a value."
|
||||
]);
|
||||
/**
|
||||
* Check if a function can recover gracefully.
|
||||
*/
|
||||
function isRecoverable(error) {
|
||||
return error.diagnosticCodes.every(code => RECOVERY_CODES.has(code));
|
||||
}
|
||||
//# sourceMappingURL=repl.js.map
|
1
node_modules/ts-node/dist/repl.js.map
generated
vendored
Normal file
1
node_modules/ts-node/dist/repl.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
13
node_modules/ts-node/dist/tsconfig-schema.d.ts
generated
vendored
Normal file
13
node_modules/ts-node/dist/tsconfig-schema.d.ts
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
import { TsConfigOptions } from '.';
|
||||
/**
|
||||
* tsconfig schema which includes "ts-node" options.
|
||||
* @allOf [{"$ref": "https://schemastore.azurewebsites.net/schemas/json/tsconfig.json"}]
|
||||
*/
|
||||
export interface TsConfigSchema {
|
||||
/**
|
||||
* ts-node options. See also: https://github.com/TypeStrong/ts-node#configuration-options
|
||||
*
|
||||
* ts-node offers TypeScript execution and REPL for node.js, with source map support.
|
||||
*/
|
||||
'ts-node': TsConfigOptions;
|
||||
}
|
3
node_modules/ts-node/dist/tsconfig-schema.js
generated
vendored
Normal file
3
node_modules/ts-node/dist/tsconfig-schema.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=tsconfig-schema.js.map
|
1
node_modules/ts-node/dist/tsconfig-schema.js.map
generated
vendored
Normal file
1
node_modules/ts-node/dist/tsconfig-schema.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"tsconfig-schema.js","sourceRoot":"","sources":["../src/tsconfig-schema.ts"],"names":[],"mappings":"","sourcesContent":["import { TsConfigOptions } from '.'\n\n/*\n * This interface exists solely for generating a JSON schema for tsconfig.json.\n * We do *not* extend the compiler's tsconfig interface. Instead we handle that\n * on a schema level, via \"allOf\", so we pull in the same schema that VSCode\n * already uses.\n */\n/**\n * tsconfig schema which includes \"ts-node\" options.\n * @allOf [{\"$ref\": \"https://schemastore.azurewebsites.net/schemas/json/tsconfig.json\"}]\n */\nexport interface TsConfigSchema {\n /**\n * ts-node options. See also: https://github.com/TypeStrong/ts-node#configuration-options\n *\n * ts-node offers TypeScript execution and REPL for node.js, with source map support.\n */\n 'ts-node': TsConfigOptions\n}\n"]}
|
7
node_modules/ts-node/esm.mjs
generated
vendored
Normal file
7
node_modules/ts-node/esm.mjs
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
import {fileURLToPath} from 'url'
|
||||
import {createRequire} from 'module'
|
||||
const require = createRequire(fileURLToPath(import.meta.url))
|
||||
|
||||
/** @type {import('./dist/esm')} */
|
||||
const esm = require('./dist/esm')
|
||||
export const {resolve, getFormat, transformSource} = esm.registerAndCreateEsmHooks()
|
7
node_modules/ts-node/esm/transpile-only.mjs
generated
vendored
Normal file
7
node_modules/ts-node/esm/transpile-only.mjs
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
import {fileURLToPath} from 'url'
|
||||
import {createRequire} from 'module'
|
||||
const require = createRequire(fileURLToPath(import.meta.url))
|
||||
|
||||
/** @type {import('../dist/esm')} */
|
||||
const esm = require('../dist/esm')
|
||||
export const {resolve, getFormat, transformSource} = esm.registerAndCreateEsmHooks({transpileOnly: true})
|
121
node_modules/ts-node/package.json
generated
vendored
Normal file
121
node_modules/ts-node/package.json
generated
vendored
Normal file
@ -0,0 +1,121 @@
|
||||
{
|
||||
"name": "ts-node",
|
||||
"version": "9.1.1",
|
||||
"description": "TypeScript execution environment and REPL for node.js, with source map support",
|
||||
"main": "dist/index.js",
|
||||
"exports": {
|
||||
".": "./dist/index.js",
|
||||
"./package": "./package.json",
|
||||
"./package.json": "./package.json",
|
||||
"./dist/bin": "./dist/bin.js",
|
||||
"./dist/bin.js": "./dist/bin.js",
|
||||
"./dist/bin-transpile": "./dist/bin-transpile.js",
|
||||
"./dist/bin-transpile.js": "./dist/bin-transpile.js",
|
||||
"./dist/bin-script": "./dist/bin-script.js",
|
||||
"./dist/bin-script.js": "./dist/bin-script.js",
|
||||
"./register": "./register/index.js",
|
||||
"./register/files": "./register/files.js",
|
||||
"./register/transpile-only": "./register/transpile-only.js",
|
||||
"./register/type-check": "./register/type-check.js",
|
||||
"./esm": "./esm.mjs",
|
||||
"./esm.mjs": "./esm.mjs",
|
||||
"./esm/transpile-only": "./esm/transpile-only.mjs",
|
||||
"./esm/transpile-only.mjs": "./esm/transpile-only.mjs"
|
||||
},
|
||||
"types": "dist/index.d.ts",
|
||||
"bin": {
|
||||
"ts-node": "dist/bin.js",
|
||||
"ts-script": "dist/bin-script-deprecated.js",
|
||||
"ts-node-script": "dist/bin-script.js",
|
||||
"ts-node-transpile-only": "dist/bin-transpile.js"
|
||||
},
|
||||
"files": [
|
||||
"dist/",
|
||||
"dist-raw/",
|
||||
"register/",
|
||||
"esm/",
|
||||
"esm.mjs",
|
||||
"LICENSE",
|
||||
"tsconfig.schema.json",
|
||||
"tsconfig.schemastore-schema.json"
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "tslint \"src/**/*.ts\" --project tsconfig.json",
|
||||
"lint-fix": "tslint \"src/**/*.ts\" --project tsconfig.json --fix",
|
||||
"clean": "rimraf dist && rimraf tsconfig.schema.json && rimraf tsconfig.schemastore-schema.json && rimraf tests/ts-node-packed.tgz",
|
||||
"build": "npm run build-nopack && npm run build-pack",
|
||||
"build-nopack": "npm run clean && npm run build-tsc && npm run build-configSchema",
|
||||
"build-tsc": "tsc",
|
||||
"build-configSchema": "typescript-json-schema --topRef --refs --validationKeywords allOf --out tsconfig.schema.json tsconfig.json TsConfigSchema && node --require ./register ./scripts/create-merged-schema",
|
||||
"build-pack": "node ./scripts/build-pack.js",
|
||||
"test-spec": "mocha dist/**/*.spec.js -R spec --bail",
|
||||
"test-cov": "nyc mocha -- \"dist/**/*.spec.js\" -R spec --bail",
|
||||
"test": "npm run build && npm run lint && npm run test-cov --",
|
||||
"coverage-report": "nyc report --reporter=lcov",
|
||||
"prepare": "npm run build-nopack"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/TypeStrong/ts-node.git"
|
||||
},
|
||||
"keywords": [
|
||||
"typescript",
|
||||
"node",
|
||||
"runtime",
|
||||
"environment",
|
||||
"ts",
|
||||
"compiler"
|
||||
],
|
||||
"author": {
|
||||
"name": "Blake Embrey",
|
||||
"email": "hello@blakeembrey.com",
|
||||
"url": "http://blakeembrey.me"
|
||||
},
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/TypeStrong/ts-node/issues"
|
||||
},
|
||||
"homepage": "https://github.com/TypeStrong/ts-node",
|
||||
"devDependencies": {
|
||||
"@types/chai": "^4.0.4",
|
||||
"@types/diff": "^4.0.2",
|
||||
"@types/lodash": "^4.14.151",
|
||||
"@types/mocha": "^5.2.7",
|
||||
"@types/node": "13.13.5",
|
||||
"@types/proxyquire": "^1.3.28",
|
||||
"@types/react": "^16.0.2",
|
||||
"@types/rimraf": "^3.0.0",
|
||||
"@types/semver": "^7.1.0",
|
||||
"@types/source-map-support": "^0.5.0",
|
||||
"axios": "^0.19.0",
|
||||
"chai": "^4.0.1",
|
||||
"get-stream": "^6.0.0",
|
||||
"lodash": "^4.17.15",
|
||||
"mocha": "^6.2.2",
|
||||
"ntypescript": "^1.201507091536.1",
|
||||
"nyc": "^15.0.1",
|
||||
"proxyquire": "^2.0.0",
|
||||
"react": "^16.0.0",
|
||||
"rimraf": "^3.0.0",
|
||||
"semver": "^7.1.3",
|
||||
"tslint": "^6.1.0",
|
||||
"tslint-config-standard": "^9.0.0",
|
||||
"typescript": "4.1.2",
|
||||
"typescript-json-schema": "^0.42.0",
|
||||
"util.promisify": "^1.0.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": ">=2.7"
|
||||
},
|
||||
"dependencies": {
|
||||
"arg": "^4.1.0",
|
||||
"create-require": "^1.1.0",
|
||||
"diff": "^4.0.1",
|
||||
"make-error": "^1.1.1",
|
||||
"source-map-support": "^0.5.17",
|
||||
"yn": "3.1.1"
|
||||
}
|
||||
}
|
3
node_modules/ts-node/register/files.js
generated
vendored
Normal file
3
node_modules/ts-node/register/files.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
require('../dist').register({
|
||||
files: true
|
||||
})
|
1
node_modules/ts-node/register/index.js
generated
vendored
Normal file
1
node_modules/ts-node/register/index.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
require('../').register()
|
3
node_modules/ts-node/register/transpile-only.js
generated
vendored
Normal file
3
node_modules/ts-node/register/transpile-only.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
require('../').register({
|
||||
transpileOnly: true
|
||||
})
|
3
node_modules/ts-node/register/type-check.js
generated
vendored
Normal file
3
node_modules/ts-node/register/type-check.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
require('../').register({
|
||||
typeCheck: true
|
||||
})
|
124
node_modules/ts-node/tsconfig.schema.json
generated
vendored
Normal file
124
node_modules/ts-node/tsconfig.schema.json
generated
vendored
Normal file
@ -0,0 +1,124 @@
|
||||
{
|
||||
"$ref": "#/definitions/TsConfigSchema",
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"definitions": {
|
||||
"TsConfigOptions": {
|
||||
"description": "Must be an interface to support `typescript-json-schema`.",
|
||||
"properties": {
|
||||
"compiler": {
|
||||
"default": "typescript",
|
||||
"description": "Specify a custom TypeScript compiler.",
|
||||
"type": "string"
|
||||
},
|
||||
"compilerHost": {
|
||||
"default": false,
|
||||
"description": "Use TypeScript's compiler host API.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"compilerOptions": {
|
||||
"additionalProperties": true,
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "https://schemastore.azurewebsites.net/schemas/json/tsconfig.json#definitions/compilerOptionsDefinition/properties/compilerOptions"
|
||||
}
|
||||
],
|
||||
"description": "JSON object to merge with compiler options.",
|
||||
"properties": {
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"emit": {
|
||||
"default": false,
|
||||
"description": "Emit output files into `.ts-node` directory.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"experimentalEsmLoader": {
|
||||
"description": "True if require() hooks should interop with experimental ESM loader.\nEnabled explicitly via a flag since it is a breaking change.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"files": {
|
||||
"default": false,
|
||||
"description": "Load files from `tsconfig.json` on startup.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"ignore": {
|
||||
"default": "/node_modules/",
|
||||
"description": "Override the path patterns to skip compilation.",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"ignoreDiagnostics": {
|
||||
"description": "Ignore TypeScript warnings by diagnostic code.",
|
||||
"items": {
|
||||
"type": [
|
||||
"string",
|
||||
"number"
|
||||
]
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"logError": {
|
||||
"default": false,
|
||||
"description": "Logs TypeScript errors to stderr instead of throwing exceptions.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"preferTsExts": {
|
||||
"default": false,
|
||||
"description": "Re-order file extensions so that TypeScript imports are preferred.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"pretty": {
|
||||
"default": false,
|
||||
"description": "Use pretty diagnostic formatter.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"require": {
|
||||
"description": "Modules to require, like node's `--require` flag.\n\nIf specified in tsconfig.json, the modules will be resolved relative to the tsconfig.json file.\n\nIf specified programmatically, each input string should be pre-resolved to an absolute path for\nbest results.",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"scope": {
|
||||
"default": false,
|
||||
"description": "Scope compiler to files within `cwd`.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"skipIgnore": {
|
||||
"default": false,
|
||||
"description": "Skip ignore check.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"transpileOnly": {
|
||||
"default": false,
|
||||
"description": "Use TypeScript's faster `transpileModule`.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"typeCheck": {
|
||||
"default": true,
|
||||
"description": "**DEPRECATED** Specify type-check is enabled (e.g. `transpileOnly == false`).",
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"TsConfigSchema": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "https://schemastore.azurewebsites.net/schemas/json/tsconfig.json"
|
||||
}
|
||||
],
|
||||
"description": "tsconfig schema which includes \"ts-node\" options.",
|
||||
"properties": {
|
||||
"ts-node": {
|
||||
"$ref": "#/definitions/TsConfigOptions",
|
||||
"description": "ts-node options. See also: https://github.com/TypeStrong/ts-node#configuration-options\n\nts-node offers TypeScript execution and REPL for node.js, with source map support."
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
935
node_modules/ts-node/tsconfig.schemastore-schema.json
generated
vendored
Normal file
935
node_modules/ts-node/tsconfig.schemastore-schema.json
generated
vendored
Normal file
@ -0,0 +1,935 @@
|
||||
{
|
||||
"title": "JSON schema for the TypeScript compiler's configuration file",
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"id": "https://json.schemastore.org/tsconfig",
|
||||
"definitions": {
|
||||
"//": {
|
||||
"explainer": "https://www.typescriptlang.org/docs/handbook/tsconfig-json.html#overview",
|
||||
"reference": "https://www.typescriptlang.org/tsconfig",
|
||||
"reference metadata": "https://github.com/microsoft/TypeScript-Website/blob/v2/packages/tsconfig-reference/scripts/tsconfigRules.ts"
|
||||
},
|
||||
"filesDefinition": {
|
||||
"properties": {
|
||||
"files": {
|
||||
"description": "If no 'files' or 'include' property is present in a tsconfig.json, the compiler defaults to including all files in the containing directory and subdirectories except those specified by 'exclude'. When a 'files' property is specified, only those files and those specified by 'include' are included.",
|
||||
"type": "array",
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"excludeDefinition": {
|
||||
"properties": {
|
||||
"exclude": {
|
||||
"description": "Specifies a list of files to be excluded from compilation. The 'exclude' property only affects the files included via the 'include' property and not the 'files' property. Glob patterns require TypeScript version 2.0 or later.",
|
||||
"type": "array",
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"includeDefinition": {
|
||||
"properties": {
|
||||
"include": {
|
||||
"description": "Specifies a list of glob patterns that match files to be included in compilation. If no 'files' or 'include' property is present in a tsconfig.json, the compiler defaults to including all files in the containing directory and subdirectories except those specified by 'exclude'. Requires TypeScript version 2.0 or later.",
|
||||
"type": "array",
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"compileOnSaveDefinition": {
|
||||
"properties": {
|
||||
"compileOnSave": {
|
||||
"description": "Enable Compile-on-Save for this project.",
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"extendsDefinition": {
|
||||
"properties": {
|
||||
"extends": {
|
||||
"description": "Path to base configuration file to inherit from. Requires TypeScript version 2.1 or later.",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"compilerOptionsDefinition": {
|
||||
"properties": {
|
||||
"compilerOptions": {
|
||||
"type": "object",
|
||||
"description": "Instructs the TypeScript compiler how to compile .ts files.",
|
||||
"properties": {
|
||||
"charset": {
|
||||
"description": "The character set of the input files. This setting is deprecated.",
|
||||
"type": "string"
|
||||
},
|
||||
"composite": {
|
||||
"description": "Enables building for project references. Requires TypeScript version 3.0 or later.",
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
"declaration": {
|
||||
"description": "Generates corresponding d.ts files.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"declarationDir": {
|
||||
"description": "Specify output directory for generated declaration files. Requires TypeScript version 2.0 or later.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"diagnostics": {
|
||||
"description": "Show diagnostic information. This setting is deprecated. See `extendedDiagnostics.`",
|
||||
"type": "boolean"
|
||||
},
|
||||
"disableReferencedProjectLoad": {
|
||||
"description": "Recommend IDE's to load referenced composite projects dynamically instead of loading them all immediately. Requires TypeScript version 4.0 or later.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"emitBOM": {
|
||||
"description": "Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"emitDeclarationOnly": {
|
||||
"description": "Only emit '.d.ts' declaration files. Requires TypeScript version 2.8 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"incremental": {
|
||||
"description": "Enable incremental compilation. Requires TypeScript version 3.4 or later.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"tsBuildInfoFile": {
|
||||
"description": "Specify file to store incremental compilation information. Requires TypeScript version 3.4 or later.",
|
||||
"default": ".tsbuildinfo",
|
||||
"type": "string"
|
||||
},
|
||||
"inlineSourceMap": {
|
||||
"description": "Emit a single file with source maps instead of having a separate file. Requires TypeScript version 1.5 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"inlineSources": {
|
||||
"description": "Emit the source alongside the sourcemaps within a single file; requires --inlineSourceMap to be set. Requires TypeScript version 1.5 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"jsx": {
|
||||
"description": "Specify JSX code generation: 'preserve', 'react', 'react-jsx', 'react-jsxdev' or'react-native'. Requires TypeScript version 2.2 or later.",
|
||||
"enum": [
|
||||
"preserve",
|
||||
"react",
|
||||
"react-jsx",
|
||||
"react-jsxdev",
|
||||
"react-native"
|
||||
]
|
||||
},
|
||||
"reactNamespace": {
|
||||
"description": "Specify the object invoked for createElement and __spread when targeting 'react' JSX emit.",
|
||||
"type": "string",
|
||||
"default": "React"
|
||||
},
|
||||
"jsxFactory": {
|
||||
"description": "Specify the JSX factory function to use when targeting react JSX emit, e.g. 'React.createElement' or 'h'. Requires TypeScript version 2.1 or later.",
|
||||
"type": "string",
|
||||
"default": "React.createElement"
|
||||
},
|
||||
"jsxFragmentFactory": {
|
||||
"description": "Specify the JSX Fragment reference to use for fragements when targeting react JSX emit, e.g. 'React.Fragment' or 'Fragment'. Requires TypeScript version 4.0 or later.",
|
||||
"type": "string",
|
||||
"default": "React.Fragment"
|
||||
},
|
||||
"jsxImportSource": {
|
||||
"description": "Declare the module specifier to be used for importing the `jsx` and `jsxs` factory functions when using jsx as \"react-jsx\" or \"react-jsxdev\". Requires TypeScript version 4.1 or later.",
|
||||
"type": "string",
|
||||
"default": "react"
|
||||
},
|
||||
"listFiles": {
|
||||
"description": "Print names of files part of the compilation.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"mapRoot": {
|
||||
"description": "Specify the location where debugger should locate map files instead of generated locations",
|
||||
"type": "string"
|
||||
},
|
||||
"module": {
|
||||
"description": "Specify module code generation: 'None', 'CommonJS', 'AMD', 'System', 'UMD', 'ES6', 'ES2015', 'ES2020' or 'ESNext'. Only 'AMD' and 'System' can be used in conjunction with --outFile.",
|
||||
"type": "string",
|
||||
"anyOf": [
|
||||
{
|
||||
"enum": [
|
||||
"CommonJS",
|
||||
"AMD",
|
||||
"System",
|
||||
"UMD",
|
||||
"ES6",
|
||||
"ES2015",
|
||||
"ES2020",
|
||||
"ESNext",
|
||||
"None"
|
||||
]
|
||||
},
|
||||
{
|
||||
"pattern": "^([Cc][Oo][Mm][Mm][Oo][Nn][Jj][Ss]|[AaUu][Mm][Dd]|[Ss][Yy][Ss][Tt][Ee][Mm]|[Ee][Ss]([356]|201[567]|2020|[Nn][Ee][Xx][Tt])|[Nn][Oo][Nn][Ee])$"
|
||||
}
|
||||
]
|
||||
},
|
||||
"moduleResolution": {
|
||||
"description": "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) .",
|
||||
"type": "string",
|
||||
"anyOf": [
|
||||
{
|
||||
"enum": [
|
||||
"Classic",
|
||||
"Node"
|
||||
]
|
||||
},
|
||||
{
|
||||
"pattern": "^(([Nn]ode)|([Cc]lassic))$"
|
||||
}
|
||||
],
|
||||
"default": "classic"
|
||||
},
|
||||
"newLine": {
|
||||
"description": "Specifies the end of line sequence to be used when emitting files: 'crlf' (Windows) or 'lf' (Unix). Requires TypeScript version 1.5 or later.",
|
||||
"type": "string",
|
||||
"anyOf": [
|
||||
{
|
||||
"enum": [
|
||||
"crlf",
|
||||
"lf"
|
||||
]
|
||||
},
|
||||
{
|
||||
"pattern": "^(CRLF|LF|crlf|lf)$"
|
||||
}
|
||||
]
|
||||
},
|
||||
"noEmit": {
|
||||
"description": "Do not emit output.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"noEmitHelpers": {
|
||||
"description": "Do not generate custom helper functions like __extends in compiled output. Requires TypeScript version 1.5 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"noEmitOnError": {
|
||||
"description": "Do not emit outputs if any type checking errors were reported. Requires TypeScript version 1.4 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"noImplicitAny": {
|
||||
"description": "Warn on expressions and declarations with an implied 'any' type. Enabling this setting is recommended.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"noImplicitThis": {
|
||||
"description": "Raise error on 'this' expressions with an implied any type. Enabling this setting is recommended. Requires TypeScript version 2.0 or later.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"noUnusedLocals": {
|
||||
"description": "Report errors on unused locals. Requires TypeScript version 2.0 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"noUnusedParameters": {
|
||||
"description": "Report errors on unused parameters. Requires TypeScript version 2.0 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"noLib": {
|
||||
"description": "Do not include the default library file (lib.d.ts).",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"noResolve": {
|
||||
"description": "Do not add triple-slash references or module import targets to the list of compiled files.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"noStrictGenericChecks": {
|
||||
"description": "Disable strict checking of generic signatures in function types. Requires TypeScript version 2.4 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"skipDefaultLibCheck": {
|
||||
"description": "Use `skipLibCheck` instead. Skip type checking of default library declaration files.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"skipLibCheck": {
|
||||
"description": "Skip type checking of declaration files. Enabling this setting is recommended. Requires TypeScript version 2.0 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"outFile": {
|
||||
"description": "Concatenate and emit output to single file.",
|
||||
"type": "string"
|
||||
},
|
||||
"outDir": {
|
||||
"description": "Redirect output structure to the directory.",
|
||||
"type": "string"
|
||||
},
|
||||
"preserveConstEnums": {
|
||||
"description": "Do not erase const enum declarations in generated code.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"preserveSymlinks": {
|
||||
"description": "Do not resolve symlinks to their real path; treat a symlinked file like a real one.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"preserveWatchOutput": {
|
||||
"description": "Keep outdated console output in watch mode instead of clearing the screen.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"pretty": {
|
||||
"description": "Stylize errors and messages using color and context (experimental).",
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
"removeComments": {
|
||||
"description": "Do not emit comments to output.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"rootDir": {
|
||||
"description": "Specifies the root directory of input files. Use to control the output directory structure with --outDir.",
|
||||
"type": "string"
|
||||
},
|
||||
"isolatedModules": {
|
||||
"description": "Unconditionally emit imports for unresolved files.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"sourceMap": {
|
||||
"description": "Generates corresponding '.map' file.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"sourceRoot": {
|
||||
"description": "Specifies the location where debugger should locate TypeScript files instead of source locations.",
|
||||
"type": "string"
|
||||
},
|
||||
"suppressExcessPropertyErrors": {
|
||||
"description": "Suppress excess property checks for object literals. It is recommended to use @ts-ignore comments instead of enabling this setting.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"suppressImplicitAnyIndexErrors": {
|
||||
"description": "Suppress noImplicitAny errors for indexing objects lacking index signatures. It is recommended to use @ts-ignore comments instead of enabling this setting.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"stripInternal": {
|
||||
"description": "Do not emit declarations for code that has an '@internal' annotation.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"target": {
|
||||
"description": "Specify ECMAScript target version: 'ES3', 'ES5', 'ES6'/'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ESNext'",
|
||||
"type": "string",
|
||||
"default": "ES3",
|
||||
"anyOf": [
|
||||
{
|
||||
"enum": [
|
||||
"ES3",
|
||||
"ES5",
|
||||
"ES6",
|
||||
"ES2015",
|
||||
"ES2016",
|
||||
"ES2017",
|
||||
"ES2018",
|
||||
"ES2019",
|
||||
"ES2020",
|
||||
"ESNext"
|
||||
]
|
||||
},
|
||||
{
|
||||
"pattern": "^([Ee][Ss]([356]|(20(1[56789]|20))|[Nn][Ee][Xx][Tt]))$"
|
||||
}
|
||||
]
|
||||
},
|
||||
"watch": {
|
||||
"description": "Watch input files.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"fallbackPolling": {
|
||||
"description": "Specify the polling strategy to use when the system runs out of or doesn't support native file watchers. Requires TypeScript version 3.8 or later.",
|
||||
"enum": [
|
||||
"fixedPollingInterval",
|
||||
"priorityPollingInterval",
|
||||
"dynamicPriorityPolling"
|
||||
]
|
||||
},
|
||||
"watchDirectory": {
|
||||
"description": "Specify the strategy for watching directories under systems that lack recursive file-watching functionality. Requires TypeScript version 3.8 or later.",
|
||||
"enum": [
|
||||
"useFsEvents",
|
||||
"fixedPollingInterval",
|
||||
"dynamicPriorityPolling"
|
||||
],
|
||||
"default": "useFsEvents"
|
||||
},
|
||||
"watchFile": {
|
||||
"description": "Specify the strategy for watching individual files. Requires TypeScript version 3.8 or later.",
|
||||
"enum": [
|
||||
"fixedPollingInterval",
|
||||
"priorityPollingInterval",
|
||||
"dynamicPriorityPolling",
|
||||
"useFsEvents",
|
||||
"useFsEventsOnParentDirectory"
|
||||
],
|
||||
"default": "useFsEvents"
|
||||
},
|
||||
"experimentalDecorators": {
|
||||
"description": "Enables experimental support for ES7 decorators.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"emitDecoratorMetadata": {
|
||||
"description": "Emit design-type metadata for decorated declarations in source.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"allowUnusedLabels": {
|
||||
"description": "Do not report errors on unused labels. Requires TypeScript version 1.8 or later.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"noImplicitReturns": {
|
||||
"description": "Report error when not all code paths in function return a value. Requires TypeScript version 1.8 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"noUncheckedIndexedAccess": {
|
||||
"description": "Add `undefined` to an un-declared field in a type. Requires TypeScript version 4.1 or later.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"noFallthroughCasesInSwitch": {
|
||||
"description": "Report errors for fallthrough cases in switch statement. Requires TypeScript version 1.8 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"allowUnreachableCode": {
|
||||
"description": "Do not report errors on unreachable code. Requires TypeScript version 1.8 or later.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"forceConsistentCasingInFileNames": {
|
||||
"description": "Disallow inconsistently-cased references to the same file. Enabling this setting is recommended.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"generateCpuProfile": {
|
||||
"description": "Emit a v8 CPI profile during the compiler run, which may provide insight into slow builds. Requires TypeScript version 3.7 or later.",
|
||||
"type": "string",
|
||||
"default": "profile.cpuprofile"
|
||||
},
|
||||
"importNotUsedAsValues": {
|
||||
"description": "This flag controls how imports work. When set to `remove`, imports that only reference types are dropped. When set to `preserve`, imports are never dropped. When set to `error`, imports that can be replaced with `import type` will result in a compiler error. Requires TypeScript version 3.8 or later.",
|
||||
"enum": [
|
||||
"remove",
|
||||
"preserve",
|
||||
"error"
|
||||
]
|
||||
},
|
||||
"baseUrl": {
|
||||
"description": "Base directory to resolve non-relative module names.",
|
||||
"type": "string"
|
||||
},
|
||||
"paths": {
|
||||
"description": "Specify path mapping to be computed relative to baseUrl option.",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "array",
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"type": "string",
|
||||
"description": "Path mapping to be computed relative to baseUrl option."
|
||||
}
|
||||
}
|
||||
},
|
||||
"plugins": {
|
||||
"description": "List of TypeScript language server plugins to load. Requires TypeScript version 2.3 or later.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"description": "Plugin name.",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"rootDirs": {
|
||||
"description": "Specify list of root directories to be used when resolving modules. Requires TypeScript version 2.0 or later.",
|
||||
"type": "array",
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"typeRoots": {
|
||||
"description": "Specify list of directories for type definition files to be included. Requires TypeScript version 2.0 or later.",
|
||||
"type": "array",
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"types": {
|
||||
"description": "Type declaration files to be included in compilation. Requires TypeScript version 2.0 or later.",
|
||||
"type": "array",
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"traceResolution": {
|
||||
"description": "Enable tracing of the name resolution process. Requires TypeScript version 2.0 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"allowJs": {
|
||||
"description": "Allow javascript files to be compiled. Requires TypeScript version 1.8 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"noErrorTruncation": {
|
||||
"description": "Do not truncate error messages. This setting is deprecated.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"allowSyntheticDefaultImports": {
|
||||
"description": "Allow default imports from modules with no default export. This does not affect code emit, just typechecking. Requires TypeScript version 1.8 or later.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"noImplicitUseStrict": {
|
||||
"description": "Do not emit 'use strict' directives in module output.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"listEmittedFiles": {
|
||||
"description": "Enable to list all emitted files. Requires TypeScript version 2.0 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"disableSizeLimit": {
|
||||
"description": "Disable size limit for JavaScript project. Requires TypeScript version 2.0 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"lib": {
|
||||
"description": "List of library files to be included in the compilation. Possible values are: 'ES5', 'ES6', 'ES2015', 'ES7', 'ES2016', 'ES2017', 'ES2018', 'ESNext', 'DOM', 'DOM.Iterable', 'WebWorker', 'ScriptHost', 'ES2015.Core', 'ES2015.Collection', 'ES2015.Generator', 'ES2015.Iterable', 'ES2015.Promise', 'ES2015.Proxy', 'ES2015.Reflect', 'ES2015.Symbol', 'ES2015.Symbol.WellKnown', 'ES2016.Array.Include', 'ES2017.object', 'ES2017.Intl', 'ES2017.SharedMemory', 'ES2017.String', 'ES2017.TypedArrays', 'ES2018.Intl', 'ES2018.Promise', 'ES2018.RegExp', 'ESNext.AsyncIterable', 'ESNext.Array', 'ESNext.Intl', 'ESNext.Symbol'. Requires TypeScript version 2.0 or later.",
|
||||
"type": "array",
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"type": "string",
|
||||
"anyOf": [
|
||||
{
|
||||
"enum": [
|
||||
"ES5",
|
||||
"ES6",
|
||||
"ES2015",
|
||||
"ES2015.Collection",
|
||||
"ES2015.Core",
|
||||
"ES2015.Generator",
|
||||
"ES2015.Iterable",
|
||||
"ES2015.Promise",
|
||||
"ES2015.Proxy",
|
||||
"ES2015.Reflect",
|
||||
"ES2015.Symbol.WellKnown",
|
||||
"ES2015.Symbol",
|
||||
"ES2016",
|
||||
"ES2016.Array.Include",
|
||||
"ES2017",
|
||||
"ES2017.Intl",
|
||||
"ES2017.Object",
|
||||
"ES2017.SharedMemory",
|
||||
"ES2017.String",
|
||||
"ES2017.TypedArrays",
|
||||
"ES2018",
|
||||
"ES2018.AsyncGenerator",
|
||||
"ES2018.AsyncIterable",
|
||||
"ES2018.Intl",
|
||||
"ES2018.Promise",
|
||||
"ES2018.Regexp",
|
||||
"ES2019",
|
||||
"ES2019.Array",
|
||||
"ES2019.Object",
|
||||
"ES2019.String",
|
||||
"ES2019.Symbol",
|
||||
"ES2020",
|
||||
"ES2020.BigInt",
|
||||
"ES2020.Promise",
|
||||
"ES2020.String",
|
||||
"ES2020.Symbol.WellKnown",
|
||||
"ESNext",
|
||||
"ESNext.Array",
|
||||
"ESNext.AsyncIterable",
|
||||
"ESNext.BigInt",
|
||||
"ESNext.Intl",
|
||||
"ESNext.Promise",
|
||||
"ESNext.String",
|
||||
"ESNext.Symbol",
|
||||
"DOM",
|
||||
"DOM.Iterable",
|
||||
"ScriptHost",
|
||||
"WebWorker",
|
||||
"WebWorker.ImportScripts"
|
||||
]
|
||||
},
|
||||
{
|
||||
"pattern": "^[Ee][Ss]5|[Ee][Ss]6|[Ee][Ss]7$"
|
||||
},
|
||||
{
|
||||
"pattern": "^[Ee][Ss]2015(\\.([Cc][Oo][Ll][Ll][Ee][Cc][Tt][Ii][Oo][Nn]|[Cc][Oo][Rr][Ee]|[Gg][Ee][Nn][Ee][Rr][Aa][Tt][Oo][Rr]|[Ii][Tt][Ee][Rr][Aa][Bb][Ll][Ee]|[Pp][Rr][Oo][Mm][Ii][Ss][Ee]|[Pp][Rr][Oo][Xx][Yy]|[Rr][Ee][Ff][Ll][Ee][Cc][Tt]|[Ss][Yy][Mm][Bb][Oo][Ll].[Ww][Ee][Ll][Ll][Kk][Nn][Oo][Ww][Nn]|[Ss][Yy][Mm][Bb][Oo][Ll]))?$"
|
||||
},
|
||||
{
|
||||
"pattern": "^[Ee][Ss]2016(\\.[Aa][Rr][Rr][Aa][Yy].[Ii][Nn][Cc][Ll][Uu][Dd][Ee])?$"
|
||||
},
|
||||
{
|
||||
"pattern": "^[Ee][Ss]2017(\\.([Ii][Nn][Tt][Ll]|[Oo][Bb][Jj][Ee][Cc][Tt]|[Ss][Hh][Aa][Rr][Ee][Dd][Mm][Ee][Mm][Oo][Rr][Yy]|[Ss][Tt][Rr][Ii][Nn][Gg]|[Tt][Yy][Pp][Ee][Dd][Aa][Rr][Rr][Aa][Yy][Ss]))?$"
|
||||
},
|
||||
{
|
||||
"pattern": "^[Ee][Ss]2018(\\.([Aa][Ss][Yy][Nn][Cc][Ii][Tt][Ee][Rr][Aa][Bb][Ll][Ee]|[Ii][Nn][Tt][Ll]|[Pp][Rr][Oo][Mm][Ii][Ss][Ee]|[Rr][Ee][Gg][Ee][Xx][Pp]))?$"
|
||||
},
|
||||
{
|
||||
"pattern": "^[Ee][Ss]2019(\\.([Aa][Rr][Rr][Aa][Yy]|[Oo][Bb][Jj][Ee][Cc][Tt]|[Ss][Tt][Rr][Ii][Nn][Gg]|[Ss][Yy][Mm][Bb][Oo][Ll]))?$"
|
||||
},
|
||||
{
|
||||
"pattern": "^[Ee][Ss]2020(\\.([Bb][Ii][Gg][Ii][Nn][Tt]|[Pp][Rr][Oo][Mm][Ii][Ss][Ee]|[Ss][Tt][Rr][Ii][Nn][Gg]|[Ss][Yy][Mm][Bb][Oo][Ll].[Ww][Ee][Ll][Ll][Kk][Nn][Oo][Ww][Nn]))?$"
|
||||
},
|
||||
{
|
||||
"pattern": "^[Ee][Ss][Nn][Ee][Xx][Tt](\\.([Aa][Rr][Rr][Aa][Yy]|[Aa][Ss][Yy][Nn][Cc][Ii][Tt][Ee][Rr][Aa][Bb][Ll][Ee]|[Bb][Ii][Gg][Ii][Nn][Tt]|[Ii][Nn][Tt][Ll]|[Ss][Yy][Mm][Bb][Oo][Ll]))?$"
|
||||
},
|
||||
{
|
||||
"pattern": "^[Dd][Oo][Mm](\\.[Ii][Tt][Ee][Rr][Aa][Bb][Ll][Ee])?$"
|
||||
},
|
||||
{
|
||||
"pattern": "^[Ss][Cc][Rr][Ii][Pp][Tt][Hh][Oo][Ss][Tt]$"
|
||||
},
|
||||
{
|
||||
"pattern": "^[Ww][Ee][Bb][Ww][Oo][Rr][Kk][Ee][Rr](\\.[Ii][Mm][Pp][Oo][Rr][Tt][Ss][Cc][Rr][Ii][Pp][Tt][Ss])?$"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"strictNullChecks": {
|
||||
"description": "Enable strict null checks. Enabling this setting is recommended. Requires TypeScript version 2.0 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"maxNodeModuleJsDepth": {
|
||||
"description": "The maximum dependency depth to search under node_modules and load JavaScript files. Only applicable with --allowJs.",
|
||||
"type": "number",
|
||||
"default": 0
|
||||
},
|
||||
"importHelpers": {
|
||||
"description": "Import emit helpers (e.g. '__extends', '__rest', etc..) from tslib. Requires TypeScript version 2.1 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"importsNotUsedAsValues": {
|
||||
"description": "Specify emit/checking behavior for imports that are only used for types. Requires TypeScript version 3.8 or later.",
|
||||
"type": "string",
|
||||
"default": "remove",
|
||||
"enum": [
|
||||
"remove",
|
||||
"preserve",
|
||||
"error"
|
||||
]
|
||||
},
|
||||
"alwaysStrict": {
|
||||
"description": "Parse in strict mode and emit 'use strict' for each source file. Requires TypeScript version 2.1 or later.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"strict": {
|
||||
"description": "Enable all strict type checking options. Enabling this setting is recommended. Requires TypeScript version 2.3 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"strictBindCallApply": {
|
||||
"description": "Enable stricter checking of of the `bind`, `call`, and `apply` methods on functions. Enabling this setting is recommended. Requires TypeScript version 3.2 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"downlevelIteration": {
|
||||
"description": "Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. Requires TypeScript version 2.3 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"checkJs": {
|
||||
"description": "Report errors in .js files. Requires TypeScript version 2.3 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"strictFunctionTypes": {
|
||||
"description": "Disable bivariant parameter checking for function types. Enabling this setting is recommended. Requires TypeScript version 2.6 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"strictPropertyInitialization": {
|
||||
"description": "Ensure non-undefined class properties are initialized in the constructor. Enabling this setting is recommended. Requires TypeScript version 2.7 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"esModuleInterop": {
|
||||
"description": "Emit '__importStar' and '__importDefault' helpers for runtime babel ecosystem compatibility and enable '--allowSyntheticDefaultImports' for typesystem compatibility. Enabling this setting is recommended. Requires TypeScript version 2.7 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"allowUmdGlobalAccess": {
|
||||
"description": "Allow accessing UMD globals from modules. Requires TypeScript version 3.5 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"keyofStringsOnly": {
|
||||
"description": "Resolve 'keyof' to string valued property names only (no numbers or symbols). This setting is deprecated. Requires TypeScript version 2.9 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"useDefineForClassFields": {
|
||||
"description": "Emit ECMAScript standard class fields. Requires TypeScript version 3.7 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"declarationMap": {
|
||||
"description": "Generates a sourcemap for each corresponding '.d.ts' file. Requires TypeScript version 2.9 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"resolveJsonModule": {
|
||||
"description": "Include modules imported with '.json' extension. Requires TypeScript version 2.9 or later.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"assumeChangesOnlyAffectDirectDependencies": {
|
||||
"description": "Have recompiles in '--incremental' and '--watch' assume that changes within a file will only affect files directly depending on it. Requires TypeScript version 3.8 or later.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"extendedDiagnostics": {
|
||||
"description": "Show verbose diagnostic information.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"listFilesOnly": {
|
||||
"description": "Print names of files that are part of the compilation and then stop processing.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"disableSourceOfProjectReferenceRedirect": {
|
||||
"description": "Disable use of source files instead of declaration files from referenced projects. Requires TypeScript version 3.7 or later.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"disableSolutionSearching": {
|
||||
"description": "Disable solution searching for this project. Requires TypeScript version 3.8 or later.",
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"typeAcquisitionDefinition": {
|
||||
"properties": {
|
||||
"typeAcquisition": {
|
||||
"type": "object",
|
||||
"description": "Auto type (.d.ts) acquisition options for this project. Requires TypeScript version 2.1 or later.",
|
||||
"properties": {
|
||||
"enable": {
|
||||
"description": "Enable auto type acquisition",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"include": {
|
||||
"description": "Specifies a list of type declarations to be included in auto type acquisition. Ex. [\"jquery\", \"lodash\"]",
|
||||
"type": "array",
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"exclude": {
|
||||
"description": "Specifies a list of type declarations to be excluded from auto type acquisition. Ex. [\"jquery\", \"lodash\"]",
|
||||
"type": "array",
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"referencesDefinition": {
|
||||
"properties": {
|
||||
"references": {
|
||||
"type": "array",
|
||||
"uniqueItems": true,
|
||||
"description": "Referenced projects. Requires TypeScript version 3.0 or later.",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"description": "Project reference.",
|
||||
"properties": {
|
||||
"path": {
|
||||
"type": "string",
|
||||
"description": "Path to referenced tsconfig or to folder containing tsconfig."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tsNodeDefinition": {
|
||||
"properties": {
|
||||
"ts-node": {
|
||||
"description": "ts-node options. See also: https://github.com/TypeStrong/ts-node#configuration-options\n\nts-node offers TypeScript execution and REPL for node.js, with source map support.",
|
||||
"properties": {
|
||||
"compiler": {
|
||||
"default": "typescript",
|
||||
"description": "Specify a custom TypeScript compiler.",
|
||||
"type": "string"
|
||||
},
|
||||
"compilerHost": {
|
||||
"default": false,
|
||||
"description": "Use TypeScript's compiler host API.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"compilerOptions": {
|
||||
"additionalProperties": true,
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/compilerOptionsDefinition/properties/compilerOptions"
|
||||
}
|
||||
],
|
||||
"description": "JSON object to merge with compiler options.",
|
||||
"properties": {},
|
||||
"type": "object"
|
||||
},
|
||||
"emit": {
|
||||
"default": false,
|
||||
"description": "Emit output files into `.ts-node` directory.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"experimentalEsmLoader": {
|
||||
"description": "True if require() hooks should interop with experimental ESM loader.\nEnabled explicitly via a flag since it is a breaking change.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"files": {
|
||||
"default": false,
|
||||
"description": "Load files from `tsconfig.json` on startup.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"ignore": {
|
||||
"default": "/node_modules/",
|
||||
"description": "Override the path patterns to skip compilation.",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"ignoreDiagnostics": {
|
||||
"description": "Ignore TypeScript warnings by diagnostic code.",
|
||||
"items": {
|
||||
"type": [
|
||||
"string",
|
||||
"number"
|
||||
]
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"logError": {
|
||||
"default": false,
|
||||
"description": "Logs TypeScript errors to stderr instead of throwing exceptions.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"preferTsExts": {
|
||||
"default": false,
|
||||
"description": "Re-order file extensions so that TypeScript imports are preferred.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"pretty": {
|
||||
"default": false,
|
||||
"description": "Use pretty diagnostic formatter.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"require": {
|
||||
"description": "Modules to require, like node's `--require` flag.\n\nIf specified in tsconfig.json, the modules will be resolved relative to the tsconfig.json file.\n\nIf specified programmatically, each input string should be pre-resolved to an absolute path for\nbest results.",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"scope": {
|
||||
"default": false,
|
||||
"description": "Scope compiler to files within `cwd`.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"skipIgnore": {
|
||||
"default": false,
|
||||
"description": "Skip ignore check.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"transpileOnly": {
|
||||
"default": false,
|
||||
"description": "Use TypeScript's faster `transpileModule`.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"typeCheck": {
|
||||
"default": true,
|
||||
"description": "**DEPRECATED** Specify type-check is enabled (e.g. `transpileOnly == false`).",
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"type": "object",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/compilerOptionsDefinition"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/compileOnSaveDefinition"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/typeAcquisitionDefinition"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/extendsDefinition"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/tsNodeDefinition"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/tsNodeDefinition"
|
||||
},
|
||||
{
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/filesDefinition"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/excludeDefinition"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/includeDefinition"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/referencesDefinition"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user