Skip to content

Commit

Permalink
Merge branch 'master' into remove-array-group
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Jan 2, 2023
2 parents a74df97 + bceb353 commit cceeeeb
Show file tree
Hide file tree
Showing 38 changed files with 7,307 additions and 7,018 deletions.
22 changes: 12 additions & 10 deletions .eslintrc.js
Expand Up @@ -9,8 +9,9 @@ module.exports = {
'plugin:@typescript-eslint/recommended',
'prettier',
'plugin:prettier/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
// Disabled until security issues of eslint-plugin-import have been resolved
// 'plugin:import/recommended',
// 'plugin:import/typescript',
'plugin:unicorn/recommended'
],
ignorePatterns: [
Expand Down Expand Up @@ -80,14 +81,15 @@ module.exports = {
],
'arrow-body-style': ['error', 'as-needed'],
'dot-notation': 'error',
'import/no-unresolved': [
'error',
{
// 'fsevents' is ony available on macOS, and not installed on linux/windows
ignore: ['fsevents', 'help.md', 'is-reference', 'package.json', 'types']
}
],
'import/order': ['error', { alphabetize: { order: 'asc' } }],
// Disabled until security issues of eslint-plugin-import have been resolved
// 'import/no-unresolved': [
// 'error',
// {
// // 'fsevents' is ony available on macOS, and not installed on linux/windows
// ignore: ['fsevents', 'help.md', 'is-reference', 'package.json', 'types']
// }
// ],
// 'import/order': ['error', { alphabetize: { order: 'asc' } }],
'no-constant-condition': ['error', { checkLoops: false }],
'no-prototype-builtins': 'off',
'object-shorthand': 'error',
Expand Down
29 changes: 29 additions & 0 deletions LICENSE.md
Expand Up @@ -16,6 +16,35 @@ The published Rollup artifact additionally contains code with the following lice
MIT, ISC

# Bundled dependencies:
## @jridgewell/sourcemap-codec
License: MIT
By: Rich Harris
Repository: git+https://github.com/jridgewell/sourcemap-codec.git

> The MIT License
>
> Copyright (c) 2015 Rich Harris
>
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> THE SOFTWARE.
---------------------------------------

## @rollup/pluginutils
License: MIT
By: Rich Harris
Expand Down
29 changes: 29 additions & 0 deletions browser/LICENSE.md
Expand Up @@ -16,6 +16,35 @@ The published Rollup artifact additionally contains code with the following lice
MIT, ISC

# Bundled dependencies:
## @jridgewell/sourcemap-codec
License: MIT
By: Rich Harris
Repository: git+https://github.com/jridgewell/sourcemap-codec.git

> The MIT License
>
> Copyright (c) 2015 Rich Harris
>
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> THE SOFTWARE.
---------------------------------------

## @rollup/pluginutils
License: MIT
By: Rich Harris
Expand Down
8 changes: 3 additions & 5 deletions browser/src/fs.ts
@@ -1,7 +1,5 @@
import { throwNoFileSystem } from './error';

export const promises = {
mkdir: throwNoFileSystem('fs.mkdir'),
readFile: throwNoFileSystem('fs.readFile'),
writeFile: throwNoFileSystem('fs.writeFile')
};
export const mkdir = throwNoFileSystem('fs.mkdir');
export const readFile = throwNoFileSystem('fs.readFile');
export const writeFile = throwNoFileSystem('fs.writeFile');
2 changes: 1 addition & 1 deletion browser/src/performance.ts
@@ -1,5 +1,5 @@
const global =
typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : {};
typeof globalThis === 'undefined' ? (typeof window === 'undefined' ? {} : window) : globalThis;

export default 'performance' in global
? performance
Expand Down
8 changes: 4 additions & 4 deletions build-plugins/generate-license-file.ts
@@ -1,4 +1,4 @@
import { promises as fs } from 'node:fs';
import { readFile, writeFile } from 'node:fs/promises';
import { join } from 'node:path';
import type { PluginImpl } from 'rollup';
import license, { type Dependency, type Person } from 'rollup-plugin-license';
Expand All @@ -7,7 +7,7 @@ async function generateLicenseFile(
directory: string,
dependencies: readonly Dependency[]
): Promise<void> {
const coreLicense = await fs.readFile('LICENSE-CORE.md', 'utf8');
const coreLicense = await readFile('LICENSE-CORE.md', 'utf8');
const licenses = new Set<string>();
const dependencyLicenseTexts = [...dependencies]
.filter(({ name }) => name !== '@rollup/browser')
Expand Down Expand Up @@ -58,9 +58,9 @@ async function generateLicenseFile(
`# Bundled dependencies:\n` +
dependencyLicenseTexts;
const licenseFile = join(directory, 'LICENSE.md');
const existingLicenseText = await fs.readFile(licenseFile, 'utf8');
const existingLicenseText = await readFile(licenseFile, 'utf8');
if (existingLicenseText !== licenseText) {
await fs.writeFile(licenseFile, licenseText);
await writeFile(licenseFile, licenseText);
console.warn('LICENSE.md updated. You should commit the updated file.');
}
}
Expand Down
4 changes: 2 additions & 2 deletions build-plugins/get-banner.ts
@@ -1,5 +1,5 @@
import { exec } from 'node:child_process';
import { promises as fs } from 'node:fs';
import { readFile } from 'node:fs/promises';
import { env } from 'node:process';
import { promisify } from 'node:util';

Expand Down Expand Up @@ -31,6 +31,6 @@ export default function getBanner(): Promise<string> {
console.error('Could not determine commit hash:', error);
return 'unknown';
}),
fs.readFile(new URL('../package.json', import.meta.url), 'utf8')
readFile(new URL('../package.json', import.meta.url), 'utf8')
]).then(([commit, package_]) => generateBanner(commit, JSON.parse(package_).version)));
}
4 changes: 2 additions & 2 deletions cli/run/getConfigPath.ts
@@ -1,4 +1,4 @@
import { promises as fs } from 'node:fs';
import { readdir } from 'node:fs/promises';
import { resolve } from 'node:path';
import { cwd } from 'node:process';
import { errorMissingExternalConfig } from '../../src/utils/error';
Expand Down Expand Up @@ -31,7 +31,7 @@ export async function getConfigPath(commandConfig: string | true): Promise<strin
}

