Switch to ESLint (#4085)

* Switch to using ESLint only

* Fix commit hook

* Fix tests

* Adapt VSCode config

* Fix changelog

* Fix prototypes
pull/4099/head
Lukas Taegert-Atkinson 3 years ago committed by GitHub
parent 551e34a314
commit ebb3ff69c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,91 @@
module.exports = {
env: {
browser: true,
es6: true,
node: true
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
'plugin:prettier/recommended',
'plugin:import/recommended',
'plugin:import/typescript'
],
ignorePatterns: [
'node_modules/**/*.*',
'dist/**/*.*',
'/test/**/*.*',
'!/test/*.js',
'!/test/*/*.js',
'/test/node_modules/*.*',
'!/test/*/samples/**/_config.js'
],
overrides: [
{
files: ['*.js'],
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off'
}
},
{
files: ['*.js', 'cli/**/*.ts'],
rules: {
'@typescript-eslint/no-var-requires': 'off'
}
},
{
env: {
mocha: true
},
files: ['test/**/*.js'],
rules: {
'sort-keys': 'off'
}
}
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module'
},
plugins: ['@typescript-eslint'],
rules: {
'@typescript-eslint/consistent-type-assertions': [
'error',
{ assertionStyle: 'as', objectLiteralTypeAssertions: 'allow' }
],
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
'@typescript-eslint/member-ordering': [
'error',
{
default: {
memberTypes: require('@typescript-eslint/eslint-plugin/dist/rules/member-ordering')
.defaultOrder,
order: 'alphabetically'
}
}
],
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'dot-notation': 'error',
'import/no-unresolved': ['error', { ignore: ['package.json', 'is-reference', 'help.md'] }],
'import/order': ['error', { alphabetize: { order: 'asc' } }],
'no-constant-condition': ['error', { checkLoops: false }],
'no-prototype-builtins': 'off',
'object-shorthand': 'error',
'prefer-const': ['error', { destructuring: 'all' }],
'prefer-object-spread': 'error',
'sort-imports': [
'error',
{
ignoreCase: true,
ignoreDeclarationSort: true,
ignoreMemberSort: false
}
],
'sort-keys': ['error', 'asc', { caseSensitive: false }]
}
};

@ -1,48 +0,0 @@
{
"ignorePatterns": [
"test/*/samples/**/*.js",
"!test/*/samples/**/_config.js",
"test/leak/index.js",
"**/*.ts"
],
"rules": {
"indent": [ 2, "tab", { "SwitchCase": 1 } ],
"semi": [ 2, "always" ],
"keyword-spacing": [ 2, { "before": true, "after": true } ],
"space-before-blocks": [ 2, "always" ],
"no-mixed-spaces-and-tabs": [ 2, "smart-tabs" ],
"no-cond-assign": 0,
"no-unused-vars": 2,
"object-shorthand": [ 2, "always" ],
"no-const-assign": 2,
"no-class-assign": 2,
"no-this-before-super": 2,
"no-var": 2,
"no-unreachable": 2,
"valid-typeof": 2,
"quote-props": [ 2, "as-needed" ],
"one-var": [ 2, "never" ],
"prefer-arrow-callback": 2,
"prefer-const": [ 2, { "destructuring": "all" } ],
"arrow-spacing": 2
},
"env": {
"es6": true,
"browser": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings"
],
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"settings": {
"import/ignore": [ 0, [
"\\.path.js$"
] ]
}
}

1
.gitignore vendored

@ -7,6 +7,7 @@ _actual.js
coverage
.commithash
.idea
.eslintcache
test/_tmp
test/hooks/tmp
test/tmp

@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged

@ -1,6 +0,0 @@
{
"hooks": {
"pre-commit": "lint-staged",
"post-commit": "git reset"
}
}

@ -1,14 +0,0 @@
{
"{src,bin,browser,typings}/**/*.ts": [
"prettier --write",
"tslint --project . --fix"
],
"test/typescript/**/*.ts": [
"prettier --write",
"tslint --project test/typescript --fix"
],
"{test/test,test/*/index,test/utils,test/**/_config}.js": [
"prettier --write",
"eslint --fix"
]
}

@ -0,0 +1,5 @@
module.exports = {
'.ts': ['eslint --fix --cache'],
'!(test/**/*).js': ['eslint --fix --cache'],
'{test/*,test/*/*,test/*/samples/**/_config}.js': ['eslint --fix --cache']
};

@ -1,5 +1,8 @@
{
"typescript.format.insertSpaceBeforeFunctionParenthesis": true,
"typescript.format.insertSpaceAfterConstructor": true,
"typescript.format.enable": true
"typescript.format.enable": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}