async function findConfigFileNameInCwd(): Promise<string> {
const filesInWorkingDirectory = new Set(await fs.readdir(cwd()));
const filesInWorkingDirectory = new Set(await readdir(cwd()));
for (const extension of ['mjs', 'cjs', 'ts']) {
const fileName = `${DEFAULT_CONFIG_BASE}.${extension}`;
if (filesInWorkingDirectory.has(fileName)) return fileName;
Expand Down
6 changes: 3 additions & 3 deletions cli/run/loadConfigFile.ts
@@ -1,4 +1,4 @@
import { promises as fs } from 'node:fs';
import { unlink, writeFile } from 'node:fs/promises';
import { dirname, isAbsolute, join } from 'node:path';
import process from 'node:process';
import { pathToFileURL } from 'node:url';
Expand Down Expand Up @@ -132,12 +132,12 @@ async function loadConfigFromWrittenFile(
bundledFileName: string,
bundledCode: string
): Promise<unknown> {
await fs.writeFile(bundledFileName, bundledCode);
await writeFile(bundledFileName, bundledCode);
try {
return (await import(pathToFileURL(bundledFileName).href)).default;
} finally {
// Not awaiting here saves some ms while potentially hiding a non-critical error
fs.unlink(bundledFileName);
unlink(bundledFileName);
}
}

Expand Down
2 changes: 1 addition & 1 deletion cli/run/timings.ts
Expand Up @@ -5,7 +5,7 @@ import { bold, underline } from '../../src/utils/colors';
export function printTimings(timings: SerializedTimings): void {
for (const [label, [time, memory, total]] of Object.entries(timings)) {
const appliedColor =
label[0] === '#' ? (label[1] !== '#' ? underline : bold) : (text: string) => text;
label[0] === '#' ? (label[1] === '#' ? bold : underline) : (text: string) => text;
const row = `${label}: ${time.toFixed(0)}ms, ${prettyBytes(memory)} / ${prettyBytes(total)}`;
console.info(appliedColor(row));
}
Expand Down
5 changes: 3 additions & 2 deletions cli/run/watch-cli.ts
@@ -1,4 +1,5 @@
import { promises as fs, type FSWatcher } from 'node:fs';
import type { FSWatcher } from 'node:fs';
import { readFile } from 'node:fs/promises';
import process from 'node:process';
import chokidar from 'chokidar';
import dateTime from 'date-time';
Expand Down Expand Up @@ -43,7 +44,7 @@ export async function watch(command: Record<string, any>): Promise<void> {

async function reloadConfigFile() {
try {
const newConfigFileData = await fs.readFile(configFile, 'utf8');
const newConfigFileData = await readFile(configFile, 'utf8');
if (newConfigFileData === configFileData) {
return;
}
Expand Down
8 changes: 6 additions & 2 deletions docs/999-big-list-of-options.md
Expand Up @@ -268,7 +268,7 @@ The following will add minification to one of the outputs:
```js
// rollup.config.js
import { terser } from 'rollup-plugin-terser';
import terser from '@rollup/plugin-terser';

export default {
input: 'main.js',
Expand Down Expand Up @@ -301,7 +301,11 @@ const isProduction = process.env.NODE_ENV === 'production';

export default (async () => ({
input: 'main.js',
plugins: [resolve(), commonjs(), isProduction && (await import('rollup-plugin-terser')).terser()],
plugins: [
resolve(),
commonjs(),
isProduction && (await import('@rollup/plugin-terser')).default()
],
output: {
file: 'bundle.js',
format: 'cjs'
Expand Down

0 comments on commit cceeeeb

Please sign in to comment.