@ -13,7 +13,7 @@
* Track "this" mutations for methods, getters and setters (#4018)
### Pull Requests
* [#4018](https://github.com/rollup/rollup/pull/4018): Class method effects (@lukastaegert)
* [#4018](https://github.com/rollup/rollup/pull/4018): Class method effects (@marijnh and @lukastaegert)
## 2.48.0
*2021-05-15*

@ -1,3 +1,6 @@
import sha256 from 'hash.js/lib/hash/sha/256';
export const createHash = () => sha256();
export const createHash = (): {
digest: (format: string) => string;
update: (data: unknown) => void;
} => sha256();

@ -1,6 +1,6 @@
import { error } from '../src/utils/error';
export const throwNoFileSystem = (method: string) => (..._args: any[]): never => {
export const throwNoFileSystem = (method: string) => (): never => {
error({
code: 'NO_FS_IN_BROWSER',
message: `Cannot access the file system (via "${method}") when using the browser build of Rollup. Make sure you supply a plugin with custom resolveId and load hooks to Rollup.`,

@ -1,24 +1,24 @@
export const absolutePath = /^(?:\/|(?:[A-Za-z]:)?[\\|/])/;
export const relativePath = /^\.?\.\//;
export function isAbsolute(path: string) {
export function isAbsolute(path: string): boolean {
return absolutePath.test(path);
}
export function isRelative(path: string) {
export function isRelative(path: string): boolean {
return relativePath.test(path);
}
export function normalize(path: string) {
export function normalize(path: string): string {
return path.replace(/\\/g, '/');
}
export function basename(path: string) {
return path.split(/(\/|\\)/).pop();
export function basename(path: string): string {
return path.split(/[/\\]/).pop() || '';
}
export function dirname(path: string) {
const match = /(\/|\\)[^/\\]*$/.exec(path);
export function dirname(path: string): string {
const match = /[/\\][^/\\]*$/.exec(path);
if (!match) return '.';
const dir = path.slice(0, -match[0].length);
@ -27,13 +27,13 @@ export function dirname(path: string) {
return dir ? dir : '/';
}
export function extname(path: string) {
export function extname(path: string): string {
const match = /\.[^.]+$/.exec(basename(path)!);
if (!match) return '';
return match[0];
}
export function relative(from: string, to: string) {
export function relative(from: string, to: string): string {
const fromParts = from.split(/[/\\]/).filter(Boolean);
const toParts = to.split(/[/\\]/).filter(Boolean);
@ -57,7 +57,7 @@ export function relative(from: string, to: string) {
return toParts.join('/');
}
export function resolve(...paths: string[]) {
export function resolve(...paths: string[]): string {
const firstPathSegment = paths.shift();
if (!firstPathSegment) {
return '/';
@ -77,7 +77,7 @@ export function resolve(...paths: string[]) {
}
}
resolvedParts.push.apply(resolvedParts, parts);
resolvedParts.push(...parts);
}
}

@ -1,4 +1,4 @@
import { CustomPluginOptions, Plugin, ResolvedId } from '../src/rollup/types';
import { CustomPluginOptions, Plugin, ResolvedId, ResolveIdResult } from '../src/rollup/types';
import { PluginDriver } from '../src/utils/PluginDriver';
import { resolveIdViaPlugins } from '../src/utils/resolveIdViaPlugins';
import { throwNoFileSystem } from './error';
@ -16,8 +16,15 @@ export async function resolveId(
) => Promise<ResolvedId | null>,
skip: { importer: string | undefined; plugin: Plugin; source: string }[] | null,
customOptions: CustomPluginOptions | undefined
) {
const pluginResult = await resolveIdViaPlugins(source, importer,pluginDriver, moduleLoaderResolveId, skip, customOptions);
): Promise<ResolveIdResult> {
const pluginResult = await resolveIdViaPlugins(
source,
importer,
pluginDriver,
moduleLoaderResolveId,
skip,
customOptions
);
if (pluginResult == null) {
throwNoFileSystem('path.resolve');
}

@ -2,15 +2,15 @@ import MagicString from 'magic-string';
export default function addCliEntry() {
return {
name: 'add-cli-entry',
buildStart() {
this.emitFile({
type: 'chunk',
id: 'cli/cli.ts',
fileName: 'bin/rollup',
preserveSignature: false
id: 'cli/cli.ts',
preserveSignature: false,
type: 'chunk'
});
},
name: 'add-cli-entry',
renderChunk(code, chunkInfo) {
if (chunkInfo.fileName === 'bin/rollup') {
const magicString = new MagicString(code);

@ -6,6 +6,11 @@ const REPLACEMENT = "require('../../../src/watch/fsevents-importer').getFsEvents
export default function conditionalFsEventsImport() {
let transformed = false;
return {
buildEnd(error) {
if (!(error || transformed)) {
throw new Error('Could not find "fsevents-handler.js", was the file renamed?');
}
},
name: 'conditional-fs-events-import',
transform(code, id) {
if (id.endsWith('fsevents-handler.js')) {
@ -22,11 +27,6 @@ export default function conditionalFsEventsImport() {
);
return { code: magicString.toString(), map: magicString.generateMap({ hires: true }) };
}
},
buildEnd(error) {
if (!(error || transformed)) {
throw new Error('Could not find "fsevents-handler.js", was the file renamed?');
}
}
};
}

@ -1,8 +1,8 @@
export default function emitModulePackageFile() {
return {
name: 'emit-module-package-file',
generateBundle() {
this.emitFile({ type: 'asset', fileName: 'package.json', source: `{"type":"module"}` });
}
this.emitFile({ fileName: 'package.json', source: `{"type":"module"}`, type: 'asset' });
},
name: 'emit-module-package-file'
};
}

@ -1,19 +1,19 @@
export default function addBinShebangAndEsmImport() {
let importFound = false;
return {
name: 'esm-dynamic-import',
renderDynamicImport({ moduleId }) {
importFound = true;
if (moduleId.endsWith('loadConfigFile.ts')) {
return { left: 'import(', right: ')' };
}
},
generateBundle() {
if (!importFound) {
throw new Error(
'Could not find dynamic import in "loadConfigFile.ts", was the file renamed?'
);
}
},
name: 'esm-dynamic-import',
renderDynamicImport({ moduleId }) {
importFound = true;
if (moduleId.endsWith('loadConfigFile.ts')) {
return { left: 'import(', right: ')' };
}
}
};
}

@ -11,7 +11,7 @@ if (process.env.FORCE_COLOR === '0' || process.env.NO_COLOR) {
// log to stderr to keep `rollup main.js > bundle.js` from breaking
export const stderr = console.error.bind(console);
export function handleError(err: RollupError, recover = false) {
export function handleError(err: RollupError, recover = false): void {
let description = err.message || err;
if (err.name) description = `${err.name}: ${description}`;
const message = (err.plugin ? `(plugin ${err.plugin}) ${description}` : description) || err;

@ -12,20 +12,12 @@ export interface BatchWarnings {
readonly warningOccurred: boolean;
}
export default function batchWarnings() {
export default function batchWarnings(): BatchWarnings {
let count = 0;
let deferredWarnings = new Map<keyof typeof deferredHandlers, RollupWarning[]>();
let warningOccurred = false;
return {
get count() {
return count;
},
get warningOccurred() {
return warningOccurred;
},
add: (warning: RollupWarning) => {
count += 1;
warningOccurred = true;
@ -52,6 +44,10 @@ export default function batchWarnings() {
}
},
get count() {
return count;
},
flush: () => {
if (count === 0) return;
@ -65,6 +61,10 @@ export default function batchWarnings() {
deferredWarnings = new Map();
count = 0;
},
get warningOccurred() {
return warningOccurred;
}
};
}
@ -72,11 +72,6 @@ export default function batchWarnings() {
const immediateHandlers: {
[code: string]: (warning: RollupWarning) => void;
} = {
UNKNOWN_OPTION: warning => {
title(`You have passed an unrecognized option`);
stderr(warning.message);
},
MISSING_NODE_BUILTINS: warning => {
title(`Missing shims for Node.js built-ins`);
@ -85,6 +80,11 @@ const immediateHandlers: {
warning.modules!
)}. You might need to include https://github.com/ionic-team/rollup-plugin-node-polyfills`
);
},
UNKNOWN_OPTION: warning => {
title(`You have passed an unrecognized option`);
stderr(warning.message);
}
};

@ -3,7 +3,10 @@ import { InputOptions } from '../../src/rollup/types';
import { stdinPlugin } from './stdin';
import { waitForInputPlugin } from './waitForInput';
export function addCommandPluginsToInputOptions(inputOptions: InputOptions, command: any) {
export function addCommandPluginsToInputOptions(
inputOptions: InputOptions,
command: Record<string, unknown>
): void {
if (command.stdin !== false) {
inputOptions.plugins!.push(stdinPlugin(command.stdin));
}
@ -34,7 +37,7 @@ function loadAndRegisterPlugin(inputOptions: InputOptions, pluginText: string) {
// -p "{transform(c,i){...}}"
plugin = new Function('return ' + pluginText);
} else {
const match = pluginText.match(/^([@.\/\\\w|^{}-]+)(=(.*))?$/);
const match = pluginText.match(/^([@./\\\w|^{}-]+)(=(.*))?$/);
if (match) {
// -p plugin
// -p plugin=arg
@ -43,7 +46,7 @@ function loadAndRegisterPlugin(inputOptions: InputOptions, pluginText: string) {
} else {
throw new Error(`Invalid --plugin argument format: ${JSON.stringify(pluginText)}`);
}
if (!/^\.|^rollup-plugin-|[@\/\\]/.test(pluginText)) {
if (!/^\.|^rollup-plugin-|[@/\\]/.test(pluginText)) {
// Try using plugin prefix variations first if applicable.
// Prefix order is significant - left has higher precedence.
for (const prefix of ['@rollup/plugin-', 'rollup-plugin-']) {

@ -8,7 +8,7 @@ import { getConfigPath } from './getConfigPath';
import loadAndParseConfigFile from './loadConfigFile';
import loadConfigFromCommand from './loadConfigFromCommand';
export default async function runRollup(command: any) {
export default async function runRollup(command: Record<string, any>): Promise<void> {
let inputSource;
if (command._.length > 0) {
if (command.input) {

@ -1,7 +1,7 @@
import { bold } from 'colorette';
import * as fs from 'fs';
import * as path from 'path';
import { pathToFileURL } from 'url';
import { bold } from 'colorette';
import * as rollup from '../../src/node-entry';
import { MergedRollupOptions } from '../../src/rollup/types';
import { error } from '../../src/utils/error';
@ -86,7 +86,7 @@ async function getDefaultFromTranspiledConfigFile(
return `'${pathToFileURL(moduleId).href}'`;
}
if (property == null) {
return `{url:'${pathToFileURL(moduleId).href}'}`
return `{url:'${pathToFileURL(moduleId).href}'}`;
}
}
}

@ -5,7 +5,7 @@ import { addCommandPluginsToInputOptions } from './commandPlugins';
import { stdinName } from './stdin';
export default function loadConfigFromCommand(
command: any
command: Record<string, any>
): { options: MergedRollupOptions[]; warnings: BatchWarnings } {
const warnings = batchWarnings();
if (!command.input && (command.stdin || !process.stdin.isTTY)) {

@ -6,7 +6,7 @@ const CLEAR_SCREEN = '\u001Bc';
export function getResetScreen(
configs: MergedRollupOptions[],
allowClearScreen: boolean | undefined
) {
): (heading: string) => void {
let clearScreen = allowClearScreen;
for (const config of configs) {
if (config.watch && config.watch.clearScreen === false) {

@ -4,19 +4,19 @@ export const stdinName = '-';
let stdinResult: Promise<string> | null = null;
export function stdinPlugin(arg: any): Plugin {
export function stdinPlugin(arg: unknown): Plugin {
const suffix = typeof arg == 'string' && arg.length ? '.' + arg : '';
return {
load(id) {
if (id === stdinName || id.startsWith(stdinName + '.')) {
return stdinResult || (stdinResult = readStdin());
}
},
name: 'stdin',
resolveId(id) {
if (id === stdinName) {
return id + suffix;
}
},
load(id) {
if (id === stdinName || id.startsWith(stdinName + '.')) {
return stdinResult || (stdinResult = readStdin());
}
}
};
}

@ -2,7 +2,7 @@ import { bold, underline } from 'colorette';
import prettyBytes from 'pretty-bytes';
import { SerializedTimings } from '../../src/rollup/types';
export function printTimings(timings: SerializedTimings) {
export function printTimings(timings: SerializedTimings): void {
Object.keys(timings).forEach(label => {
const appliedColor =
label[0] === '#' ? (label[1] !== '#' ? underline : bold) : (text: string) => text;

@ -1,10 +1,10 @@
import { bold } from 'colorette';
import { NormalizedInputOptions, PluginContext } from '../../src/rollup/types';
import { PluginContext } from 'rollup';
import { NormalizedInputOptions, Plugin } from '../../src/rollup/types';
import { stderr } from '../logging';
export function waitForInputPlugin() {
export function waitForInputPlugin(): Plugin {
return {
name: 'wait-for-input',
async buildStart(this: PluginContext, options: NormalizedInputOptions) {
const inputSpecifiers = Array.isArray(options.input)
? options.input
@ -24,6 +24,7 @@ export function waitForInputPlugin() {
}
break;
}
}
},
name: 'wait-for-input'
};
}

@ -1,7 +1,7 @@
import fs from 'fs';
import chokidar from 'chokidar';
import { bold, cyan, green, underline } from 'colorette';
import dateTime from 'date-time';
import fs from 'fs';
import ms from 'pretty-ms';
import onExit from 'signal-exit';
import * as rollup from '../../src/node-entry';
@ -15,7 +15,7 @@ import loadConfigFromCommand from './loadConfigFromCommand';
import { getResetScreen } from './resetScreen';
import { printTimings } from './timings';
export async function watch(command: any) {
export async function watch(command: Record<string, any>): Promise<void> {
process.env.ROLLUP_WATCH = 'true';
const isTTY = process.stderr.isTTY;
const silent = command.silent;
@ -32,7 +32,7 @@ export async function watch(command: any) {
process.stdin.resume();
}
if (configFile) {
async function loadConfigFromFileAndTrack(configFile: string) {
let reloadingConfig = false;
let aborted = false;
let configFileData: string | null = null;
@ -42,7 +42,7 @@ export async function watch(command: any) {
async function reloadConfigFile() {
try {
const newConfigFileData = fs.readFileSync(configFile!, 'utf-8');
const newConfigFileData = fs.readFileSync(configFile, 'utf-8');
if (newConfigFileData === configFileData) {
return;
}
@ -55,7 +55,7 @@ export async function watch(command: any) {
}
configFileData = newConfigFileData;
reloadingConfig = true;
({ options: configs, warnings } = await loadAndParseConfigFile(configFile!, command));
({ options: configs, warnings } = await loadAndParseConfigFile(configFile, command));
reloadingConfig = false;
if (aborted) {
aborted = false;
@ -72,12 +72,15 @@ export async function watch(command: any) {
handleError(err, true);
}
}
}
if (configFile) {
await loadConfigFromFileAndTrack(configFile);
} else {
({ options: configs, warnings } = await loadConfigFromCommand(command));
start(configs);
}
// tslint:disable-next-line:no-unnecessary-type-assertion
const resetScreen = getResetScreen(configs!, isTTY);
function start(configs: MergedRollupOptions[]) {

643
package-lock.json generated

@ -318,9 +318,9 @@
}
},
"@eslint/eslintrc": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.0.tgz",
"integrity": "sha512-2ZPCc+uNbjV5ERJr+aKSPRwZgKd2z11x0EgLvb1PURmUrn9QNRXFqje0Ldq454PfAVyaJYyrDvvIKSFP4NnBog==",
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.1.tgz",
"integrity": "sha512-5v7TDE9plVhvxQeWLXDTvFvJBdH6pEsdnl2g/dAptmuFEPedQ4Erq5rsDsX+mvAM610IhNaO2W5V1dOOnDKxkQ==",
"dev": true,
"requires": {
"ajv": "^6.12.4",
@ -342,6 +342,12 @@
"requires": {
"type-fest": "^0.8.1"
}
},
"ignore": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz",
"integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==",
"dev": true
}
}
},
@ -427,6 +433,32 @@
"integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==",
"dev": true
},
"@nodelib/fs.scandir": {
"version": "2.1.4",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.4.tgz",
"integrity": "sha512-33g3pMJk3bg5nXbL/+CY6I2eJDzZAni49PfJnL5fghPTggPvBd/pFNSgJsdAgWptuFu7qq/ERvOYFlhvsLTCKA==",
"dev": true,
"requires": {
"@nodelib/fs.stat": "2.0.4",
"run-parallel": "^1.1.9"
}
},
"@nodelib/fs.stat": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.4.tgz",
"integrity": "sha512-IYlHJA0clt2+Vg7bccq+TzRdJvv19c2INqBSsoOLp1je7xjtr7J26+WXR72MCdvU9q1qTzIWDfhMf+DRvQJK4Q==",
"dev": true
},
"@nodelib/fs.walk": {
"version": "1.2.6",
"resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.6.tgz",
"integrity": "sha512-8Broas6vTtW4GIXTAHDoE32hnN2M5ykgCpWGbuXHQ15vEMqr23pB76e/GZcYsZCHALv50ktd24qhEyKr6wBtow==",
"dev": true,
"requires": {
"@nodelib/fs.scandir": "2.1.4",
"fastq": "^1.6.0"
}
},
"@rollup/plugin-alias": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/@rollup/plugin-alias/-/plugin-alias-3.1.2.tgz",
@ -563,6 +595,12 @@
"@types/node": "*"
}
},
"@types/json-schema": {
"version": "7.0.7",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.7.tgz",
"integrity": "sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA==",
"dev": true
},
"@types/json5": {
"version": "0.0.29",
"resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz",
@ -633,6 +671,123 @@
"integrity": "sha512-37RSHht+gzzgYeobbG+KWryeAW8J33Nhr69cjTqSYymXVZEN9NbRYWoYlRtDhHKPVT1FyNKwaTPC1NynKZpzRA==",
"dev": true
},
"@typescript-eslint/eslint-plugin": {
"version": "4.24.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.24.0.tgz",
"integrity": "sha512-qbCgkPM7DWTsYQGjx9RTuQGswi+bEt0isqDBeo+CKV0953zqI0Tp7CZ7Fi9ipgFA6mcQqF4NOVNwS/f2r6xShw==",
"dev": true,
"requires": {
"@typescript-eslint/experimental-utils": "4.24.0",
"@typescript-eslint/scope-manager": "4.24.0",
"debug": "^4.1.1",
"functional-red-black-tree": "^1.0.1",
"lodash": "^4.17.15",
"regexpp": "^3.0.0",
"semver": "^7.3.2",
"tsutils": "^3.17.1"
},
"dependencies": {
"tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
"dev": true
},
"tsutils": {
"version": "3.21.0",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
"integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
"dev": true,
"requires": {
"tslib": "^1.8.1"
}
}
}
},
"@typescript-eslint/experimental-utils": {
"version": "4.24.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.24.0.tgz",
"integrity": "sha512-IwTT2VNDKH1h8RZseMH4CcYBz6lTvRoOLDuuqNZZoThvfHEhOiZPQCow+5El3PtyxJ1iDr6UXZwYtE3yZQjhcw==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.3",
"@typescript-eslint/scope-manager": "4.24.0",
"@typescript-eslint/types": "4.24.0",
"@typescript-eslint/typescript-estree": "4.24.0",
"eslint-scope": "^5.0.0",
"eslint-utils": "^2.0.0"
}
},
"@typescript-eslint/parser": {
"version": "4.24.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.24.0.tgz",
"integrity": "sha512-dj1ZIh/4QKeECLb2f/QjRwMmDArcwc2WorWPRlB8UNTZlY1KpTVsbX7e3ZZdphfRw29aTFUSNuGB8w9X5sS97w==",
"dev": true,
"requires": {
"@typescript-eslint/scope-manager": "4.24.0",
"@typescript-eslint/types": "4.24.0",
"@typescript-eslint/typescript-estree": "4.24.0",
"debug": "^4.1.1"
}
},
"@typescript-eslint/scope-manager": {
"version": "4.24.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.24.0.tgz",
"integrity": "sha512-9+WYJGDnuC9VtYLqBhcSuM7du75fyCS/ypC8c5g7Sdw7pGL4NDTbeH38eJPfzIydCHZDoOgjloxSAA3+4l/zsA==",
"dev": true,
"requires": {
"@typescript-eslint/types": "4.24.0",
"@typescript-eslint/visitor-keys": "4.24.0"
}
},
"@typescript-eslint/types": {
"version": "4.24.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.24.0.tgz",
"integrity": "sha512-tkZUBgDQKdvfs8L47LaqxojKDE+mIUmOzdz7r+u+U54l3GDkTpEbQ1Jp3cNqqAU9vMUCBA1fitsIhm7yN0vx9Q==",
"dev": true
},
"@typescript-eslint/typescript-estree": {
"version": "4.24.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.24.0.tgz",
"integrity": "sha512-kBDitL/by/HK7g8CYLT7aKpAwlR8doshfWz8d71j97n5kUa5caHWvY0RvEUEanL/EqBJoANev8Xc/mQ6LLwXGA==",
"dev": true,
"requires": {
"@typescript-eslint/types": "4.24.0",
"@typescript-eslint/visitor-keys": "4.24.0",
"debug": "^4.1.1",
"globby": "^11.0.1",
"is-glob": "^4.0.1",
"semver": "^7.3.2",
"tsutils": "^3.17.1"
},
"dependencies": {
"tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
"dev": true
},
"tsutils": {
"version": "3.21.0",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
"integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
"dev": true,
"requires": {
"tslib": "^1.8.1"
}
}
}
},
"@typescript-eslint/visitor-keys": {
"version": "4.24.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.24.0.tgz",
"integrity": "sha512-4ox1sjmGHIxjEDBnMCtWFFhErXtKA1Ec0sBpuz0fqf3P+g3JFGyTxxbF06byw0FRsPnnbq44cKivH7Ks1/0s6g==",
"dev": true,
"requires": {
"@typescript-eslint/types": "4.24.0",
"eslint-visitor-keys": "^2.0.0"
}
},
"@ungap/promise-all-settled": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz",
@ -776,6 +931,12 @@
"is-string": "^1.0.5"
}
},
"array-union": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz",
"integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==",
"dev": true
},
"array.prototype.flat": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.4.tgz",
@ -1064,10 +1225,25 @@
"dev": true
},
"contains-path": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz",
"integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=",
"dev": true
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/contains-path/-/contains-path-1.0.0.tgz",
"integrity": "sha1-NFizMhhWA+ju0Y9RjUoQiIo6vJE=",
"dev": true,
"requires": {
"normalize-path": "^2.1.1",
"path-starts-with": "^1.0.0"
},
"dependencies": {
"normalize-path": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz",
"integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=",
"dev": true,
"requires": {
"remove-trailing-separator": "^1.0.1"
}
}
}
},
"convert-source-map": {
"version": "1.7.0",
@ -1216,6 +1392,23 @@
"integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==",
"dev": true
},
"dir-glob": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
"integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==",
"dev": true,
"requires": {
"path-type": "^4.0.0"
},
"dependencies": {
"path-type": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz",
"integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==",
"dev": true
}
}
},
"doctrine": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz",
@ -1342,13 +1535,13 @@
"dev": true
},
"eslint": {
"version": "7.25.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-7.25.0.tgz",
"integrity": "sha512-TVpSovpvCNpLURIScDRB6g5CYu/ZFq9GfX2hLNIV4dSBKxIWojeDODvYl3t0k0VtMxYeR8OXPCFE5+oHMlGfhw==",
"version": "7.26.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-7.26.0.tgz",
"integrity": "sha512-4R1ieRf52/izcZE7AlLy56uIHHDLT74Yzz2Iv2l6kDaYvEu9x+wMB5dZArVL8SYGXSYV2YAg70FcW5Y5nGGNIg==",
"dev": true,
"requires": {
"@babel/code-frame": "7.12.11",
"@eslint/eslintrc": "^0.4.0",
"@eslint/eslintrc": "^0.4.1",
"ajv": "^6.10.0",
"chalk": "^4.0.0",
"cross-spawn": "^7.0.2",
@ -1426,6 +1619,12 @@
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true
},
"ignore": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz",
"integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==",
"dev": true
},
"supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
@ -1437,6 +1636,12 @@
}
}
},
"eslint-config-prettier": {
"version": "8.3.0",
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.3.0.tgz",
"integrity": "sha512-BgZuLUSeKzvlL/VUjx/Yb787VQ26RU3gGjA3iiFvdsp/2bMfVIWUVP7tjxtjS0e+HP409cPlPvNkQloz8C91ew==",
"dev": true
},
"eslint-import-resolver-node": {
"version": "0.3.4",
"resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.4.tgz",
@ -1465,50 +1670,47 @@
}
},
"eslint-module-utils": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.6.0.tgz",
"integrity": "sha512-6j9xxegbqe8/kZY8cYpcp0xhbK0EgJlg3g9mib3/miLaExuuwc3n5UEfSnU6hWMbT0FAYVvDbL9RrRgpUeQIvA==",
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.6.1.tgz",
"integrity": "sha512-ZXI9B8cxAJIH4nfkhTwcRTEAnrVfobYqwjWy/QMCZ8rHkZHFjf9yO4BzpiF9kCSfNlMG54eKigISHpX0+AaT4A==",
"dev": true,
"requires": {
"debug": "^2.6.9",
"debug": "^3.2.7",
"pkg-dir": "^2.0.0"
},
"dependencies": {
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"version": "3.2.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
"integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
"dev": true,
"requires": {
"ms": "2.0.0"
"ms": "^2.1.1"
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
"dev": true
}
}
},
"eslint-plugin-import": {
"version": "2.22.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.22.1.tgz",
"integrity": "sha512-8K7JjINHOpH64ozkAhpT3sd+FswIZTfMZTjdx052pnWrgRCVfp8op9tbjpAk3DdUeI/Ba4C8OjdC0r90erHEOw==",
"version": "2.23.2",
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.23.2.tgz",
"integrity": "sha512-LmNoRptHBxOP+nb0PIKz1y6OSzCJlB+0g0IGS3XV4KaKk2q4szqQ6s6F1utVf5ZRkxk/QOTjdxe7v4VjS99Bsg==",
"dev": true,
"requires": {
"array-includes": "^3.1.1",
"array.prototype.flat": "^1.2.3",
"contains-path": "^0.1.0",
"array-includes": "^3.1.3",
"array.prototype.flat": "^1.2.4",
"contains-path": "^1.0.0",
"debug": "^2.6.9",
"doctrine": "1.5.0",
"doctrine": "^2.1.0",
"eslint-import-resolver-node": "^0.3.4",
"eslint-module-utils": "^2.6.0",
"eslint-module-utils": "^2.6.1",
"find-up": "^2.0.0",
"has": "^1.0.3",
"is-core-module": "^2.4.0",
"minimatch": "^3.0.4",
"object.values": "^1.1.1",
"read-pkg-up": "^2.0.0",
"resolve": "^1.17.0",
"object.values": "^1.1.3",
"pkg-up": "^2.0.0",
"read-pkg-up": "^3.0.0",
"resolve": "^1.20.0",
"tsconfig-paths": "^3.9.0"
},
"dependencies": {
@ -1522,13 +1724,21 @@
}
},
"doctrine": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz",
"integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=",
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz",
"integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==",
"dev": true,
"requires": {
"esutils": "^2.0.2"
}
},
"is-core-module": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.4.0.tgz",
"integrity": "sha512-6A2fkfq1rfeQZjxrZJGerpLCTHRNEBiSgnu0+obeJpEPZRUooHgsizvzv0ZjJwOz3iWIHdJtVWJ/tmPr3D21/A==",
"dev": true,
"requires": {
"esutils": "^2.0.2",
"isarray": "^1.0.0"
"has": "^1.0.3"
}
},
"ms": {
@ -1539,6 +1749,15 @@
}
}
},
"eslint-plugin-prettier": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.4.0.tgz",
"integrity": "sha512-UDK6rJT6INSfcOo545jiaOwB701uAIt2/dR7WnFQoGCVl1/EMqdANBmwUaqqQ45aXprsTGzSa39LI1PyuRBxxw==",
"dev": true,
"requires": {
"prettier-linter-helpers": "^1.0.0"
}
},
"eslint-scope": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz",
@ -1678,6 +1897,26 @@
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
"dev": true
},
"fast-diff": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz",
"integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==",
"dev": true
},
"fast-glob": {
"version": "3.2.5",
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.5.tgz",
"integrity": "sha512-2DtFcgT68wiTTiwZ2hNdJfcHNke9XOfnwmBRWXhmeKM8rF0TGwmC/Qto3S7RoZKp5cilZbxzO5iTNTQsJ+EeDg==",
"dev": true,
"requires": {
"@nodelib/fs.stat": "^2.0.2",
"@nodelib/fs.walk": "^1.2.3",
"glob-parent": "^5.1.0",
"merge2": "^1.3.0",
"micromatch": "^4.0.2",
"picomatch": "^2.2.1"
}
},
"fast-json-stable-stringify": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
@ -1690,6 +1929,15 @@
"integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=",
"dev": true
},
"fastq": {
"version": "1.11.0",
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.11.0.tgz",
"integrity": "sha512-7Eczs8gIPDrVzT+EksYBcupqMyxSHXXrHOLRRxU2/DicV8789MRBRR8+Hc2uWzUupOs4YS4JzBmBxjjCVBxD/g==",
"dev": true,
"requires": {
"reusify": "^1.0.4"
}
},
"figures": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz",
@ -1986,6 +2234,20 @@
}
}
},
"globby": {
"version": "11.0.3",
"resolved": "https://registry.npmjs.org/globby/-/globby-11.0.3.tgz",
"integrity": "sha512-ffdmosjA807y7+lA1NM0jELARVmYul/715xiILEjo3hBLPTcirgQNnXECn5g3mtR8TOLCVbkfua1Hpen25/Xcg==",
"dev": true,
"requires": {
"array-union": "^2.1.0",
"dir-glob": "^3.0.1",
"fast-glob": "^3.1.1",
"ignore": "^5.1.4",
"merge2": "^1.3.0",
"slash": "^3.0.0"
}
},
"graceful-fs": {
"version": "4.2.6",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz",
@ -2051,14 +2313,6 @@
"integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==",
"dev": true
},
"hosted-git-info": {
"version": "3.0.8",
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-3.0.8.tgz",
"integrity": "sha512-aXpmwoOhRBrw6X3j0h5RloK4x1OzsxMPyxqIHyNfSe2pypkVTZFpEiRoSipPEPlMrh0HW/XsjkJ5WgnCirpNUw==",
"requires": {
"lru-cache": "^6.0.0"
}
},
"html-escaper": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz",
@ -2078,9 +2332,9 @@
"dev": true
},
"ignore": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz",
"integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==",
"version": "5.1.8",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz",
"integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==",
"dev": true
},
"import-fresh": {
@ -2155,12 +2409,12 @@
}
},
"is-boolean-object": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.0.tgz",
"integrity": "sha512-a7Uprx8UtD+HWdyYwnD1+ExtTgqQtD2k/1yJgtXP6wnMm8byhkoTZRl+95LLThpzNZJ5aEvi46cdH+ayMFRwmA==",
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.1.tgz",
"integrity": "sha512-bXdQWkECBUIAcCkeH1unwJLIpZYaa5VvuygSyS/c2lf719mTKZDU5UdDRlpd01UjADgmW8RfqaP+mRaVPdr/Ng==",
"dev": true,
"requires": {
"call-bind": "^1.0.0"
"call-bind": "^1.0.2"
}
},
"is-callable": {
@ -2179,9 +2433,9 @@
}
},
"is-date-object": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.3.tgz",
"integrity": "sha512-tDpEUInNcy2Yw3lNSepK3Wdw1RnXLcIVienz6Ou631Acl15cJyRWK4dgA1vCmOEgIbtOV0W7MHg+AR2Gdg1NXQ==",
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.4.tgz",
"integrity": "sha512-/b4ZVsG7Z5XVtIxs/h9W8nvfLgSAyKYdtGWQLbqy6jA1icmgjf8WCoTKgeS4wy5tYaPePouzFMANbnj94c2Z+A==",
"dev": true
},
"is-extglob": {
@ -2224,9 +2478,9 @@
"dev": true
},
"is-number-object": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.4.tgz",
"integrity": "sha512-zohwelOAur+5uXtk8O3GPQ1eAcu4ZX3UwxQhUlfFFMNpUd83gXgjbhJh6HmB6LUNV/ieOLQuDwJO3dWJosUeMw==",
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.5.tgz",
"integrity": "sha512-RU0lI/n95pMoUKu9v1BZP5MBcZuNSVJkMkAG2dJqC4z2GlkGUNeH68SuHuBKBD/XFe+LHZ+f9BKkLET60Niedw==",
"dev": true
},
"is-obj": {
@ -2250,13 +2504,13 @@
}
},
"is-regex": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.2.tgz",
"integrity": "sha512-axvdhb5pdhEVThqJzYXwMlVuZwC+FF2DpcOhTS+y/8jVq4trxyPgfcwIxIKiyeuLlSQYKkmUaPQJ8ZE4yNKXDg==",
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.3.tgz",
"integrity": "sha512-qSVXFz28HM7y+IWX6vLCsexdlvzT1PJNFSBuaQLQ5o0IEw8UDYW6/2+eCMVyIsbM8CNLX2a/QWmSpyxYEHY7CQ==",
"dev": true,
"requires": {
"call-bind": "^1.0.2",
"has-symbols": "^1.0.1"
"has-symbols": "^1.0.2"
}
},
"is-regexp": {
@ -2272,18 +2526,18 @@
"dev": true
},
"is-string": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.5.tgz",
"integrity": "sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ==",
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.6.tgz",
"integrity": "sha512-2gdzbKUuqtQ3lYNrUTQYoClPhm7oQu4UdpSZMp1/DGgkHBT8E2Z1l0yMdb6D4zNAxwDiMv8MdulKROJGNl0Q0w==",
"dev": true
},
"is-symbol": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz",
"integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==",
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.4.tgz",
"integrity": "sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==",
"dev": true,
"requires": {
"has-symbols": "^1.0.1"
"has-symbols": "^1.0.2"
}
},
"is-typedarray": {
@ -2304,12 +2558,6 @@
"integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==",
"dev": true
},
"isarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=",
"dev": true
},
"isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
@ -2484,6 +2732,12 @@
"integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=",
"dev": true
},
"json-parse-better-errors": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz",
"integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==",
"dev": true
},
"json-parse-even-better-errors": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz",
@ -2726,14 +2980,14 @@
}
},
"load-json-file": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz",
"integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=",
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz",
"integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=",
"dev": true,
"requires": {
"graceful-fs": "^4.1.2",
"parse-json": "^2.2.0",
"pify": "^2.0.0",
"parse-json": "^4.0.0",
"pify": "^3.0.0",
"strip-bom": "^3.0.0"
}
},
@ -2903,6 +3157,7 @@
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
"dev": true,
"requires": {
"yallist": "^4.0.0"
}
@ -3042,6 +3297,12 @@
"integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==",
"dev": true
},
"merge2": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz",
"integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==",
"dev": true
},
"micromatch": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz",
@ -3336,12 +3597,18 @@
"integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==",
"dev": true,
"requires": {
"hosted-git-info": "^3.0.8",
"hosted-git-info": "^2.1.4",
"resolve": "^1.10.0",
"semver": "2 || 3 || 4 || 5",
"validate-npm-package-license": "^3.0.1"
},
"dependencies": {
"hosted-git-info": {
"version": "2.8.9",
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz",
"integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==",
"dev": true
},
"semver": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
@ -3560,9 +3827,9 @@
}
},
"object-inspect": {
"version": "1.10.2",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.10.2.tgz",
"integrity": "sha512-gz58rdPpadwztRrPjZE9DZLOABUpTGdcANUgOwBFO1C+HZZhePoP83M65WGDmbpwFYJSWqavbl4SgDn4k8RYTA==",
"version": "1.10.3",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.10.3.tgz",
"integrity": "sha512-e5mCJlSH7poANfC8z8S9s9S2IN5/4Zb3aZ33f5s8YqoazCFzNLloLU8r5VCG+G7WoqLvAAZoVMcy3tp/3X0Plw==",
"dev": true
},
"object-keys": {
@ -3688,12 +3955,13 @@
}
},
"parse-json": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz",
"integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=",
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz",
"integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=",
"dev": true,
"requires": {
"error-ex": "^1.2.0"
"error-ex": "^1.3.1",
"json-parse-better-errors": "^1.0.1"
}
},
"parse-ms": {
@ -3726,13 +3994,33 @@
"integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==",
"dev": true
},
"path-starts-with": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/path-starts-with/-/path-starts-with-1.0.0.tgz",
"integrity": "sha1-soJDAV6LE43lcmgqxS2kLmRq2E4=",
"dev": true,
"requires": {
"normalize-path": "^2.1.1"
},
"dependencies": {
"normalize-path": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz",
"integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=",
"dev": true,
"requires": {
"remove-trailing-separator": "^1.0.1"
}
}
}
},
"path-type": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz",
"integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=",
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz",
"integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==",
"dev": true,
"requires": {
"pify": "^2.0.0"
"pify": "^3.0.0"
}
},
"picomatch": {
@ -3742,9 +4030,9 @@
"dev": true
},
"pify": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz",
"integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=",
"dev": true
},
"pinst": {
@ -3765,6 +4053,15 @@
"find-up": "^2.1.0"
}
},
"pkg-up": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/pkg-up/-/pkg-up-2.0.0.tgz",
"integrity": "sha1-yBmscoBZpGHKscOImivjxJoATX8=",
"dev": true,
"requires": {
"find-up": "^2.1.0"
}
},
"please-upgrade-node": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz",
@ -3786,6 +4083,15 @@
"integrity": "sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==",
"dev": true
},
"prettier-linter-helpers": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz",
"integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==",
"dev": true,
"requires": {
"fast-diff": "^1.1.2"
}
},
"pretty-bytes": {
"version": "5.6.0",
"resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.6.0.tgz",
@ -3832,6 +4138,12 @@
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==",
"dev": true
},
"queue-microtask": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
"integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==",
"dev": true
},
"randombytes": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
@ -3862,24 +4174,24 @@
}
},
"read-pkg": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz",
"integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=",
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz",
"integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=",
"dev": true,
"requires": {
"load-json-file": "^2.0.0",
"load-json-file": "^4.0.0",
"normalize-package-data": "^2.3.2",
"path-type": "^2.0.0"
"path-type": "^3.0.0"
}
},
"read-pkg-up": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz",
"integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=",
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-3.0.0.tgz",
"integrity": "sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc=",
"dev": true,
"requires": {
"find-up": "^2.0.0",
"read-pkg": "^2.0.0"
"read-pkg": "^3.0.0"
}
},
"readdirp": {
@ -3959,6 +4271,12 @@
"es6-error": "^4.0.1"
}
},
"remove-trailing-separator": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz",
"integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=",
"dev": true
},
"require-directory": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
@ -4015,6 +4333,12 @@
"signal-exit": "^3.0.2"
}
},
"reusify": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz",
"integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==",
"dev": true
},
"rimraf": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz",
@ -4131,6 +4455,15 @@
}
}
},
"run-parallel": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
"integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==",
"dev": true,
"requires": {
"queue-microtask": "^1.2.2"
}
},
"rxjs": {
"version": "6.6.7",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz",
@ -4520,9 +4853,9 @@
"dev": true
},
"table": {
"version": "6.7.0",
"resolved": "https://registry.npmjs.org/table/-/table-6.7.0.tgz",
"integrity": "sha512-SAM+5p6V99gYiiy2gT5ArdzgM1dLDed0nkrWmG6Fry/bUS/m9x83BwpJUOf1Qj/x2qJd+thL6IkIx7qPGRxqBw==",
"version": "6.7.1",
"resolved": "https://registry.npmjs.org/table/-/table-6.7.1.tgz",
"integrity": "sha512-ZGum47Yi6KOOFDE8m223td53ath2enHcYLgOCjGr5ngu8bdIARQk6mN/wRMv4yMRcHnCSnHbCEha4sobQx5yWg==",
"dev": true,
"requires": {
"ajv": "^8.0.1",
@ -4534,9 +4867,9 @@
},
"dependencies": {
"ajv": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.2.0.tgz",
"integrity": "sha512-WSNGFuyWd//XO8n/m/EaOlNLtO0yL8EXT/74LqT4khdhpZjP7lkj/kT5uwRmGitKEVp/Oj7ZUHeGfPtgHhQ5CA==",
"version": "8.4.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.4.0.tgz",
"integrity": "sha512-7QD2l6+KBSLwf+7MuYocbWvRPdOu63/trReTLu2KFwkgctnub1auoF+Y1WYcm09CTM7quuscrzqmASaLHC/K4Q==",
"dev": true,
"requires": {
"fast-deep-equal": "^3.1.1",
@ -4634,85 +4967,6 @@
"integrity": "sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w==",
"dev": true
},
"tslint": {
"version": "6.1.3",
"resolved": "https://registry.npmjs.org/tslint/-/tslint-6.1.3.tgz",
"integrity": "sha512-IbR4nkT96EQOvKE2PW/djGz8iGNeJ4rF2mBfiYaR/nvUWYKJhLwimoJKgjIFEIDibBtOevj7BqCRL4oHeWWUCg==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.0.0",
"builtin-modules": "^1.1.1",
"chalk": "^2.3.0",
"commander": "^2.12.1",
"diff": "^4.0.1",
"glob": "^7.1.1",
"js-yaml": "^3.13.1",
"minimatch": "^3.0.4",
"mkdirp": "^0.5.3",
"resolve": "^1.3.2",
"semver": "^5.3.0",
"tslib": "^1.13.0",
"tsutils": "^2.29.0"
},
"dependencies": {
"builtin-modules": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz",
"integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=",
"dev": true
},
"commander": {
"version": "2.20.3",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
"dev": true
},
"diff": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
"integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
"dev": true
},
"mkdirp": {
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
"integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
"dev": true,
"requires": {
"minimist": "^1.2.5"
}
},
"semver": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
"dev": true
},
"tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
"dev": true
}
}
},
"tsutils": {
"version": "2.29.0",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz",
"integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==",
"dev": true,
"requires": {
"tslib": "^1.8.1"
},
"dependencies": {
"tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
"dev": true
}
}
},
"type-check": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
@ -4995,7 +5249,8 @@
"yallist": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
"dev": true
},
"yaml": {
"version": "1.10.2",

@ -16,17 +16,15 @@
"ci:test": "npm run build:cjs && npm run build:bootstrap && npm run test:all",
"ci:test:only": "npm run build:cjs && npm run build:bootstrap && npm run test:only",
"ci:coverage": "npm run build:cjs && nyc --reporter lcovonly mocha",
"lint": "npm run lint:ts -- --fix && npm run lint:js -- --fix && npm run lint:markdown",
"lint:nofix": "npm run lint:ts && npm run lint:js && npm run lint:markdown",
"lint:ts": "tslint --project .",
"lint:js": "eslint test/test.js test/*/index.js test/utils.js test/**/_config.js",
"lint": "npx eslint . --fix --cache && npm run lint:markdown",
"lint:nofix": "npx eslint . && npm run lint:markdown",
"lint:markdown": "markdownlint --config markdownlint.json docs/**/*.md",
"perf": "npm run build:cjs && node --expose-gc scripts/perf.js",
"perf:debug": "node --inspect-brk scripts/perf-debug.js",
"perf:init": "node scripts/perf-init.js",
"postinstall": "husky install",
"postpublish": "pinst --enable && git push && git push --tags",
"prepare": "npm run build",
"prepare": "husky install && npm run build",
"prepublishOnly": "pinst --disable && npm ci && npm run lint:nofix && npm run security && npm run build:bootstrap && npm run test:all",
"security": "npm audit",
"test": "npm run build && npm run test:all",
@ -71,6 +69,8 @@
"@types/require-relative": "^0.8.0",
"@types/signal-exit": "^3.0.0",
"@types/yargs-parser": "^20.2.0",
"@typescript-eslint/eslint-plugin": "^4.24.0",
"@typescript-eslint/parser": "^4.24.0",
"acorn": "^8.2.4",
"acorn-jsx": "^5.3.1",
"acorn-walk": "^8.1.0",
@ -81,8 +81,10 @@
"date-time": "^4.0.0",
"es5-shim": "^4.5.15",
"es6-shim": "^0.35.6",
"eslint": "^7.25.0",
"eslint-plugin-import": "^2.22.1",
"eslint": "^7.26.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.23.2",
"eslint-plugin-prettier": "^3.4.0",
"execa": "^5.0.0",
"fixturify": "^2.1.1",
"hash.js": "^1.1.7",
@ -117,7 +119,6 @@
"systemjs": "^6.8.3",
"terser": "^5.7.0",
"tslib": "^2.2.0",
"tslint": "^6.1.3",
"typescript": "^4.2.4",
"weak-napi": "^2.0.2",
"yargs-parser": "^20.2.7"

@ -1,9 +1,9 @@
import fs from 'fs';
import path from 'path';
import alias from '@rollup/plugin-alias';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import resolve from '@rollup/plugin-node-resolve';
import fs from 'fs';
import path from 'path';
import { string } from 'rollup-plugin-string';
import { terser } from 'rollup-plugin-terser';
import typescript from 'rollup-plugin-typescript';
@ -47,12 +47,12 @@ const onwarn = warning => {
};
const moduleAliases = {
resolve: ['.js', '.json', '.md'],
entries: [
{ find: 'help.md', replacement: path.resolve('cli/help.md') },
{ find: 'package.json', replacement: path.resolve('package.json') },
{ find: 'acorn', replacement: path.resolve('node_modules/acorn/dist/acorn.mjs') }
]
],
resolve: ['.js', '.json', '.md']
};
const treeshake = {
@ -74,17 +74,6 @@ const nodePlugins = [
export default command => {
const { collectLicenses, writeLicense } = getLicenseHandler();
const commonJSBuild = {
input: {
'rollup.js': 'src/node-entry.ts',
'loadConfigFile.js': 'cli/run/loadConfigFile.ts'
},
onwarn,
plugins: [
...nodePlugins,
addCliEntry(),
esmDynamicImport(),
!command.configTest && collectLicenses()
],
// fsevents is a dependency of chokidar that cannot be bundled as it contains binary code
external: [
'assert',
@ -99,8 +88,11 @@ export default command => {
'url',
'util'
],
treeshake,
strictDeprecations: true,
input: {
'loadConfigFile.js': 'cli/run/loadConfigFile.ts',
'rollup.js': 'src/node-entry.ts'
},
onwarn,
output: {
banner,
chunkFileNames: 'shared/[name].js',
@ -119,7 +111,15 @@ export default command => {
},
manualChunks: { rollup: ['src/node-entry.ts'] },
sourcemap: true
}
},
plugins: [
...nodePlugins,
addCliEntry(),
esmDynamicImport(),
!command.configTest && collectLicenses()
],
strictDeprecations: true,
treeshake
};
if (command.configTest) {
@ -129,19 +129,23 @@ export default command => {
const esmBuild = {
...commonJSBuild,
input: { 'rollup.js': 'src/node-entry.ts' },
plugins: [...nodePlugins, emitModulePackageFile(), collectLicenses()],
output: {
...commonJSBuild.output,
dir: 'dist/es',
format: 'es',
sourcemap: false,
minifyInternalExports: false
}
minifyInternalExports: false,
sourcemap: false
},
plugins: [...nodePlugins, emitModulePackageFile(), collectLicenses()]
};
const browserBuilds = {
input: 'src/browser-entry.ts',
onwarn,
output: [
{ banner, file: 'dist/rollup.browser.js', format: 'umd', name: 'rollup', sourcemap: true },
{ banner, file: 'dist/es/rollup.browser.js', format: 'es' }
],
plugins: [
replaceBrowserModules(),
alias(moduleAliases),
@ -153,12 +157,8 @@ export default command => {
collectLicenses(),
writeLicense()
],
treeshake,
strictDeprecations: true,
output: [
{ file: 'dist/rollup.browser.js', format: 'umd', name: 'rollup', banner, sourcemap: true },
{ file: 'dist/es/rollup.browser.js', format: 'es', banner }
]
treeshake
};
return [commonJSBuild, esmBuild, browserBuilds];

@ -1,5 +1,5 @@
const path = require('path');
const fs = require('fs');
const path = require('path');
const rollup = require('../dist/rollup.js');
exports.targetDir = path.resolve(__dirname, '..', 'perf');
@ -16,8 +16,8 @@ try {
exports.loadPerfConfig = async () => {
const bundle = await rollup.rollup({
input: configFile,
external: id => (id[0] !== '.' && !path.isAbsolute(id)) || id.slice(-5, id.length) === '.json',
input: configFile,
onwarn: warning => console.error(warning.message)
});
let config = loadConfigFromCode((await bundle.generate({ format: 'cjs' })).output[0].code);

@ -1,8 +1,8 @@
/* eslint-disable no-console */
const execa = require('execa');
const path = require('path');
const fs = require('fs');
const path = require('path');
const execa = require('execa');
const sander = require('sander');
const repoWithBranch = process.argv[2];

@ -1,9 +1,11 @@
const path = require('path');
/* global gc */
const fs = require('fs');
const rollup = require('../dist/rollup.js');
const path = require('path');
const prettyBytes = require('pretty-bytes');
const tc = require('turbocolor');
const rollup = require('../dist/rollup.js');
const { loadPerfConfig, targetDir } = require('./load-perf-config');
const prettyBytes = require('pretty-bytes');
const initialDir = process.cwd();
const perfFile = path.resolve(targetDir, 'rollup.perf.json');
@ -48,13 +50,13 @@ function getAverage(accumulatedMeasurements, runs, discarded) {
const average = {};
Object.keys(accumulatedMeasurements).forEach(label => {
average[label] = {
time: getSingleAverage(
accumulatedMeasurements[label].map(timing => timing[0]),
memory: getSingleAverage(
accumulatedMeasurements[label].map(timing => timing[2]),
runs,
discarded
),
memory: getSingleAverage(
accumulatedMeasurements[label].map(timing => timing[2]),
time: getSingleAverage(
accumulatedMeasurements[label].map(timing => timing[0]),
runs,
discarded
)
@ -153,7 +155,7 @@ function persistTimings(timings) {
);
} catch (e) {
console.error(tc.bold(`Could not persist performance information in ${tc.cyan(perfFile)}.`));
system.exit(1);
process.exit(1);
}
}

@ -1,7 +1,7 @@
#!/usr/bin/env node
const { readdirSync, copydirSync, copyFileSync, rimrafSync } = require('sander');
const { resolve, join } = require('path');
const { readdirSync, copydirSync, copyFileSync, rimrafSync } = require('sander');
const basePath = resolve(__dirname, '../test');

@ -12,6 +12,8 @@ import {
OutputChunk,
WarningHandler
} from './rollup/types';
import { FILE_PLACEHOLDER } from './utils/FileEmitter';
import { PluginDriver } from './utils/PluginDriver';
import { Addons, createAddons } from './utils/addons';
import { getChunkAssignments } from './utils/chunkAssignment';
import commondir from './utils/commondir';
@ -22,9 +24,7 @@ import {
warnDeprecation
} from './utils/error';
import { sortByExecutionOrder } from './utils/executionOrder';
import { FILE_PLACEHOLDER } from './utils/FileEmitter';
import { basename, isAbsolute } from './utils/path';
import { PluginDriver } from './utils/PluginDriver';
import { timeEnd, timeStart } from './utils/timers';
export default class Bundle {

@ -1,5 +1,7 @@
import MagicString, { Bundle as MagicStringBundle, SourceMap } from 'magic-string';
import { relative } from '../browser/path';
import ExternalModule from './ExternalModule';
import Module from './Module';
import ExportDefaultDeclaration from './ast/nodes/ExportDefaultDeclaration';
import FunctionDeclaration from './ast/nodes/FunctionDeclaration';
import ChildScope from './ast/scopes/ChildScope';
@ -10,9 +12,7 @@ import LocalVariable from './ast/variables/LocalVariable';
import NamespaceVariable from './ast/variables/NamespaceVariable';
import SyntheticNamedExportVariable from './ast/variables/SyntheticNamedExportVariable';
import Variable from './ast/variables/Variable';
import ExternalModule from './ExternalModule';
import finalisers from './finalisers/index';
import Module from './Module';
import {
DecodedSourceMapOrMissing,
GetInterop,
@ -25,6 +25,7 @@ import {
RenderedModule,
WarningHandler
} from './rollup/types';
import { PluginDriver } from './utils/PluginDriver';
import { Addons } from './utils/addons';
import { collapseSourcemaps } from './utils/collapseSourcemaps';
import { createHash } from './utils/crypto';
@ -51,7 +52,6 @@ import {
namespaceInteropHelpersByInteropType
} from './utils/interopHelpers';
import { basename, dirname, extname, isAbsolute, normalize, resolve } from './utils/path';
import { PluginDriver } from './utils/PluginDriver';
import relativeId, { getAliasName } from './utils/relativeId';
import renderChunk from './utils/renderChunk';
import { RenderOptions } from './utils/renderHelpers';
@ -127,52 +127,6 @@ function getGlobalName(
}
export default class Chunk {
private static generateFacade(
inputOptions: NormalizedInputOptions,
outputOptions: NormalizedOutputOptions,
unsetOptions: Set<string>,
pluginDriver: PluginDriver,
modulesById: Map<string, Module | ExternalModule>,
chunkByModule: Map<Module, Chunk>,
facadeChunkByModule: Map<Module, Chunk>,
includedNamespaces: Set<Module>,
facadedModule: Module,
facadeName: FacadeName
): Chunk {
const chunk = new Chunk(
[],
inputOptions,
outputOptions,
unsetOptions,
pluginDriver,
modulesById,
chunkByModule,
facadeChunkByModule,
includedNamespaces,
null
);
chunk.assignFacadeName(facadeName, facadedModule);
if (!facadeChunkByModule.has(facadedModule)) {
facadeChunkByModule.set(facadedModule, chunk);
}
for (const dependency of facadedModule.getDependenciesToBeIncluded()) {
chunk.dependencies.add(
dependency instanceof Module ? chunkByModule.get(dependency)! : dependency
);
}
if (
!chunk.dependencies.has(chunkByModule.get(facadedModule)!) &&
facadedModule.info.hasModuleSideEffects &&
facadedModule.hasEffects()
) {
chunk.dependencies.add(chunkByModule.get(facadedModule)!);
}
chunk.ensureReexportsAreAvailableForModule(facadedModule);
chunk.facadeModule = facadedModule;
chunk.strictFacade = true;
return chunk;
}
entryModules: Module[] = [];
execIndex: number;
exportMode: 'none' | 'named' | 'default' = 'named';
@ -194,7 +148,7 @@ export default class Chunk {
private implicitEntryModules: Module[] = [];
private implicitlyLoadedBefore = new Set<Chunk>();
private imports = new Set<Variable>();
private indentString: string = undefined as any;
private indentString: string = undefined as never;
private readonly isEmpty: boolean = true;
private name: string | null = null;
private needsExportsShim = false;
@ -203,16 +157,15 @@ export default class Chunk {
ModuleDeclarationDependency
> | null = null;
private renderedExports: ChunkExports | null = null;
private renderedHash: string = undefined as any;
private renderedHash: string = undefined as never;
private renderedModuleSources = new Map<Module, MagicString>();
private renderedModules: {
[moduleId: string]: RenderedModule;
} = Object.create(null);
private renderedModuleSources = new Map<Module, MagicString>();
private renderedSource: MagicStringBundle | null = null;
private sortedExportNames: string[] | null = null;
private strictFacade = false;
private usedModules: Module[] = undefined as any;
private usedModules: Module[] = undefined as never;
constructor(
private readonly orderedModules: Module[],
private readonly inputOptions: NormalizedInputOptions,
@ -255,6 +208,52 @@ export default class Chunk {
this.suggestedVariableName = makeLegal(this.generateVariableName());
}
private static generateFacade(
inputOptions: NormalizedInputOptions,
outputOptions: NormalizedOutputOptions,
unsetOptions: Set<string>,
pluginDriver: PluginDriver,
modulesById: Map<string, Module | ExternalModule>,
chunkByModule: Map<Module, Chunk>,
facadeChunkByModule: Map<Module, Chunk>,
includedNamespaces: Set<Module>,
facadedModule: Module,
facadeName: FacadeName
): Chunk {
const chunk = new Chunk(
[],
inputOptions,
outputOptions,
unsetOptions,
pluginDriver,
modulesById,
chunkByModule,
facadeChunkByModule,
includedNamespaces,
null
);
chunk.assignFacadeName(facadeName, facadedModule);
if (!facadeChunkByModule.has(facadedModule)) {
facadeChunkByModule.set(facadedModule, chunk);
}
for (const dependency of facadedModule.getDependenciesToBeIncluded()) {
chunk.dependencies.add(
dependency instanceof Module ? chunkByModule.get(dependency)! : dependency
);
}
if (
!chunk.dependencies.has(chunkByModule.get(facadedModule)!) &&
facadedModule.info.hasModuleSideEffects &&
facadedModule.hasEffects()
) {
chunk.dependencies.add(chunkByModule.get(facadedModule)!);
}
chunk.ensureReexportsAreAvailableForModule(facadedModule);
chunk.facadeModule = facadedModule;
chunk.strictFacade = true;
return chunk;
}
canModuleBeFacade(module: Module, exposedVariables: Set<Variable>): boolean {
const moduleExportNamesByVariable = module.getExportNamesByVariable();
for (const exposedVariable of this.exports) {
@ -287,7 +286,7 @@ export default class Chunk {
return true;
}
generateExports() {
generateExports(): void {
this.sortedExportNames = null;
const remainingExports = new Set(this.exports);
if (
@ -402,7 +401,7 @@ export default class Chunk {
generateId(
addons: Addons,
options: NormalizedOutputOptions,
existingNames: Record<string, any>,
existingNames: Record<string, unknown>,
includeHash: boolean
): string {
if (this.fileName !== null) {
@ -432,7 +431,7 @@ export default class Chunk {
generateIdPreserveModules(
preserveModulesRelativeDir: string,
options: NormalizedOutputOptions,
existingNames: Record<string, any>,
existingNames: Record<string, unknown>,
unsetOptions: Set<string>
): string {
const id = this.orderedModules[0].id;
@ -448,7 +447,7 @@ export default class Chunk {
typeof pattern === 'function' ? pattern(this.getChunkInfo()) : pattern,
'output.entryFileNames',
{
assetExtname: () => NON_ASSET_EXTENSIONS.includes(extension) ? '' : extension,
assetExtname: () => (NON_ASSET_EXTENSIONS.includes(extension) ? '' : extension),
ext: () => extension.substr(1),
extname: () => extension,
format: () => options.format as string,
@ -499,7 +498,9 @@ export default class Chunk {
}
getChunkName(): string {
return this.name || (this.name = this.outputOptions.sanitizeFileName(this.getFallbackChunkName()));
return (
this.name || (this.name = this.outputOptions.sanitizeFileName(this.getFallbackChunkName()))
);
}
getExportNames(): string[] {
@ -544,7 +545,7 @@ export default class Chunk {
return this.exportNamesByVariable.get(variable)![0];
}
link() {
link(): void {
this.dependencies = getStaticDependencies(this, this.orderedModules, this.chunkByModule);
for (const module of this.orderedModules) {
this.addDependenciesToChunk(module.dynamicDependencies, this.dynamicDependencies);
@ -554,7 +555,7 @@ export default class Chunk {
}
// prerender allows chunk hashes and names to be generated before finalizing
preRender(options: NormalizedOutputOptions, inputBase: string) {
preRender(options: NormalizedOutputOptions, inputBase: string): void {
const magicString = new MagicStringBundle({ separator: options.compact ? '' : '\n\n' });
this.usedModules = [];
this.indentString = getIndentString(this.orderedModules, options);
@ -610,15 +611,15 @@ export default class Chunk {
}
}
const { renderedExports, removedExports } = module.getRenderedExports();
const chunk = this;
const { renderedModuleSources } = this;
renderedModules[module.id] = {
get code() {
return renderedModuleSources.get(module)?.toString() ?? null;
},
originalLength: module.originalCode.length,
removedExports,
renderedExports,
renderedLength,
get code() {
return chunk.renderedModuleSources.get(module)?.toString() ?? null;
}
renderedLength
};
}
@ -635,7 +636,7 @@ export default class Chunk {
this.renderedSource = magicString.trim();
}
this.renderedHash = undefined as any;
this.renderedHash = undefined as never;
if (this.isEmpty && this.getExportNames().length === 0 && this.dependencies.size === 0) {
const chunkName = this.getChunkName();
@ -653,7 +654,11 @@ export default class Chunk {
this.exportMode === 'none' ? [] : this.getChunkExportDeclarations(options.format);
}
async render(options: NormalizedOutputOptions, addons: Addons, outputChunk: RenderedChunk) {
async render(
options: NormalizedOutputOptions,
addons: Addons,
outputChunk: RenderedChunk
): Promise<{ code: string; map: SourceMap }> {
timeStart('render format', 2);
const format = options.format;
@ -743,7 +748,7 @@ export default class Chunk {
timeEnd('render format', 2);
let map: SourceMap = null as any;
let map: SourceMap = null as never;
const chunkSourcemapChain: DecodedSourceMapOrMissing[] = [];
let code = await renderChunk({
@ -814,7 +819,9 @@ export default class Chunk {
if (fileName) {
this.fileName = fileName;
} else {
this.name = this.outputOptions.sanitizeFileName(name || getChunkNameFromModule(facadedModule));
this.name = this.outputOptions.sanitizeFileName(
name || getChunkNameFromModule(facadedModule)
);
}
}
@ -846,7 +853,7 @@ export default class Chunk {
private computeContentHashWithDependencies(
addons: Addons,
options: NormalizedOutputOptions,
existingNames: Record<string, any>
existingNames: Record<string, unknown>
): string {
const hash = createHash();
hash.update(
@ -967,7 +974,7 @@ export default class Chunk {
(imports || reexports) !== null,
this.inputOptions.onwarn
)) as string,
id: undefined as any, // chunk id updated on render
id: undefined as never, // chunk id updated on render
imports,
isChunk: dep instanceof Chunk,
name: dep.variableName,
@ -1086,25 +1093,6 @@ export default class Chunk {
return getAliasName(this.orderedModules[this.orderedModules.length - 1].id);
}
private getImportedBindingsPerDependency(): { [imported: string]: string[] } {
const importSpecifiers: { [imported: string]: string[] } = {};
for (const [dependency, declaration] of this.renderedDependencies!) {
const specifiers = new Set<string>();
if (declaration.imports) {
for (const { imported } of declaration.imports) {
specifiers.add(imported);
}
}
if (declaration.reexports) {
for (const { imported } of declaration.reexports) {
specifiers.add(imported);
}
}
importSpecifiers[dependency.id!] = [...specifiers];
}
return importSpecifiers;
}
private getImportSpecifiers(): Map<Chunk | ExternalModule, ImportSpecifier[]> {
const { interop } = this.outputOptions;
const importsByDependency = new Map<Chunk | ExternalModule, ImportSpecifier[]>();
@ -1130,6 +1118,25 @@ export default class Chunk {
return importsByDependency;
}
private getImportedBindingsPerDependency(): { [imported: string]: string[] } {
const importSpecifiers: { [imported: string]: string[] } = {};
for (const [dependency, declaration] of this.renderedDependencies!) {
const specifiers = new Set<string>();
if (declaration.imports) {
for (const { imported } of declaration.imports) {
specifiers.add(imported);
}
}
if (declaration.reexports) {
for (const { imported } of declaration.reexports) {
specifiers.add(imported);
}
}
importSpecifiers[dependency.id!] = [...specifiers];
}
return importSpecifiers;
}
private getReexportSpecifiers(): Map<Chunk | ExternalModule, ReexportSpecifier[]> {
const { externalLiveBindings, interop } = this.outputOptions;
const reexportSpecifiers = new Map<Chunk | ExternalModule, ReexportSpecifier[]>();

@ -21,10 +21,10 @@ export default class ExternalModule {
importers: string[] = [];
info: ModuleInfo;
mostCommonSuggestion = 0;
namespaceVariableName = '';
nameSuggestions: { [name: string]: number };
namespaceVariableName = '';
reexported = false;
renderPath: string = undefined as any;
renderPath: string = undefined as never;
suggestedVariableName: string;
used = false;
variableName = '';
@ -42,13 +42,13 @@ export default class ExternalModule {
this.declarations = Object.create(null);
this.exportedVariables = new Map();
const module = this;
const { importers, dynamicImporters } = this;
this.info = {
ast: null,
code: null,
dynamicallyImportedIds: EMPTY_ARRAY,
get dynamicImporters() {
return module.dynamicImporters.sort();
return dynamicImporters.sort();
},
hasModuleSideEffects,
id,
@ -56,7 +56,7 @@ export default class ExternalModule {
implicitlyLoadedBefore: EMPTY_ARRAY,
importedIds: EMPTY_ARRAY,
get importers() {
return module.importers.sort();
return importers.sort();
},
isEntry: false,
isExternal: true,
@ -74,7 +74,7 @@ export default class ExternalModule {
return declaration;
}
setRenderPath(options: NormalizedOutputOptions, inputBase: string) {
setRenderPath(options: NormalizedOutputOptions, inputBase: string): string {
this.renderPath =
typeof options.paths === 'function' ? options.paths(this.id) : options.paths[this.id];
if (!this.renderPath) {
@ -85,7 +85,7 @@ export default class ExternalModule {
return this.renderPath;
}
suggestName(name: string) {
suggestName(name: string): void {
if (!this.nameSuggestions[name]) this.nameSuggestions[name] = 0;
this.nameSuggestions[name] += 1;
@ -95,7 +95,7 @@ export default class ExternalModule {
}
}
warnUnusedImports() {
warnUnusedImports(): void {
const unused = Object.keys(this.declarations).filter(name => {
if (name === '*') return false;
const declaration = this.declarations[name];

@ -1,9 +1,9 @@
import * as acorn from 'acorn';
import GlobalScope from './ast/scopes/GlobalScope';
import { PathTracker } from './ast/utils/PathTracker';
import ExternalModule from './ExternalModule';
import Module from './Module';
import { ModuleLoader, UnresolvedModule } from './ModuleLoader';
import GlobalScope from './ast/scopes/GlobalScope';
import { PathTracker } from './ast/utils/PathTracker';
import {
ModuleInfo,
ModuleJSON,
@ -13,10 +13,10 @@ import {
SerializablePluginCache,
WatchChangeHook
} from './rollup/types';
import { PluginDriver } from './utils/PluginDriver';
import { BuildPhase } from './utils/buildPhase';
import { errImplicitDependantIsNotIncluded, error } from './utils/error';
import { analyseModuleExecution } from './utils/executionOrder';
import { PluginDriver } from './utils/PluginDriver';
import { markPureCallExpressions } from './utils/pureComments';
import relativeId from './utils/relativeId';
import { timeEnd, timeStart } from './utils/timers';
@ -113,13 +113,13 @@ export default class Graph {
this.phase = BuildPhase.GENERATE;
}
contextParse(code: string, options: Partial<acorn.Options> = {}) {
contextParse(code: string, options: Partial<acorn.Options> = {}): acorn.Node {
const onCommentOrig = options.onComment;
const comments: acorn.Comment[] = [];
if (onCommentOrig && typeof onCommentOrig == 'function') {
options.onComment = (block, text, start, end, ...args) => {
comments.push({ type: block ? 'Block' : 'Line', value: text, start, end });
comments.push({ end, start, type: block ? 'Block' : 'Line', value: text });
return onCommentOrig.call(options, block, text, start, end, ...args);
};
} else {
@ -127,7 +127,7 @@ export default class Graph {
}
const ast = this.acornParser.parse(code, {
...(this.options.acorn as acorn.Options),
...((this.options.acorn as unknown) as acorn.Options),
...options
});

@ -2,6 +2,8 @@ import * as acorn from 'acorn';
import { locate } from 'locate-character';
import MagicString from 'magic-string';
import extractAssignedNames from 'rollup-pluginutils/src/extractAssignedNames';
import ExternalModule from './ExternalModule';
import Graph from './Graph';
import { createHasEffectsContext, createInclusionContext } from './ast/ExecutionContext';
import ExportAllDeclaration from './ast/nodes/ExportAllDeclaration';
import ExportDefaultDeclaration from './ast/nodes/ExportDefaultDeclaration';
@ -10,14 +12,14 @@ import Identifier from './ast/nodes/Identifier';
import ImportDeclaration from './ast/nodes/ImportDeclaration';
import ImportExpression from './ast/nodes/ImportExpression';
import ImportSpecifier from './ast/nodes/ImportSpecifier';
import { nodeConstructors } from './ast/nodes/index';
import Literal from './ast/nodes/Literal';
import MetaProperty from './ast/nodes/MetaProperty';
import * as NodeType from './ast/nodes/NodeType';
import Program from './ast/nodes/Program';
import { ExpressionNode, GenericEsTreeNode, NodeBase } from './ast/nodes/shared/Node';
import TemplateLiteral from './ast/nodes/TemplateLiteral';
import VariableDeclaration from './ast/nodes/VariableDeclaration';
import { nodeConstructors } from './ast/nodes/index';
import { ExpressionNode, GenericEsTreeNode, NodeBase } from './ast/nodes/shared/Node';
import ModuleScope from './ast/scopes/ModuleScope';
import { PathTracker, UNKNOWN_PATH } from './ast/utils/PathTracker';
import ExportDefaultVariable from './ast/variables/ExportDefaultVariable';
@ -26,8 +28,6 @@ import ExternalVariable from './ast/variables/ExternalVariable';
import NamespaceVariable from './ast/variables/NamespaceVariable';
import SyntheticNamedExportVariable from './ast/variables/SyntheticNamedExportVariable';
import Variable from './ast/variables/Variable';
import ExternalModule from './ExternalModule';
import Graph from './Graph';
import {
CustomPluginOptions,
DecodedSourceMapOrMissing,
@ -212,7 +212,7 @@ export default class Module {
ast: Program | null = null;
chunkFileNames = new Set<string>();
chunkName: string | null = null;
cycles = new Set<Symbol>();
cycles = new Set<symbol>();
dependencies = new Set<Module | ExternalModule>();
dynamicDependencies = new Set<Module | ExternalModule>();
dynamicImporters: string[] = [];
@ -229,8 +229,8 @@ export default class Module {
implicitlyLoadedAfter = new Set<Module>();
implicitlyLoadedBefore = new Set<Module>();
importDescriptions: { [name: string]: ImportDescription } = Object.create(null);
importers: string[] = [];
importMetas: MetaProperty[] = [];
importers: string[] = [];
imports = new Set<Variable>();
includedDynamicImporters: Module[] = [];
info: ModuleInfo;
@ -278,6 +278,7 @@ export default class Module {
this.excludeFromSourcemap = /\0/.test(id);
this.context = options.moduleContext(id);
// eslint-disable-next-line @typescript-eslint/no-this-alias
const module = this;
this.info = {
ast: null,
@ -315,14 +316,14 @@ export default class Module {
};
}
basename() {
basename(): string {
const base = basename(this.id);
const ext = extname(this.id);
return makeLegal(ext ? base.slice(0, -ext.length) : base);
}
bindReferences() {
bindReferences(): void {
this.ast!.bind();
}
@ -435,7 +436,7 @@ export default class Module {
return (this.exportNamesByVariable = exportNamesByVariable);
}
getExports() {
getExports(): string[] {
return Object.keys(this.exports);
}
@ -462,7 +463,7 @@ export default class Module {
return (this.transitiveReexports = [...reexports]);
}
getRenderedExports() {
getRenderedExports(): { removedExports: string[]; renderedExports: string[] } {
// only direct exports are counted here, not reexports at all
const renderedExports: string[] = [];
const removedExports: string[] = [];
@ -470,10 +471,10 @@ export default class Module {
const variable = this.getVariableForExportName(exportName);
(variable && variable.included ? renderedExports : removedExports).push(exportName);
}
return { renderedExports, removedExports };
return { removedExports, renderedExports };
}
getSyntheticNamespace() {
getSyntheticNamespace(): Variable {
if (this.syntheticNamespace === null) {
this.syntheticNamespace = undefined;
this.syntheticNamespace = this.getVariableForExportName(
@ -598,7 +599,7 @@ export default class Module {
return null;
}
hasEffects() {
hasEffects(): boolean {
return (
this.info.hasModuleSideEffects === 'no-treeshake' ||
(this.ast!.included && this.ast!.hasEffects(createHasEffectsContext()))
@ -610,7 +611,7 @@ export default class Module {
if (this.ast!.shouldBeIncluded(context)) this.ast!.include(context, false);
}
includeAllExports(includeNamespaceMembers: boolean) {
includeAllExports(includeNamespaceMembers: boolean): void {
if (!this.isExecuted) {
this.graph.needsTreeshakingPass = true;
markModuleAndImpureDependenciesAsExecuted(this);
@ -644,15 +645,15 @@ export default class Module {
}
}
includeAllInBundle() {
includeAllInBundle(): void {
this.ast!.include(createInclusionContext(), true);
}
isIncluded() {
isIncluded(): boolean {
return this.ast!.included || this.namespace.included;
}
linkImports() {
linkImports(): void {
this.addModulesToImportDescriptions(this.importDescriptions);
this.addModulesToImportDescriptions(this.reexportDescriptions);
for (const name in this.exports) {
@ -701,7 +702,7 @@ export default class Module {
}: TransformModuleJSON & {
alwaysRemovedCode?: [number, number][];
transformFiles?: EmittedFile[] | undefined;
}) {
}): void {
this.info.code = code;
this.originalCode = originalCode;
this.originalSourcemap = originalSourcemap;
@ -769,7 +770,7 @@ export default class Module {
this.scope = new ModuleScope(this.graph.scope, this.astContext);
this.namespace = new NamespaceVariable(this.astContext, this.info.syntheticNamedExports);
this.ast = new Program(ast, { type: 'Module', context: this.astContext }, this.scope);
this.ast = new Program(ast, { context: this.astContext, type: 'Module' }, this.scope);
this.info.ast = ast;
timeEnd('analyse ast', 3);
@ -851,7 +852,7 @@ export default class Module {
meta,
moduleSideEffects,
syntheticNamedExports
}: Partial<PartialNull<ModuleOptions>>) {
}: Partial<PartialNull<ModuleOptions>>): void {
if (moduleSideEffects != null) {
this.info.hasModuleSideEffects = moduleSideEffects;
}
@ -863,7 +864,7 @@ export default class Module {
}
}
warn(props: RollupWarning, pos: number) {
warn(props: RollupWarning, pos: number): void {
this.addLocationToLogProps(props, pos);
this.options.onwarn(props);
}
@ -877,7 +878,7 @@ export default class Module {
} else if (argument instanceof Literal && typeof argument.value === 'string') {
argument = argument.value;
}
this.dynamicImports.push({ node, resolution: null, argument });
this.dynamicImports.push({ argument, node, resolution: null });
}
private addExport(
@ -899,7 +900,7 @@ export default class Module {
const name = node.exported.name;
this.reexportDescriptions[name] = {
localName: '*',
module: null as any, // filled in later,
module: null as never, // filled in later,
source,
start: node.start
};
@ -917,7 +918,7 @@ export default class Module {
const name = specifier.exported.name;
this.reexportDescriptions[name] = {
localName: specifier.local.name,
module: null as any, // filled in later,
module: null as never, // filled in later,
source,
start: specifier.start
};
@ -963,7 +964,7 @@ export default class Module {
? '*'
: (specifier as ImportSpecifier).imported.name;
this.importDescriptions[specifier.local.name] = {
module: null as any, // filled in later
module: null as never, // filled in later
name,
source,
start: specifier.start

@ -14,6 +14,7 @@ import {
ResolveIdResult,
SourceDescription
} from './rollup/types';
import { PluginDriver } from './utils/PluginDriver';
import { EMPTY_OBJECT } from './utils/blank';
import {
errBadLoader,
@ -29,7 +30,6 @@ import {
} from './utils/error';
import { readFile } from './utils/fs';
import { isAbsolute, isRelative, resolve } from './utils/path';
import { PluginDriver } from './utils/PluginDriver';
import relativeId from './utils/relativeId';
import { resolveId } from './utils/resolveId';
import { timeEnd, timeStart } from './utils/timers';
@ -51,7 +51,7 @@ export class ModuleLoader {
private readonly hasModuleSideEffects: HasModuleSideEffects;
private readonly implicitEntryModules = new Set<Module>();
private readonly indexedEntryModules: { index: number; module: Module }[] = [];
private latestLoadModulesPromise: Promise<any> = Promise.resolve();
private latestLoadModulesPromise: Promise<unknown> = Promise.resolve();
private nextEntryModuleIndex = 0;
constructor(
@ -99,7 +99,7 @@ export class ModuleLoader {
indexedModule => indexedModule.module === entryModule
);
if (!existingIndexedModule) {
this.indexedEntryModules.push({ module: entryModule, index: moduleIndex });
this.indexedEntryModules.push({ index: moduleIndex, module: entryModule });
} else {
existingIndexedModule.index = Math.min(existingIndexedModule.index, moduleIndex);
}

@ -1,5 +1,5 @@
import { ExpressionEntity } from './nodes/shared/Expression';
import SpreadElement from './nodes/SpreadElement';
import { ExpressionEntity } from './nodes/shared/Expression';
export const NO_ARGS = [];

@ -1,6 +1,7 @@
import { HasEffectsContext } from './ExecutionContext';
import { ObjectPath } from './utils/PathTracker';
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface Entity {}
export interface WritableEntity extends Entity {

@ -7,7 +7,7 @@ export const keys: {
Program: ['body']
};
export function getAndCreateKeys(esTreeNode: GenericEsTreeNode) {
export function getAndCreateKeys(esTreeNode: GenericEsTreeNode): string[] {
keys[esTreeNode.type] = Object.keys(esTreeNode).filter(
key => typeof esTreeNode[key] === 'object' && key !== '_rollupAnnotations'
);

@ -5,18 +5,18 @@ import { NodeEvent } from '../NodeEvents';
import { ObjectPath, PathTracker, UnknownInteger } from '../utils/PathTracker';
import { UNDEFINED_EXPRESSION, UNKNOWN_LITERAL_NUMBER } from '../values';
import * as NodeType from './NodeType';
import SpreadElement from './SpreadElement';
import { ARRAY_PROTOTYPE } from './shared/ArrayPrototype';
import { ExpressionEntity, LiteralValueOrUnknown } from './shared/Expression';
import { ExpressionNode, NodeBase } from './shared/Node';
import { ObjectEntity, ObjectProperty } from './shared/ObjectEntity';
import SpreadElement from './SpreadElement';
export default class ArrayExpression extends NodeBase {
elements!: (ExpressionNode | SpreadElement | null)[];
type!: NodeType.tArrayExpression;
private objectEntity: ObjectEntity | null = null;
deoptimizePath(path: ObjectPath) {
deoptimizePath(path: ObjectPath): void {
this.getObjectEntity().deoptimizePath(path);
}
@ -25,7 +25,7 @@ export default class ArrayExpression extends NodeBase {
path: ObjectPath,
thisParameter: ExpressionEntity,
recursionTracker: PathTracker
) {
): void {
this.getObjectEntity().deoptimizeThisOnEventAtPath(
event,
path,
@ -56,11 +56,11 @@ export default class ArrayExpression extends NodeBase {
);
}
hasEffectsWhenAccessedAtPath(path: ObjectPath, context: HasEffectsContext) {
hasEffectsWhenAccessedAtPath(path: ObjectPath, context: HasEffectsContext): boolean {
return this.getObjectEntity().hasEffectsWhenAccessedAtPath(path, context);
}
hasEffectsWhenAssignedAtPath(path: ObjectPath, context: HasEffectsContext) {
hasEffectsWhenAssignedAtPath(path: ObjectPath, context: HasEffectsContext): boolean {
return this.getObjectEntity().hasEffectsWhenAssignedAtPath(path, context);
}
@ -77,16 +77,16 @@ export default class ArrayExpression extends NodeBase {
return this.objectEntity;
}
const properties: ObjectProperty[] = [
{ kind: 'init', key: 'length', property: UNKNOWN_LITERAL_NUMBER }
{ key: 'length', kind: 'init', property: UNKNOWN_LITERAL_NUMBER }
];
for (let index = 0; index < this.elements.length; index++) {
const element = this.elements[index];
if (element instanceof SpreadElement) {
properties.unshift({ kind: 'init', key: UnknownInteger, property: element });
properties.unshift({ key: UnknownInteger, kind: 'init', property: element });
} else if (!element) {
properties.push({ kind: 'init', key: String(index), property: UNDEFINED_EXPRESSION });
properties.push({ key: String(index), kind: 'init', property: UNDEFINED_EXPRESSION });
} else {
properties.push({ kind: 'init', key: String(index), property: element });
properties.push({ key: String(index), kind: 'init', property: element });
}
}
return (this.objectEntity = new ObjectEntity(properties, ARRAY_PROTOTYPE));

@ -1,5 +1,6 @@
import { HasEffectsContext } from '../ExecutionContext';
import { EMPTY_PATH, ObjectPath } from '../utils/PathTracker';
import LocalVariable from '../variables/LocalVariable';
import Variable from '../variables/Variable';
import * as NodeType from './NodeType';
import { UNKNOWN_EXPRESSION } from './shared/Expression';
@ -21,8 +22,8 @@ export default class ArrayPattern extends NodeBase implements PatternNode {
}
}
declare(kind: string) {
const variables = [];
declare(kind: string): LocalVariable[] {
const variables: LocalVariable[] = [];
for (const element of this.elements) {
if (element !== null) {
variables.push(...element.declare(kind, UNKNOWN_EXPRESSION));
@ -31,7 +32,7 @@ export default class ArrayPattern extends NodeBase implements PatternNode {
return variables;
}
deoptimizePath(path: ObjectPath) {
deoptimizePath(path: ObjectPath): void {
if (path.length === 0) {
for (const element of this.elements) {
if (element !== null) {
@ -41,7 +42,7 @@ export default class ArrayPattern extends NodeBase implements PatternNode {
}
}
hasEffectsWhenAssignedAtPath(path: ObjectPath, context: HasEffectsContext) {
hasEffectsWhenAssignedAtPath(path: ObjectPath, context: HasEffectsContext): boolean {
if (path.length > 0) return true;
for (const element of this.elements) {
if (element !== null && element.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context))

@ -2,15 +2,15 @@ import { CallOptions } from '../CallOptions';
import { BROKEN_FLOW_NONE, HasEffectsContext, InclusionContext } from '../ExecutionContext';
import ReturnValueScope from '../scopes/ReturnValueScope';
import Scope from '../scopes/Scope';
import { ObjectPath, UnknownKey, UNKNOWN_PATH } from '../utils/PathTracker';
import { ObjectPath, UNKNOWN_PATH, UnknownKey } from '../utils/PathTracker';
import BlockStatement from './BlockStatement';
import Identifier from './Identifier';
import * as NodeType from './NodeType';
import RestElement from './RestElement';
import { UNKNOWN_EXPRESSION } from './shared/Expression';
import SpreadElement from './SpreadElement';
import { ExpressionEntity, UNKNOWN_EXPRESSION } from './shared/Expression';
import { ExpressionNode, GenericEsTreeNode, IncludeChildren, NodeBase } from './shared/Node';
import { PatternNode } from './shared/Pattern';
import SpreadElement from './SpreadElement';
export default class ArrowFunctionExpression extends NodeBase {
body!: BlockStatement | ExpressionNode;
@ -19,11 +19,11 @@ export default class ArrowFunctionExpression extends NodeBase {
scope!: ReturnValueScope;
type!: NodeType.tArrowFunctionExpression;
createScope(parentScope: Scope) {
createScope(parentScope: Scope): void {
this.scope = new ReturnValueScope(parentScope, this.context);
}
deoptimizePath(path: ObjectPath) {
deoptimizePath(path: ObjectPath): void {
// A reassignment of UNKNOWN_PATH is considered equivalent to having lost track
// which means the return expression needs to be reassigned
if (path.length === 1 && path[0] === UnknownKey) {
@ -32,21 +32,21 @@ export default class ArrowFunctionExpression extends NodeBase {
}
// Arrow functions do not mutate their context
deoptimizeThisOnEventAtPath() {}
deoptimizeThisOnEventAtPath(): void {}
getReturnExpressionWhenCalledAtPath(path: ObjectPath) {
getReturnExpressionWhenCalledAtPath(path: ObjectPath): ExpressionEntity {
return path.length === 0 ? this.scope.getReturnExpression() : UNKNOWN_EXPRESSION;
}
hasEffects() {
hasEffects(): boolean {
return false;
}
hasEffectsWhenAccessedAtPath(path: ObjectPath) {
hasEffectsWhenAccessedAtPath(path: ObjectPath): boolean {
return path.length > 1;
}
hasEffectsWhenAssignedAtPath(path: ObjectPath) {
hasEffectsWhenAssignedAtPath(path: ObjectPath): boolean {
return path.length > 1;
}
@ -72,7 +72,7 @@ export default class ArrowFunctionExpression extends NodeBase {
return false;
}
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) {
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void {
this.included = true;
for (const param of this.params) {
if (!(param instanceof Identifier)) {
@ -89,7 +89,7 @@ export default class ArrowFunctionExpression extends NodeBase {
this.scope.includeCallArguments(context, args);
}
initialise() {
initialise(): void {
this.scope.addParameterVariables(
this.params.map(param => param.declare('parameter', UNKNOWN_EXPRESSION)),
this.params[this.params.length - 1] instanceof RestElement
@ -101,7 +101,7 @@ export default class ArrowFunctionExpression extends NodeBase {
}
}
parseNode(esTreeNode: GenericEsTreeNode) {
parseNode(esTreeNode: GenericEsTreeNode): void {
if (esTreeNode.body.type === NodeType.BlockStatement) {
this.body = new this.context.nodeConstructors.BlockStatement(
esTreeNode.body,

@ -69,7 +69,7 @@ export default class AssignmentExpression extends NodeBase {
code: MagicString,
options: RenderOptions,
{ preventASI, renderedParentType }: NodeRenderOptions = BLANK
) {
): void {
if (this.left.included) {
this.left.render(code, options);
this.right.render(code, options);
@ -122,7 +122,7 @@ export default class AssignmentExpression extends NodeBase {
}
}
protected applyDeoptimizations() {
protected applyDeoptimizations(): void {
this.deoptimized = true;
this.left.deoptimizePath(EMPTY_PATH);
this.right.deoptimizePath(UNKNOWN_PATH);

@ -3,6 +3,7 @@ import { BLANK } from '../../utils/blank';
import { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers';
import { HasEffectsContext } from '../ExecutionContext';
import { EMPTY_PATH, ObjectPath, UNKNOWN_PATH } from '../utils/PathTracker';
import LocalVariable from '../variables/LocalVariable';
import Variable from '../variables/Variable';
import * as NodeType from './NodeType';
import { ExpressionEntity } from './shared/Expression';
@ -22,11 +23,11 @@ export default class AssignmentPattern extends NodeBase implements PatternNode {
this.left.addExportedVariables(variables, exportNamesByVariable);
}
declare(kind: string, init: ExpressionEntity) {
declare(kind: string, init: ExpressionEntity): LocalVariable[] {
return this.left.declare(kind, init);
}
deoptimizePath(path: ObjectPath) {
deoptimizePath(path: ObjectPath): void {
path.length === 0 && this.left.deoptimizePath(path);
}
@ -38,12 +39,12 @@ export default class AssignmentPattern extends NodeBase implements PatternNode {
code: MagicString,
options: RenderOptions,
{ isShorthandProperty }: NodeRenderOptions = BLANK
) {
): void {
this.left.render(code, options, { isShorthandProperty });
this.right.render(code, options);
}
protected applyDeoptimizations():void {
protected applyDeoptimizations(): void {
this.deoptimized = true;
this.left.deoptimizePath(EMPTY_PATH);
this.right.deoptimizePath(UNKNOWN_PATH);

@ -8,11 +8,11 @@ export default class AwaitExpression extends NodeBase {
argument!: ExpressionNode;
type!: NodeType.tAwaitExpression;
hasEffects(context: HasEffectsContext) {
hasEffects(context: HasEffectsContext): boolean {
return !context.ignore.returnAwaitYield || this.argument.hasEffects(context);
}
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) {
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void {
if (!this.included) {
this.included = true;
checkTopLevelAwait: if (!this.context.usesTopLevelAwait) {

@ -79,7 +79,7 @@ export default class BinaryExpression extends NodeBase implements DeoptimizableE
return super.hasEffects(context);
}
hasEffectsWhenAccessedAtPath(path: ObjectPath) {
hasEffectsWhenAccessedAtPath(path: ObjectPath): boolean {
return path.length > 1;
}
}

@ -16,20 +16,20 @@ export default class BlockStatement extends StatementBase {
private deoptimizeBody!: boolean;
private directlyIncluded = false;
addImplicitReturnExpressionToScope() {
addImplicitReturnExpressionToScope(): void {
const lastStatement = this.body[this.body.length - 1];
if (!lastStatement || lastStatement.type !== NodeType.ReturnStatement) {
this.scope.addReturnExpression(UNKNOWN_EXPRESSION);
}
}
createScope(parentScope: Scope) {
createScope(parentScope: Scope): void {
this.scope = (this.parent as Node).preventChildBlockScope
? (parentScope as ChildScope)
: new BlockScope(parentScope);
}
hasEffects(context: HasEffectsContext) {
hasEffects(context: HasEffectsContext): boolean {
if (this.deoptimizeBody) return true;
for (const node of this.body) {
if (node.hasEffects(context)) return true;
@ -38,7 +38,7 @@ export default class BlockStatement extends StatementBase {
return false;
}
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) {
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void {
if (!this.deoptimizeBody || !this.directlyIncluded) {
this.included = true;
this.directlyIncluded = true;
@ -50,14 +50,14 @@ export default class BlockStatement extends StatementBase {
}
}
initialise() {
initialise(): void {
const firstBodyStatement = this.body[0];
this.deoptimizeBody =
firstBodyStatement instanceof ExpressionStatement &&
firstBodyStatement.directive === 'use asm';
}
render(code: MagicString, options: RenderOptions) {
render(code: MagicString, options: RenderOptions): void {
if (this.body.length) {
renderStatementList(this.body, code, this.start + 1, this.end - 1, options);
} else {

@ -12,7 +12,7 @@ export default class BreakStatement extends StatementBase {
label!: Identifier | null;
type!: NodeType.tBreakStatement;
hasEffects(context: HasEffectsContext) {
hasEffects(context: HasEffectsContext): boolean {
if (this.label) {
if (!context.ignore.labels.has(this.label.name)) return true;
context.includedLabels.add(this.label.name);
@ -24,7 +24,7 @@ export default class BreakStatement extends StatementBase {
return false;
}
include(context: InclusionContext) {
include(context: InclusionContext): void {
this.included = true;
if (this.label) {
this.label.include();

@ -20,21 +20,21 @@ import {
import Identifier from './Identifier';
import MemberExpression from './MemberExpression';
import * as NodeType from './NodeType';
import SpreadElement from './SpreadElement';
import Super from './Super';
import {
ExpressionEntity,
LiteralValueOrUnknown,
UnknownValue,
UNKNOWN_EXPRESSION
UNKNOWN_EXPRESSION,
UnknownValue
} from './shared/Expression';
import {
Annotation,
ExpressionNode,
IncludeChildren,
INCLUDE_PARAMETERS,
IncludeChildren,
NodeBase
} from './shared/Node';
import SpreadElement from './SpreadElement';
import Super from './Super';
export default class CallExpression extends NodeBase implements DeoptimizableEntity {
arguments!: (ExpressionNode | SpreadElement)[];
@ -47,7 +47,7 @@ export default class CallExpression extends NodeBase implements DeoptimizableEnt
private expressionsToBeDeoptimized = new Set<ExpressionEntity>();
private returnExpression: ExpressionEntity | null = null;
bind() {
bind(): void {
super.bind();
if (this.callee instanceof Identifier) {
const variable = this.scope.findVariable(this.callee.name);
@ -83,7 +83,7 @@ export default class CallExpression extends NodeBase implements DeoptimizableEnt
};
}
deoptimizeCache() {
deoptimizeCache(): void {
if (this.returnExpression !== UNKNOWN_EXPRESSION) {
this.returnExpression = UNKNOWN_EXPRESSION;
for (const expression of this.deoptimizableDependentExpressions) {
@ -95,7 +95,7 @@ export default class CallExpression extends NodeBase implements DeoptimizableEnt
}
}
deoptimizePath(path: ObjectPath) {
deoptimizePath(path: ObjectPath): void {
if (
path.length === 0 ||
this.context.deoptimizationTracker.trackEntityAtPathAndGetIfTracked(path, this)
@ -113,7 +113,7 @@ export default class CallExpression extends NodeBase implements DeoptimizableEnt
path: ObjectPath,
thisParameter: ExpressionEntity,
recursionTracker: PathTracker
) {
): void {
const returnExpression = this.getReturnExpression(recursionTracker);
if (returnExpression === UNKNOWN_EXPRESSION) {
thisParameter.deoptimizePath(UNKNOWN_PATH);
@ -225,7 +225,7 @@ export default class CallExpression extends NodeBase implements DeoptimizableEnt
);
}
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) {
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void {
if (!this.deoptimized) this.applyDeoptimizations();
if (includeChildrenRecursively) {
super.include(context, includeChildrenRecursively);
@ -251,7 +251,7 @@ export default class CallExpression extends NodeBase implements DeoptimizableEnt
code: MagicString,
options: RenderOptions,
{ renderedParentType, renderedSurroundingElement }: NodeRenderOptions = BLANK
) {
): void {
const surroundingELement = renderedParentType || renderedSurroundingElement;
this.callee.render(
code,
@ -290,7 +290,7 @@ export default class CallExpression extends NodeBase implements DeoptimizableEnt
}
}
protected applyDeoptimizations() {
protected applyDeoptimizations(): void {
this.deoptimized = true;
const { thisParam } = this.callOptions;
if (thisParam) {

@ -13,17 +13,17 @@ export default class CatchClause extends NodeBase {
scope!: CatchScope;
type!: NodeType.tCatchClause;
createScope(parentScope: Scope) {
createScope(parentScope: Scope): void {
this.scope = new CatchScope(parentScope, this.context);
}
initialise() {
initialise(): void {
if (this.param) {
this.param.declare('parameter', UNKNOWN_EXPRESSION);
}
}
parseNode(esTreeNode: GenericEsTreeNode) {
parseNode(esTreeNode: GenericEsTreeNode): void {
this.body = new this.context.nodeConstructors.BlockStatement(
esTreeNode.body,
this,

@ -12,11 +12,11 @@ export default class ClassBody extends NodeBase {
scope!: ClassBodyScope;
type!: NodeType.tClassBody;
createScope(parentScope: Scope) {
createScope(parentScope: Scope): void {
this.scope = new ClassBodyScope(parentScope, this.parent as ClassNode, this.context);
}
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) {
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void {
this.included = true;
this.context.includeVariableInModule(this.scope.thisVariable);
for (const definition of this.body) {
@ -24,7 +24,7 @@ export default class ClassBody extends NodeBase {
}
}
parseNode(esTreeNode: GenericEsTreeNode) {
parseNode(esTreeNode: GenericEsTreeNode): void {
const body: NodeBase[] = (this.body = []);
for (const definition of esTreeNode.body) {
body.push(

@ -11,14 +11,14 @@ export default class ClassDeclaration extends ClassNode {
id!: IdentifierWithVariable | null;
type!: NodeType.tClassDeclaration;
initialise() {
initialise(): void {
super.initialise();
if (this.id !== null) {
this.id.variable.isId = true;
}
}
parseNode(esTreeNode: GenericEsTreeNode) {
parseNode(esTreeNode: GenericEsTreeNode): void {
if (esTreeNode.id !== null) {
this.id = new this.context.nodeConstructors.Identifier(
esTreeNode.id,
@ -29,13 +29,16 @@ export default class ClassDeclaration extends ClassNode {
super.parseNode(esTreeNode);
}
render(code: MagicString, options: RenderOptions) {
render(code: MagicString, options: RenderOptions): void {
if (
options.format === 'system' &&
this.id &&
options.exportNamesByVariable.has(this.id.variable)
) {
code.appendLeft(this.end, `${options.compact ? '' : ' '}${getSystemExportStatement([this.id.variable], options)};`);
code.appendLeft(
this.end,
`${options.compact ? '' : ' '}${getSystemExportStatement([this.id.variable], options)};`
);
}
super.render(code, options);
}

@ -11,7 +11,7 @@ export default class ClassExpression extends ClassNode {
code: MagicString,
options: RenderOptions,
{ renderedParentType, renderedSurroundingElement }: NodeRenderOptions = BLANK
) {
): void {
super.render(code, options);
const surroundingElement = renderedParentType || renderedSurroundingElement;
if (surroundingElement === NodeType.ExpressionStatement) {

@ -12,13 +12,19 @@ import { CallOptions } from '../CallOptions';
import { DeoptimizableEntity } from '../DeoptimizableEntity';
import { HasEffectsContext, InclusionContext } from '../ExecutionContext';
import { NodeEvent } from '../NodeEvents';
import { EMPTY_PATH, ObjectPath, PathTracker, SHARED_RECURSION_TRACKER, UNKNOWN_PATH } from '../utils/PathTracker';
import {
EMPTY_PATH,
ObjectPath,
PathTracker,
SHARED_RECURSION_TRACKER,
UNKNOWN_PATH
} from '../utils/PathTracker';
import CallExpression from './CallExpression';
import * as NodeType from './NodeType';
import SpreadElement from './SpreadElement';
import { ExpressionEntity, LiteralValueOrUnknown, UnknownValue } from './shared/Expression';
import { MultiExpression } from './shared/MultiExpression';
import { ExpressionNode, IncludeChildren, NodeBase } from './shared/Node';
import SpreadElement from './SpreadElement';
export default class ConditionalExpression extends NodeBase implements DeoptimizableEntity {
alternate!: ExpressionNode;
@ -30,7 +36,7 @@ export default class ConditionalExpression extends NodeBase implements Deoptimiz
private isBranchResolutionAnalysed = false;
private usedBranch: ExpressionNode | null = null;
deoptimizeCache() {
deoptimizeCache(): void {
if (this.usedBranch !== null) {
const unusedBranch = this.usedBranch === this.consequent ? this.alternate : this.consequent;
this.usedBranch = null;
@ -41,7 +47,7 @@ export default class ConditionalExpression extends NodeBase implements Deoptimiz
}
}
deoptimizePath(path: ObjectPath) {
deoptimizePath(path: ObjectPath): void {
const usedBranch = this.getUsedBranch();
if (usedBranch === null) {
this.consequent.deoptimizePath(path);
@ -56,7 +62,7 @@ export default class ConditionalExpression extends NodeBase implements Deoptimiz
path: ObjectPath,
thisParameter: ExpressionEntity,
recursionTracker: PathTracker
) {
): void {
this.consequent.deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker);
this.alternate.deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker);
}
@ -149,7 +155,7 @@ export default class ConditionalExpression extends NodeBase implements Deoptimiz
return usedBranch.hasEffectsWhenCalledAtPath(path, callOptions, context);
}
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) {
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void {
this.included = true;
const usedBranch = this.getUsedBranch();
if (includeChildrenRecursively || this.test.shouldBeIncluded(context) || usedBranch === null) {
@ -175,7 +181,7 @@ export default class ConditionalExpression extends NodeBase implements Deoptimiz
code: MagicString,
options: RenderOptions,
{ renderedParentType, isCalleeOfRenderedParent, preventASI }: NodeRenderOptions = BLANK
) {
): void {
const usedBranch = this.getUsedBranch();
if (!this.test.included) {
const colonPos = findFirstOccurrenceOutsideComment(code.original, ':', this.consequent.end);

@ -12,7 +12,7 @@ export default class ContinueStatement extends StatementBase {
label!: Identifier | null;
type!: NodeType.tContinueStatement;
hasEffects(context: HasEffectsContext) {
hasEffects(context: HasEffectsContext): boolean {
if (this.label) {
if (!context.ignore.labels.has(this.label.name)) return true;
context.includedLabels.add(this.label.name);
@ -24,7 +24,7 @@ export default class ContinueStatement extends StatementBase {
return false;
}
include(context: InclusionContext) {
include(context: InclusionContext): void {
this.included = true;
if (this.label) {
this.label.include();

@ -22,7 +22,7 @@ export default class DoWhileStatement extends StatementBase {
return false;
}
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) {
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void {
this.included = true;
this.test.include(context, includeChildrenRecursively);
const { brokenFlow } = context;

@ -11,15 +11,15 @@ export default class ExportAllDeclaration extends NodeBase {
source!: Literal<string>;
type!: NodeType.tExportAllDeclaration;
hasEffects() {
hasEffects(): boolean {
return false;
}
initialise() {
initialise(): void {
this.context.addExport(this);
}
render(code: MagicString, _options: RenderOptions, nodeRenderOptions?: NodeRenderOptions) {
render(code: MagicString, _options: RenderOptions, nodeRenderOptions?: NodeRenderOptions): void {
code.remove(nodeRenderOptions!.start!, nodeRenderOptions!.end!);
}
}

@ -49,14 +49,14 @@ export default class ExportDefaultDeclaration extends NodeBase {
private declarationName: string | undefined;
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) {
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void {
super.include(context, includeChildrenRecursively);
if (includeChildrenRecursively) {
this.context.includeVariableInModule(this.variable);
}
}
initialise() {
initialise(): void {
const declaration = this.declaration as FunctionDeclaration | ClassDeclaration;
this.declarationName =
(declaration.id && declaration.id.name) || (this.declaration as Identifier).name;
@ -68,7 +68,7 @@ export default class ExportDefaultDeclaration extends NodeBase {
this.context.addExport(this);
}
render(code: MagicString, options: RenderOptions, nodeRenderOptions?: NodeRenderOptions) {
render(code: MagicString, options: RenderOptions, nodeRenderOptions?: NodeRenderOptions): void {
const { start, end } = nodeRenderOptions as { end: number; start: number };
const declarationStart = getDeclarationStart(code.original, this.start);

@ -6,8 +6,8 @@ import ExportSpecifier from './ExportSpecifier';
import FunctionDeclaration from './FunctionDeclaration';
import Literal from './Literal';
import * as NodeType from './NodeType';
import { Node, NodeBase } from './shared/Node';
import VariableDeclaration from './VariableDeclaration';
import { Node, NodeBase } from './shared/Node';
export default class ExportNamedDeclaration extends NodeBase {
declaration!: FunctionDeclaration | ClassDeclaration | VariableDeclaration | null;
@ -16,26 +16,26 @@ export default class ExportNamedDeclaration extends NodeBase {
specifiers!: ExportSpecifier[];
type!: NodeType.tExportNamedDeclaration;
bind() {
bind(): void {
// Do not bind specifiers
if (this.declaration !== null) this.declaration.bind();
}
hasEffects(context: HasEffectsContext) {
hasEffects(context: HasEffectsContext): boolean {
return this.declaration !== null && this.declaration.hasEffects(context);
}
initialise() {
initialise(): void {
this.context.addExport(this);
}
render(code: MagicString, options: RenderOptions, nodeRenderOptions?: NodeRenderOptions) {
render(code: MagicString, options: RenderOptions, nodeRenderOptions?: NodeRenderOptions): void {
const { start, end } = nodeRenderOptions as { end: number; start: number };
if (this.declaration === null) {
code.remove(start, end);
} else {
code.remove(this.start, this.declaration.start);
(this.declaration as Node).render(code, options, { start, end });
(this.declaration as Node).render(code, options, { end, start });
}
}
}

@ -8,7 +8,7 @@ export default class ExpressionStatement extends StatementBase {
directive?: string;
expression!: ExpressionNode;
initialise() {
initialise(): void {
if (
this.directive &&
this.directive !== 'use strict' &&
@ -25,12 +25,12 @@ export default class ExpressionStatement extends StatementBase {
}
}
render(code: MagicString, options: RenderOptions) {
render(code: MagicString, options: RenderOptions): void {
super.render(code, options);
if (this.included) this.insertSemicolon(code);
}
shouldBeIncluded(context: InclusionContext) {
shouldBeIncluded(context: InclusionContext): boolean {
if (this.directive && this.directive !== 'use strict')
return this.parent.type !== NodeType.Program;

@ -5,9 +5,9 @@ import BlockScope from '../scopes/BlockScope';
import Scope from '../scopes/Scope';
import { EMPTY_PATH } from '../utils/PathTracker';
import * as NodeType from './NodeType';
import VariableDeclaration from './VariableDeclaration';
import { ExpressionNode, IncludeChildren, StatementBase, StatementNode } from './shared/Node';
import { PatternNode } from './shared/Pattern';
import VariableDeclaration from './VariableDeclaration';
export default class ForInStatement extends StatementBase {
body!: StatementNode;
@ -16,7 +16,7 @@ export default class ForInStatement extends StatementBase {
type!: NodeType.tForInStatement;
protected deoptimized = false;
createScope(parentScope: Scope) {
createScope(parentScope: Scope): void {
this.scope = new BlockScope(parentScope);
}
@ -42,7 +42,7 @@ export default class ForInStatement extends StatementBase {
return false;
}
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) {
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void {
if (!this.deoptimized) this.applyDeoptimizations();
this.included = true;
this.left.include(context, includeChildrenRecursively || true);
@ -52,7 +52,7 @@ export default class ForInStatement extends StatementBase {
context.brokenFlow = brokenFlow;
}
render(code: MagicString, options: RenderOptions) {
render(code: MagicString, options: RenderOptions): void {
this.left.render(code, options, NO_SEMICOLON);
this.right.render(code, options, NO_SEMICOLON);
// handle no space between "in" and the right side
@ -62,7 +62,7 @@ export default class ForInStatement extends StatementBase {
this.body.render(code, options);
}
protected applyDeoptimizations():void {
protected applyDeoptimizations(): void {
this.deoptimized = true;
this.left.deoptimizePath(EMPTY_PATH);
}

@ -5,9 +5,9 @@ import BlockScope from '../scopes/BlockScope';
import Scope from '../scopes/Scope';
import { EMPTY_PATH } from '../utils/PathTracker';
import * as NodeType from './NodeType';
import VariableDeclaration from './VariableDeclaration';
import { ExpressionNode, IncludeChildren, StatementBase, StatementNode } from './shared/Node';
import { PatternNode } from './shared/Pattern';
import VariableDeclaration from './VariableDeclaration';
export default class ForOfStatement extends StatementBase {
await!: boolean;
@ -17,7 +17,7 @@ export default class ForOfStatement extends StatementBase {
type!: NodeType.tForOfStatement;
protected deoptimized = false;
createScope(parentScope: Scope) {
createScope(parentScope: Scope): void {
this.scope = new BlockScope(parentScope);
}
@ -27,7 +27,7 @@ export default class ForOfStatement extends StatementBase {
return true;
}
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) {
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void {
if (!this.deoptimized) this.applyDeoptimizations();
this.included = true;
this.left.include(context, includeChildrenRecursively || true);
@ -37,7 +37,7 @@ export default class ForOfStatement extends StatementBase {
context.brokenFlow = brokenFlow;
}
render(code: MagicString, options: RenderOptions) {
render(code: MagicString, options: RenderOptions): void {
this.left.render(code, options, NO_SEMICOLON);
this.right.render(code, options, NO_SEMICOLON);
// handle no space between "of" and the right side

@ -4,8 +4,8 @@ import { HasEffectsContext, InclusionContext } from '../ExecutionContext';
import BlockScope from '../scopes/BlockScope';
import Scope from '../scopes/Scope';
import * as NodeType from './NodeType';
import { ExpressionNode, IncludeChildren, StatementBase, StatementNode } from './shared/Node';
import VariableDeclaration from './VariableDeclaration';
import { ExpressionNode, IncludeChildren, StatementBase, StatementNode } from './shared/Node';
export default class ForStatement extends StatementBase {
body!: StatementNode;
@ -14,7 +14,7 @@ export default class ForStatement extends StatementBase {
type!: NodeType.tForStatement;
update!: ExpressionNode | null;
createScope(parentScope: Scope) {
createScope(parentScope: Scope): void {
this.scope = new BlockScope(parentScope);
}
@ -38,7 +38,7 @@ export default class ForStatement extends StatementBase {
return false;
}
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) {
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void {
this.included = true;
if (this.init) this.init.includeAsSingleStatement(context, includeChildrenRecursively);
if (this.test) this.test.include(context, includeChildrenRecursively);
@ -48,7 +48,7 @@ export default class ForStatement extends StatementBase {
context.brokenFlow = brokenFlow;
}
render(code: MagicString, options: RenderOptions) {
render(code: MagicString, options: RenderOptions): void {
if (this.init) this.init.render(code, options, NO_SEMICOLON);
if (this.test) this.test.render(code, options, NO_SEMICOLON);
if (this.update) this.update.render(code, options, NO_SEMICOLON);

@ -7,17 +7,20 @@ import { GenericEsTreeNode } from './shared/Node';
export default class FunctionDeclaration extends FunctionNode {
type!: NodeType.tFunctionDeclaration;
initialise() {
initialise(): void {
super.initialise();
if (this.id !== null) {
this.id.variable.isId = true;
}
}
parseNode(esTreeNode: GenericEsTreeNode) {
parseNode(esTreeNode: GenericEsTreeNode): void {
if (esTreeNode.id !== null) {
this.id = new this.context.nodeConstructors.Identifier(esTreeNode.id, this, this.scope
.parent as ChildScope) as IdentifierWithVariable;
this.id = new this.context.nodeConstructors.Identifier(
esTreeNode.id,
this,
this.scope.parent as ChildScope
) as IdentifierWithVariable;
}
super.parseNode(esTreeNode);
}

@ -11,7 +11,7 @@ export default class FunctionExpression extends FunctionNode {
code: MagicString,
options: RenderOptions,
{ renderedParentType, renderedSurroundingElement }: NodeRenderOptions = BLANK
) {
): void {
super.render(code, options);
const surroundingElement = renderedParentType || renderedSurroundingElement;
if (surroundingElement === NodeType.ExpressionStatement) {

@ -13,10 +13,10 @@ import GlobalVariable from '../variables/GlobalVariable';
import LocalVariable from '../variables/LocalVariable';
import Variable from '../variables/Variable';
import * as NodeType from './NodeType';
import SpreadElement from './SpreadElement';
import { ExpressionEntity, LiteralValueOrUnknown } from './shared/Expression';
import { ExpressionNode, NodeBase } from './shared/Node';
import { PatternNode } from './shared/Pattern';
import SpreadElement from './SpreadElement';
export type IdentifierWithVariable = Identifier & { variable: Variable };
@ -36,14 +36,14 @@ export default class Identifier extends NodeBase implements PatternNode {
}
}
bind() {
bind(): void {
if (this.variable === null && isReference(this, this.parent as any)) {
this.variable = this.scope.findVariable(this.name);
this.variable.addReference(this);
}
}
declare(kind: string, init: ExpressionEntity) {
declare(kind: string, init: ExpressionEntity): LocalVariable[] {
let variable: LocalVariable;
switch (kind) {
case 'var':
@ -69,7 +69,7 @@ export default class Identifier extends NodeBase implements PatternNode {
return [(this.variable = variable)];
}
deoptimizePath(path: ObjectPath) {
deoptimizePath(path: ObjectPath): void {
if (path.length === 0 && !this.scope.contains(this.name)) {
this.disallowImportReassignment();
}
@ -81,7 +81,7 @@ export default class Identifier extends NodeBase implements PatternNode {
path: ObjectPath,
thisParameter: ExpressionEntity,
recursionTracker: PathTracker
) {
): void {
this.variable!.deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker);
}
@ -128,11 +128,11 @@ export default class Identifier extends NodeBase implements PatternNode {
path: ObjectPath,
callOptions: CallOptions,
context: HasEffectsContext
) {
): boolean {
return !this.variable || this.variable.hasEffectsWhenCalledAtPath(path, callOptions, context);
}
include() {
include(): void {
if (!this.deoptimized) this.applyDeoptimizations();
if (!this.included) {
this.included = true;
@ -150,7 +150,7 @@ export default class Identifier extends NodeBase implements PatternNode {
code: MagicString,
_options: RenderOptions,
{ renderedParentType, isCalleeOfRenderedParent, isShorthandProperty }: NodeRenderOptions = BLANK
) {
): void {
if (this.variable) {
const name = this.variable.getName();
@ -174,12 +174,9 @@ export default class Identifier extends NodeBase implements PatternNode {
}
}
protected applyDeoptimizations() {
protected applyDeoptimizations(): void {
this.deoptimized = true;
if (
this.variable !== null &&
this.variable instanceof LocalVariable
) {
if (this.variable !== null && this.variable instanceof LocalVariable) {
this.variable.consolidateInitializers();
}
}

@ -29,7 +29,7 @@ export default class IfStatement extends StatementBase implements DeoptimizableE
private consequentScope!: TrackingScope;
private testValue: LiteralValueOrUnknown | typeof unset = unset;
deoptimizeCache() {
deoptimizeCache(): void {
this.testValue = UnknownValue;
}
@ -54,7 +54,7 @@ export default class IfStatement extends StatementBase implements DeoptimizableE
: this.alternate !== null && this.alternate.hasEffects(context);
}
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) {
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void {
this.included = true;
if (includeChildrenRecursively) {
this.includeRecursively(includeChildrenRecursively, context);
@ -68,7 +68,7 @@ export default class IfStatement extends StatementBase implements DeoptimizableE
}
}
parseNode(esTreeNode: GenericEsTreeNode) {
parseNode(esTreeNode: GenericEsTreeNode): void {
this.consequentScope = new TrackingScope(this.scope);
this.consequent = new (this.context.nodeConstructors[esTreeNode.consequent.type] ||
this.context.nodeConstructors.UnknownNode)(esTreeNode.consequent, this, this.consequentScope);
@ -80,7 +80,7 @@ export default class IfStatement extends StatementBase implements DeoptimizableE
super.parseNode(esTreeNode);
}
render(code: MagicString, options: RenderOptions) {
render(code: MagicString, options: RenderOptions): void {
// Note that unknown test values are always included
const testValue = this.getTestValue();
const hoistedDeclarations: Identifier[] = [];

@ -14,17 +14,17 @@ export default class ImportDeclaration extends NodeBase {
type!: NodeType.tImportDeclaration;
// Do not bind specifiers
bind() {}
bind(): void {}
hasEffects() {
hasEffects(): boolean {
return false;
}
initialise() {
initialise(): void {
this.context.addImport(this);
}
render(code: MagicString, _options: RenderOptions, nodeRenderOptions?: NodeRenderOptions) {
render(code: MagicString, _options: RenderOptions, nodeRenderOptions?: NodeRenderOptions): void {
code.remove(nodeRenderOptions!.start!, nodeRenderOptions!.end!);
}
}

@ -2,11 +2,11 @@ import MagicString from 'magic-string';
import ExternalModule from '../../ExternalModule';
import Module from '../../Module';
import { GetInterop, NormalizedOutputOptions } from '../../rollup/types';
import { PluginDriver } from '../../utils/PluginDriver';
import {
getDefaultOnlyHelper,
namespaceInteropHelpersByInteropType
} from '../../utils/interopHelpers';
import { PluginDriver } from '../../utils/PluginDriver';
import { findFirstOccurrenceOutsideComment, RenderOptions } from '../../utils/renderHelpers';
import { InclusionContext } from '../ExecutionContext';
import ChildScope from '../scopes/ChildScope';
@ -31,7 +31,7 @@ export default class ImportExpression extends NodeBase {
return true;
}
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) {
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void {
if (!this.included) {
this.included = true;
this.context.includeDynamicImport(this);
@ -40,11 +40,11 @@ export default class ImportExpression extends NodeBase {
this.source.include(context, includeChildrenRecursively);
}
initialise() {
initialise(): void {
this.context.addDynamicImport(this);
}
render(code: MagicString, options: RenderOptions) {
render(code: MagicString, options: RenderOptions): void {
if (this.inlineNamespace) {
const _ = options.compact ? '' : ' ';
const s = options.compact ? '' : ';';
@ -72,7 +72,7 @@ export default class ImportExpression extends NodeBase {
resolution: string,
namespaceExportName: string | false | undefined,
options: NormalizedOutputOptions
) {
): void {
code.overwrite(this.source.start, this.source.end, resolution);
if (namespaceExportName) {
const _ = options.compact ? '' : ' ';
@ -108,7 +108,7 @@ export default class ImportExpression extends NodeBase {
}
}
setInternalResolution(inlineNamespace: NamespaceVariable) {
setInternalResolution(inlineNamespace: NamespaceVariable): void {
this.inlineNamespace = inlineNamespace;
}
@ -135,7 +135,7 @@ export default class ImportExpression extends NodeBase {
const _ = options.compact ? '' : ' ';
const s = options.compact ? '' : ';';
const leftStart = `Promise.resolve().then(function${_}()${_}{${_}return`;
const helper = this.getInteropHelper(resolution, exportMode, options.interop);
const helper = getInteropHelper(resolution, exportMode, options.interop);
return {
helper,
mechanism: helper
@ -153,7 +153,7 @@ export default class ImportExpression extends NodeBase {
const _ = options.compact ? '' : ' ';
const resolve = options.compact ? 'c' : 'resolve';
const reject = options.compact ? 'e' : 'reject';
const helper = this.getInteropHelper(resolution, exportMode, options.interop);
const helper = getInteropHelper(resolution, exportMode, options.interop);
const resolveNamespace = helper
? `function${_}(m)${_}{${_}${resolve}(/*#__PURE__*/${helper}(m));${_}}`
: resolve;
@ -186,20 +186,20 @@ export default class ImportExpression extends NodeBase {
}
return { helper: null, mechanism: null };
}
}
private getInteropHelper(
resolution: Module | ExternalModule | string | null,
exportMode: 'none' | 'named' | 'default' | 'external',
interop: GetInterop
): string | null {
return exportMode === 'external'
? namespaceInteropHelpersByInteropType[
String(interop(resolution instanceof ExternalModule ? resolution.id : null))
]
: exportMode === 'default'
? getDefaultOnlyHelper()
: null;
}
function getInteropHelper(
resolution: Module | ExternalModule | string | null,
exportMode: 'none' | 'named' | 'default' | 'external',
interop: GetInterop
): string | null {
return exportMode === 'external'
? namespaceInteropHelpersByInteropType[
String(interop(resolution instanceof ExternalModule ? resolution.id : null))
]
: exportMode === 'default'
? getDefaultOnlyHelper()
: null;
}
const accessedImportGlobals: Record<string, string[]> = {

@ -14,7 +14,7 @@ export default class LabeledStatement extends StatementBase {
label!: Identifier;
type!: NodeType.tLabeledStatement;
hasEffects(context: HasEffectsContext) {
hasEffects(context: HasEffectsContext): boolean {
const brokenFlow = context.brokenFlow;
context.ignore.labels.add(this.label.name);
if (this.body.hasEffects(context)) return true;
@ -26,7 +26,7 @@ export default class LabeledStatement extends StatementBase {
return false;
}
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) {
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void {
this.included = true;
const brokenFlow = context.brokenFlow;
this.body.include(context, includeChildrenRecursively);
@ -37,7 +37,7 @@ export default class LabeledStatement extends StatementBase {
}
}
render(code: MagicString, options: RenderOptions) {
render(code: MagicString, options: RenderOptions): void {
if (this.label.included) {
this.label.render(code, options);
} else {

@ -9,7 +9,12 @@ import {
MemberDescription
} from '../values';
import * as NodeType from './NodeType';
import { LiteralValueOrUnknown, UnknownValue, UNKNOWN_EXPRESSION } from './shared/Expression';
import {
ExpressionEntity,
LiteralValueOrUnknown,
UNKNOWN_EXPRESSION,
UnknownValue
} from './shared/Expression';
import { GenericEsTreeNode, NodeBase } from './shared/Node';
export type LiteralValue = string | boolean | null | number | RegExp | undefined;
@ -24,7 +29,7 @@ export default class Literal<T extends LiteralValue = LiteralValue> extends Node
private members!: { [key: string]: MemberDescription };
deoptimizeThisOnEventAtPath() {}
deoptimizeThisOnEventAtPath(): void {}
getLiteralValueAtPath(path: ObjectPath): LiteralValueOrUnknown {
if (
@ -40,19 +45,19 @@ export default class Literal<T extends LiteralValue = LiteralValue> extends Node
return this.value;
}
getReturnExpressionWhenCalledAtPath(path: ObjectPath) {
getReturnExpressionWhenCalledAtPath(path: ObjectPath): ExpressionEntity {
if (path.length !== 1) return UNKNOWN_EXPRESSION;
return getMemberReturnExpressionWhenCalled(this.members, path[0]);
}
hasEffectsWhenAccessedAtPath(path: ObjectPath) {
hasEffectsWhenAccessedAtPath(path: ObjectPath): boolean {
if (this.value === null) {
return path.length > 0;
}
return path.length > 1;
}
hasEffectsWhenAssignedAtPath(path: ObjectPath) {
hasEffectsWhenAssignedAtPath(path: ObjectPath): boolean {
return path.length > 0;
}
@ -67,17 +72,17 @@ export default class Literal<T extends LiteralValue = LiteralValue> extends Node
return true;
}
initialise() {
initialise(): void {
this.members = getLiteralMembersForValue(this.value);
}
parseNode(esTreeNode: GenericEsTreeNode) {
parseNode(esTreeNode: GenericEsTreeNode): void {
this.value = esTreeNode.value;
this.regex = esTreeNode.regex;
super.parseNode(esTreeNode);
}
render(code: MagicString) {
render(code: MagicString): void {
if (typeof this.value === 'string') {
(code.indentExclusionRanges as [number, number][]).push([this.start + 1, this.end - 1]);
}

@ -38,7 +38,7 @@ export default class LogicalExpression extends NodeBase implements Deoptimizable
private isBranchResolutionAnalysed = false;
private usedBranch: ExpressionNode | null = null;
deoptimizeCache() {
deoptimizeCache(): void {
if (this.usedBranch !== null) {
const unusedBranch = this.usedBranch === this.left ? this.right : this.left;
this.usedBranch = null;
@ -49,7 +49,7 @@ export default class LogicalExpression extends NodeBase implements Deoptimizable
}
}
deoptimizePath(path: ObjectPath) {
deoptimizePath(path: ObjectPath): void {
const usedBranch = this.getUsedBranch();
if (usedBranch === null) {
this.left.deoptimizePath(path);
@ -64,7 +64,7 @@ export default class LogicalExpression extends NodeBase implements Deoptimizable
path: ObjectPath,
thisParameter: ExpressionEntity,
recursionTracker: PathTracker
) {
): void {
this.left.deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker);
this.right.deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker);
}
@ -148,7 +148,7 @@ export default class LogicalExpression extends NodeBase implements Deoptimizable
return usedBranch.hasEffectsWhenCalledAtPath(path, callOptions, context);
}
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) {
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void {
this.included = true;
const usedBranch = this.getUsedBranch();
if (
@ -167,7 +167,7 @@ export default class LogicalExpression extends NodeBase implements Deoptimizable
code: MagicString,
options: RenderOptions,
{ renderedParentType, isCalleeOfRenderedParent, preventASI }: NodeRenderOptions = BLANK
) {
): void {
if (!this.left.included || !this.right.included) {
const operatorPos = findFirstOccurrenceOutsideComment(
code.original,

@ -13,8 +13,8 @@ import {
ObjectPathKey,
PathTracker,
SHARED_RECURSION_TRACKER,
UnknownKey,
UNKNOWN_PATH
UNKNOWN_PATH,
UnknownKey
} from '../utils/PathTracker';
import ExternalVariable from '../variables/ExternalVariable';
import NamespaceVariable from '../variables/NamespaceVariable';
@ -24,10 +24,15 @@ import Identifier from './Identifier';
import Literal from './Literal';
import * as NodeType from './NodeType';
import PrivateIdentifier from './PrivateIdentifier';
import { ExpressionEntity, LiteralValueOrUnknown, UnknownValue, UNKNOWN_EXPRESSION } from './shared/Expression';
import { ExpressionNode, IncludeChildren, NodeBase } from './shared/Node';
import SpreadElement from './SpreadElement';
import Super from './Super';
import {
ExpressionEntity,
LiteralValueOrUnknown,
UNKNOWN_EXPRESSION,
UnknownValue
} from './shared/Expression';
import { ExpressionNode, IncludeChildren, NodeBase } from './shared/Node';
function getResolvablePropertyKey(memberExpression: MemberExpression): string | null {
return memberExpression.computed
@ -85,7 +90,7 @@ export default class MemberExpression extends NodeBase implements DeoptimizableE
private expressionsToBeDeoptimized: DeoptimizableEntity[] = [];
private replacement: string | null = null;
bind() {
bind(): void {
this.bound = true;
const path = getPathIfNotComputed(this);
const baseVariable = path && this.scope.findVariable(path[0].key);
@ -104,7 +109,7 @@ export default class MemberExpression extends NodeBase implements DeoptimizableE
}
}
deoptimizeCache() {
deoptimizeCache(): void {
const expressionsToBeDeoptimized = this.expressionsToBeDeoptimized;
this.expressionsToBeDeoptimized = [];
this.propertyKey = UnknownKey;
@ -114,7 +119,7 @@ export default class MemberExpression extends NodeBase implements DeoptimizableE
}
}
deoptimizePath(path: ObjectPath) {
deoptimizePath(path: ObjectPath): void {
if (path.length === 0) this.disallowNamespaceReassignment();
if (this.variable) {
this.variable.deoptimizePath(path);
@ -243,7 +248,7 @@ export default class MemberExpression extends NodeBase implements DeoptimizableE
);
}
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) {
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void {
if (!this.deoptimized) this.applyDeoptimizations();
if (!this.included) {
this.included = true;
@ -263,7 +268,7 @@ export default class MemberExpression extends NodeBase implements DeoptimizableE
}
}
initialise() {
initialise(): void {
this.propertyKey = getResolvablePropertyKey(this);
}
@ -275,7 +280,7 @@ export default class MemberExpression extends NodeBase implements DeoptimizableE
isCalleeOfRenderedParent,
renderedSurroundingElement
}: NodeRenderOptions = BLANK
) {
): void {
const isCalleeOfDifferentParent =
renderedParentType === NodeType.CallExpression && isCalleeOfRenderedParent;
if (this.variable || this.replacement) {
@ -299,7 +304,7 @@ export default class MemberExpression extends NodeBase implements DeoptimizableE
}
}
protected applyDeoptimizations() {
protected applyDeoptimizations(): void {
this.deoptimized = true;
const { propertyReadSideEffects } = this.context.options
.treeshake as NormalizedTreeshakingOptions;

@ -1,8 +1,8 @@
import MagicString from 'magic-string';
import { InternalModuleFormat } from '../../rollup/types';
import { PluginDriver } from '../../utils/PluginDriver';
import { warnDeprecation } from '../../utils/error';
import { dirname, normalize, relative } from '../../utils/path';
import { PluginDriver } from '../../utils/PluginDriver';
import ChildScope from '../scopes/ChildScope';
import { ObjectPathKey } from '../utils/PathTracker';
import Identifier from './Identifier';
@ -24,7 +24,7 @@ export default class MetaProperty extends NodeBase {
addAccessedGlobals(
format: InternalModuleFormat,
accessedGlobalsByScope: Map<ChildScope, Set<string>>
) {
): void {
const metaProperty = this.metaProperty;
const accessedGlobals = (metaProperty &&
(metaProperty.startsWith(FILE_PREFIX) ||
@ -53,7 +53,7 @@ export default class MetaProperty extends NodeBase {
return path.length > 1;
}
include() {
include(): void {
if (!this.included) {
this.included = true;
if (this.meta.name === 'import') {

@ -28,11 +28,11 @@ export default class NewExpression extends NodeBase {
);
}
hasEffectsWhenAccessedAtPath(path: ObjectPath) {
hasEffectsWhenAccessedAtPath(path: ObjectPath): boolean {
return path.length > 0;
}
initialise() {
initialise(): void {
this.callOptions = {
args: this.arguments,
thisParam: null,

@ -16,27 +16,27 @@ import Identifier from './Identifier';
import Literal from './Literal';
import * as NodeType from './NodeType';
import Property from './Property';
import SpreadElement from './SpreadElement';
import {
ExpressionEntity,
LiteralValueOrUnknown,
UnknownValue,
UNKNOWN_EXPRESSION
UNKNOWN_EXPRESSION,
UnknownValue
} from './shared/Expression';
import { NodeBase } from './shared/Node';
import { ObjectEntity, ObjectProperty } from './shared/ObjectEntity';
import { OBJECT_PROTOTYPE } from './shared/ObjectPrototype';
import SpreadElement from './SpreadElement';
export default class ObjectExpression extends NodeBase implements DeoptimizableEntity {
properties!: (Property | SpreadElement)[];
type!: NodeType.tObjectExpression;
private objectEntity: ObjectEntity | null = null;
deoptimizeCache() {
deoptimizeCache(): void {
this.getObjectEntity().deoptimizeAllProperties();
}
deoptimizePath(path: ObjectPath) {
deoptimizePath(path: ObjectPath): void {
this.getObjectEntity().deoptimizePath(path);
}
@ -45,7 +45,7 @@ export default class ObjectExpression extends NodeBase implements DeoptimizableE
path: ObjectPath,
thisParameter: ExpressionEntity,
recursionTracker: PathTracker
) {
): void {
this.getObjectEntity().deoptimizeThisOnEventAtPath(
event,
path,
@ -76,11 +76,11 @@ export default class ObjectExpression extends NodeBase implements DeoptimizableE
);
}
hasEffectsWhenAccessedAtPath(path: ObjectPath, context: HasEffectsContext) {
hasEffectsWhenAccessedAtPath(path: ObjectPath, context: HasEffectsContext): boolean {
return this.getObjectEntity().hasEffectsWhenAccessedAtPath(path, context);
}
hasEffectsWhenAssignedAtPath(path: ObjectPath, context: HasEffectsContext) {
hasEffectsWhenAssignedAtPath(path: ObjectPath, context: HasEffectsContext): boolean {
return this.getObjectEntity().hasEffectsWhenAssignedAtPath(path, context);
}
@ -96,7 +96,7 @@ export default class ObjectExpression extends NodeBase implements DeoptimizableE
code: MagicString,
options: RenderOptions,
{ renderedParentType, renderedSurroundingElement }: NodeRenderOptions = BLANK
) {
): void {
super.render(code, options);
const surroundingElement = renderedParentType || renderedSurroundingElement;
if (
@ -115,7 +115,7 @@ export default class ObjectExpression extends NodeBase implements DeoptimizableE
const properties: ObjectProperty[] = [];
for (const property of this.properties) {
if (property instanceof SpreadElement) {
properties.push({ kind: 'init', key: UnknownKey, property });
properties.push({ key: UnknownKey, kind: 'init', property });
continue;
}
let key: string;
@ -126,7 +126,7 @@ export default class ObjectExpression extends NodeBase implements DeoptimizableE
this
);
if (keyValue === UnknownValue) {
properties.push({ kind: property.kind, key: UnknownKey, property });
properties.push({ key: UnknownKey, kind: property.kind, property });
continue;
} else {
key = String(keyValue);
@ -137,11 +137,11 @@ export default class ObjectExpression extends NodeBase implements DeoptimizableE
? property.key.name
: String((property.key as Literal).value);
if (key === '__proto__' && property.kind === 'init') {
properties.unshift({ kind: 'init', key: UnknownKey, property: UNKNOWN_EXPRESSION });
properties.unshift({ key: UnknownKey, kind: 'init', property: UNKNOWN_EXPRESSION });
continue;
}
}
properties.push({ kind: property.kind, key, property });
properties.push({ key, kind: property.kind, property });
}
return (this.objectEntity = new ObjectEntity(properties, OBJECT_PROTOTYPE));
}

@ -1,5 +1,6 @@
import { HasEffectsContext } from '../ExecutionContext';
import { EMPTY_PATH, ObjectPath } from '../utils/PathTracker';
import LocalVariable from '../variables/LocalVariable';
import Variable from '../variables/Variable';
import * as NodeType from './NodeType';
import Property from './Property';
@ -28,15 +29,15 @@ export default class ObjectPattern extends NodeBase implements PatternNode {
}
}
declare(kind: string, init: ExpressionEntity) {
const variables = [];
declare(kind: string, init: ExpressionEntity): LocalVariable[] {
const variables: LocalVariable[] = [];
for (const property of this.properties) {
variables.push(...property.declare(kind, init));
}
return variables;
}
deoptimizePath(path: ObjectPath) {
deoptimizePath(path: ObjectPath): void {
if (path.length === 0) {
for (const property of this.properties) {
property.deoptimizePath(path);
@ -44,7 +45,7 @@ export default class ObjectPattern extends NodeBase implements PatternNode {
}
}
hasEffectsWhenAssignedAtPath(path: ObjectPath, context: HasEffectsContext) {
hasEffectsWhenAssignedAtPath(path: ObjectPath, context: HasEffectsContext): boolean {
if (path.length > 0) return true;
for (const property of this.properties) {
if (property.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context)) return true;

@ -11,7 +11,7 @@ export default class Program extends NodeBase {
private hasCachedEffect = false;
hasEffects(context: HasEffectsContext) {
hasEffects(context: HasEffectsContext): boolean {
// We are caching here to later more efficiently identify side-effect-free modules
if (this.hasCachedEffect) return true;
for (const node of this.body) {
@ -22,7 +22,7 @@ export default class Program extends NodeBase {
return false;
}
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) {
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void {
this.included = true;
for (const node of this.body) {
if (includeChildrenRecursively || node.shouldBeIncluded(context)) {
@ -31,7 +31,7 @@ export default class Program extends NodeBase {
}
}
render(code: MagicString, options: RenderOptions) {
render(code: MagicString, options: RenderOptions): void {
if (this.body.length) {
renderStatementList(this.body, code, this.start, this.end, options);
} else {

@ -3,6 +3,7 @@ import { NormalizedTreeshakingOptions } from '../../rollup/types';
import { RenderOptions } from '../../utils/renderHelpers';
import { HasEffectsContext } from '../ExecutionContext';
import { UnknownKey } from '../utils/PathTracker';
import LocalVariable from '../variables/LocalVariable';
import * as NodeType from './NodeType';
import { ExpressionEntity, UNKNOWN_EXPRESSION } from './shared/Expression';
import MethodBase from './shared/MethodBase';
@ -18,7 +19,7 @@ export default class Property extends MethodBase implements PatternNode {
protected deoptimized = false;
private declarationInit: ExpressionEntity | null = null;
declare(kind: string, init: ExpressionEntity) {
declare(kind: string, init: ExpressionEntity): LocalVariable[] {
this.declarationInit = init;
return (this.value as PatternNode).declare(kind, UNKNOWN_EXPRESSION);
}
@ -34,14 +35,14 @@ export default class Property extends MethodBase implements PatternNode {
);
}
render(code: MagicString, options: RenderOptions) {
render(code: MagicString, options: RenderOptions): void {
if (!this.shorthand) {
this.key.render(code, options);
}
this.value.render(code, options, { isShorthandProperty: this.shorthand });
}
protected applyDeoptimizations():void {
protected applyDeoptimizations(): void {
this.deoptimized = true;
if (this.declarationInit !== null) {
this.declarationInit.deoptimizePath([UnknownKey, UnknownKey]);

@ -8,8 +8,8 @@ import PrivateIdentifier from './PrivateIdentifier';
import {
ExpressionEntity,
LiteralValueOrUnknown,
UnknownValue,
UNKNOWN_EXPRESSION
UNKNOWN_EXPRESSION,
UnknownValue
} from './shared/Expression';
import { ExpressionNode, NodeBase } from './shared/Node';
@ -20,7 +20,7 @@ export default class PropertyDefinition extends NodeBase {
type!: NodeType.tPropertyDefinition;
value!: ExpressionNode | null;
deoptimizePath(path: ObjectPath) {
deoptimizePath(path: ObjectPath): void {
this.value?.deoptimizePath(path);
}
@ -29,7 +29,7 @@ export default class PropertyDefinition extends NodeBase {
path: ObjectPath,
thisParameter: ExpressionEntity,
recursionTracker: PathTracker
) {
): void {
this.value?.deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker);
}
@ -73,7 +73,7 @@ export default class PropertyDefinition extends NodeBase {
path: ObjectPath,
callOptions: CallOptions,
context: HasEffectsContext
) {
): boolean {
return !this.value || this.value.hasEffectsWhenCalledAtPath(path, callOptions, context);
}
}

@ -13,7 +13,7 @@ export default class ReturnStatement extends StatementBase {
argument!: ExpressionNode | null;
type!: NodeType.tReturnStatement;
hasEffects(context: HasEffectsContext) {
hasEffects(context: HasEffectsContext): boolean {
if (
!context.ignore.returnAwaitYield ||
(this.argument !== null && this.argument.hasEffects(context))
@ -23,7 +23,7 @@ export default class ReturnStatement extends StatementBase {
return false;
}
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) {
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void {
this.included = true;
if (this.argument) {
this.argument.include(context, includeChildrenRecursively);
@ -31,11 +31,11 @@ export default class ReturnStatement extends StatementBase {
context.brokenFlow = BROKEN_FLOW_ERROR_RETURN_LABEL;
}
initialise() {
initialise(): void {
this.scope.addReturnExpression(this.argument || UNKNOWN_EXPRESSION);
}
render(code: MagicString, options: RenderOptions) {
render(code: MagicString, options: RenderOptions): void {
if (this.argument) {
this.argument.render(code, options, { preventASI: true });
if (this.argument.start === this.start + 6 /* 'return'.length */) {

@ -21,7 +21,7 @@ export default class SequenceExpression extends NodeBase {
expressions!: ExpressionNode[];
type!: NodeType.tSequenceExpression;
deoptimizePath(path: ObjectPath) {
deoptimizePath(path: ObjectPath): void {
if (path.length > 0) this.expressions[this.expressions.length - 1].deoptimizePath(path);
}
@ -30,9 +30,14 @@ export default class SequenceExpression extends NodeBase {
path: ObjectPath,
thisParameter: ExpressionEntity,
recursionTracker: PathTracker
) {
): void {
if (event === EVENT_CALLED || path.length > 0) {
this.expressions[this.expressions.length - 1].deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker);
this.expressions[this.expressions.length - 1].deoptimizeThisOnEventAtPath(
event,
path,
thisParameter,
recursionTracker
);
}
}
@ -81,7 +86,7 @@ export default class SequenceExpression extends NodeBase {
);
}
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) {
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void {
this.included = true;
for (let i = 0; i < this.expressions.length - 1; i++) {
const node = this.expressions[i];
@ -95,7 +100,7 @@ export default class SequenceExpression extends NodeBase {
code: MagicString,
options: RenderOptions,
{ renderedParentType, isCalleeOfRenderedParent, preventASI }: NodeRenderOptions = BLANK
) {
): void {
let includedNodes = 0;
for (const { node, start, end } of getCommaSeparatedNodesWithBoundaries(
this.expressions,

@ -9,9 +9,19 @@ export default class SpreadElement extends NodeBase {
type!: NodeType.tSpreadElement;
protected deoptimized = false;
deoptimizeThisOnEventAtPath(event: NodeEvent, path: ObjectPath, thisParameter: ExpressionEntity, recursionTracker: PathTracker) {
deoptimizeThisOnEventAtPath(
event: NodeEvent,
path: ObjectPath,
thisParameter: ExpressionEntity,
recursionTracker: PathTracker
): void {
if (path.length > 0) {
this.argument.deoptimizeThisOnEventAtPath(event, [UnknownKey, ...path], thisParameter, recursionTracker)
this.argument.deoptimizeThisOnEventAtPath(
event,
[UnknownKey, ...path],
thisParameter,
recursionTracker
);
}
}

@ -8,15 +8,15 @@ export default class Super extends NodeBase {
variable!: ThisVariable;
bind() {
bind(): void {
this.variable = this.scope.findVariable('this') as ThisVariable;
}
deoptimizePath(path: ObjectPath) {
deoptimizePath(path: ObjectPath): void {
this.variable.deoptimizePath(path);
}
include() {
include(): void {
if (!this.included) {
this.included = true;
this.context.includeVariableInModule(this.variable);

@ -24,7 +24,7 @@ export default class SwitchCase extends NodeBase {
return false;
}
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) {
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void {
this.included = true;
if (this.test) this.test.include(context, includeChildrenRecursively);
for (const node of this.consequent) {
@ -33,7 +33,7 @@ export default class SwitchCase extends NodeBase {
}
}
render(code: MagicString, options: RenderOptions, nodeRenderOptions?: NodeRenderOptions) {
render(code: MagicString, options: RenderOptions, nodeRenderOptions?: NodeRenderOptions): void {
if (this.consequent.length) {
this.test && this.test.render(code, options);
const testEnd = this.test

@ -9,8 +9,8 @@ import {
import BlockScope from '../scopes/BlockScope';
import Scope from '../scopes/Scope';
import * as NodeType from './NodeType';
import { ExpressionNode, IncludeChildren, StatementBase } from './shared/Node';
import SwitchCase from './SwitchCase';
import { ExpressionNode, IncludeChildren, StatementBase } from './shared/Node';
export default class SwitchStatement extends StatementBase {
cases!: SwitchCase[];
@ -19,11 +19,11 @@ export default class SwitchStatement extends StatementBase {
private defaultCase!: number | null;
createScope(parentScope: Scope) {
createScope(parentScope: Scope): void {
this.scope = new BlockScope(parentScope);
}
hasEffects(context: HasEffectsContext) {
hasEffects(context: HasEffectsContext): boolean {
if (this.discriminant.hasEffects(context)) return true;
const {
brokenFlow,
@ -43,7 +43,7 @@ export default class SwitchStatement extends StatementBase {
return false;
}
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) {
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void {
this.included = true;
this.discriminant.include(context, includeChildrenRecursively);
const { brokenFlow } = context;
@ -78,7 +78,7 @@ export default class SwitchStatement extends StatementBase {
}
}
initialise() {
initialise(): void {
for (let caseIndex = 0; caseIndex < this.cases.length; caseIndex++) {
if (this.cases[caseIndex].test === null) {
this.defaultCase = caseIndex;
@ -88,7 +88,7 @@ export default class SwitchStatement extends StatementBase {
this.defaultCase = null;
}
render(code: MagicString, options: RenderOptions) {
render(code: MagicString, options: RenderOptions): void {
this.discriminant.render(code, options);
if (this.cases.length > 0) {
renderStatementList(this.cases, code, this.cases[0].start, this.end - 1, options);

@ -3,8 +3,8 @@ import { HasEffectsContext } from '../ExecutionContext';
import { EMPTY_PATH } from '../utils/PathTracker';
import Identifier from './Identifier';
import * as NodeType from './NodeType';
import { ExpressionNode, NodeBase } from './shared/Node';
import TemplateLiteral from './TemplateLiteral';
import { ExpressionNode, NodeBase } from './shared/Node';
export default class TaggedTemplateExpression extends NodeBase {
quasi!: TemplateLiteral;
@ -13,7 +13,7 @@ export default class TaggedTemplateExpression extends NodeBase {
private callOptions!: CallOptions;
bind() {
bind(): void {
super.bind();
if (this.tag.type === NodeType.Identifier) {
const name = (this.tag as Identifier).name;
@ -23,7 +23,7 @@ export default class TaggedTemplateExpression extends NodeBase {
this.context.warn(
{
code: 'CANNOT_CALL_NAMESPACE',
message: `Cannot call a namespace ('${name}')`,
message: `Cannot call a namespace ('${name}')`
},
this.start
);
@ -34,7 +34,7 @@ export default class TaggedTemplateExpression extends NodeBase {
{
code: 'EVAL',
message: `Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification`,
url: 'https://rollupjs.org/guide/en/#avoiding-eval',
url: 'https://rollupjs.org/guide/en/#avoiding-eval'
},
this.start
);
@ -42,18 +42,18 @@ export default class TaggedTemplateExpression extends NodeBase {
}
}
hasEffects(context: HasEffectsContext) {
hasEffects(context: HasEffectsContext): boolean {
return (
super.hasEffects(context) ||
this.tag.hasEffectsWhenCalledAtPath(EMPTY_PATH, this.callOptions, context)
);
}
initialise() {
initialise(): void {
this.callOptions = {
args: NO_ARGS,
thisParam: null,
withNew: false,
withNew: false
};
}
}

@ -10,20 +10,20 @@ export default class TemplateElement extends NodeBase {
};
// Do not try to bind value
bind() {}
bind(): void {}
hasEffects() {
hasEffects(): boolean {
return false;
}
include() {
include(): void {
this.included = true;
}
parseNode(esTreeNode: GenericEsTreeNode) {
parseNode(esTreeNode: GenericEsTreeNode): void {
this.value = esTreeNode.value;
super.parseNode(esTreeNode);
}
render() {}
render(): void {}
}

@ -2,9 +2,9 @@ import MagicString from 'magic-string';
import { RenderOptions } from '../../utils/renderHelpers';
import { ObjectPath } from '../utils/PathTracker';
import * as NodeType from './NodeType';
import TemplateElement from './TemplateElement';
import { LiteralValueOrUnknown, UnknownValue } from './shared/Expression';
import { ExpressionNode, NodeBase } from './shared/Node';
import TemplateElement from './TemplateElement';
export default class TemplateLiteral extends NodeBase {
expressions!: ExpressionNode[];
@ -18,7 +18,7 @@ export default class TemplateLiteral extends NodeBase {
return this.quasis[0].value.cooked;
}
render(code: MagicString, options: RenderOptions) {
render(code: MagicString, options: RenderOptions): void {
(code.indentExclusionRanges as [number, number][]).push([this.start, this.end] as [
number,
number

@ -14,11 +14,11 @@ export default class ThisExpression extends NodeBase {
variable!: Variable;
private alias!: string | null;
bind() {
bind(): void {
this.variable = this.scope.findVariable('this');
}
deoptimizePath(path: ObjectPath) {
deoptimizePath(path: ObjectPath): void {
this.variable.deoptimizePath(path);
}
@ -27,7 +27,7 @@ export default class ThisExpression extends NodeBase {
path: ObjectPath,
thisParameter: ExpressionEntity,
recursionTracker: PathTracker
) {
): void {
this.variable.deoptimizeThisOnEventAtPath(
event,
path,
@ -45,14 +45,14 @@ export default class ThisExpression extends NodeBase {
return this.variable.hasEffectsWhenAssignedAtPath(path, context);
}
include() {
include(): void {
if (!this.included) {
this.included = true;
this.context.includeVariableInModule(this.variable);
}
}
initialise() {
initialise(): void {
this.alias =
this.scope.findLexicalBoundary() instanceof ModuleScope ? this.context.moduleContext : null;
if (this.alias === 'undefined') {
@ -67,7 +67,7 @@ export default class ThisExpression extends NodeBase {
}
}
render(code: MagicString) {
render(code: MagicString): void {
if (this.alias !== null) {
code.overwrite(this.start, this.end, this.alias, {
contentOnly: false,

@ -8,17 +8,17 @@ export default class ThrowStatement extends StatementBase {
argument!: ExpressionNode;
type!: NodeType.tThrowStatement;
hasEffects() {
hasEffects(): boolean {
return true;
}
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) {
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void {
this.included = true;
this.argument.include(context, includeChildrenRecursively);
context.brokenFlow = BROKEN_FLOW_ERROR_RETURN_LABEL;
}
render(code: MagicString, options: RenderOptions) {
render(code: MagicString, options: RenderOptions): void {
this.argument.render(code, options, { preventASI: true });
if (this.argument.start === this.start + 5 /* 'throw'.length */) {
code.prependLeft(this.start + 5, ' ');

@ -3,7 +3,7 @@ import { HasEffectsContext, InclusionContext } from '../ExecutionContext';
import BlockStatement from './BlockStatement';
import CatchClause from './CatchClause';
import * as NodeType from './NodeType';
import { IncludeChildren, INCLUDE_PARAMETERS, StatementBase } from './shared/Node';
import { INCLUDE_PARAMETERS, IncludeChildren, StatementBase } from './shared/Node';
export default class TryStatement extends StatementBase {
block!: BlockStatement;
@ -23,7 +23,7 @@ export default class TryStatement extends StatementBase {
);
}
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) {
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void {
const tryCatchDeoptimization = (this.context.options.treeshake as NormalizedTreeshakingOptions)
?.tryCatchDeoptimization;
const { brokenFlow } = context;

@ -48,7 +48,7 @@ export default class UnaryExpression extends NodeBase {
);
}
hasEffectsWhenAccessedAtPath(path: ObjectPath) {
hasEffectsWhenAccessedAtPath(path: ObjectPath): boolean {
if (this.operator === 'void') {
return path.length > 0;
}

@ -2,11 +2,11 @@ import { InclusionContext } from '../ExecutionContext';
import { NodeBase } from './shared/Node';
export default class UnknownNode extends NodeBase {
hasEffects() {
hasEffects(): boolean {
return true;
}
include(context: InclusionContext) {
include(context: InclusionContext): void {
super.include(context, true);
}
}

@ -25,11 +25,11 @@ export default class UpdateExpression extends NodeBase {
);
}
hasEffectsWhenAccessedAtPath(path: ObjectPath) {
hasEffectsWhenAccessedAtPath(path: ObjectPath): boolean {
return path.length > 1;
}
render(code: MagicString, options: RenderOptions) {
render(code: MagicString, options: RenderOptions): void {
this.argument.render(code, options);
if (options.format === 'system') {
const variable = this.argument.variable;
@ -80,7 +80,7 @@ export default class UpdateExpression extends NodeBase {
}
}
protected applyDeoptimizations() {
protected applyDeoptimizations(): void {
this.deoptimized = true;
this.argument.deoptimizePath(EMPTY_PATH);
if (this.argument instanceof Identifier) {

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save