mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2025-11-24 14:35:51 +00:00
* Bump the dev-dependencies group with 10 updates Bumps the dev-dependencies group with 10 updates: | Package | From | To | | --- | --- | --- | | [@eslint/js](https://github.com/eslint/eslint/tree/HEAD/packages/js) | `9.37.0` | `9.38.0` | | [@openpgp/web-stream-tools](https://github.com/openpgpjs/web-stream-tools) | `0.2.0` | `0.2.1` | | [@rollup/plugin-commonjs](https://github.com/rollup/plugins/tree/HEAD/packages/commonjs) | `28.0.7` | `28.0.9` | | [@rollup/plugin-replace](https://github.com/rollup/plugins/tree/HEAD/packages/replace) | `6.0.2` | `6.0.3` | | [@rollup/plugin-typescript](https://github.com/rollup/plugins/tree/HEAD/packages/typescript) | `12.1.4` | `12.3.0` | | [@stylistic/eslint-plugin](https://github.com/eslint-stylistic/eslint-stylistic/tree/HEAD/packages/eslint-plugin) | `5.4.0` | `5.5.0` | | [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) | `24.7.2` | `24.9.2` | | [eslint](https://github.com/eslint/eslint) | `9.37.0` | `9.38.0` | | [rollup](https://github.com/rollup/rollup) | `4.52.4` | `4.52.5` | | [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint) | `8.46.1` | `8.46.2` | Updates `@eslint/js` from 9.37.0 to 9.38.0 - [Release notes](https://github.com/eslint/eslint/releases) - [Commits](https://github.com/eslint/eslint/commits/v9.38.0/packages/js) Updates `@openpgp/web-stream-tools` from 0.2.0 to 0.2.1 - [Commits](https://github.com/openpgpjs/web-stream-tools/compare/v0.2.0...v0.2.1) Updates `@rollup/plugin-commonjs` from 28.0.7 to 28.0.9 - [Changelog](https://github.com/rollup/plugins/blob/master/packages/commonjs/CHANGELOG.md) - [Commits](https://github.com/rollup/plugins/commits/commonjs-v28.0.9/packages/commonjs) Updates `@rollup/plugin-replace` from 6.0.2 to 6.0.3 - [Changelog](https://github.com/rollup/plugins/blob/master/packages/replace/CHANGELOG.md) - [Commits](https://github.com/rollup/plugins/commits/babel-v6.0.3/packages/replace) Updates `@rollup/plugin-typescript` from 12.1.4 to 12.3.0 - [Changelog](https://github.com/rollup/plugins/blob/master/packages/typescript/CHANGELOG.md) - [Commits](https://github.com/rollup/plugins/commits/typescript-v12.3.0/packages/typescript) Updates `@stylistic/eslint-plugin` from 5.4.0 to 5.5.0 - [Release notes](https://github.com/eslint-stylistic/eslint-stylistic/releases) - [Changelog](https://github.com/eslint-stylistic/eslint-stylistic/blob/main/CHANGELOG.md) - [Commits](https://github.com/eslint-stylistic/eslint-stylistic/commits/v5.5.0/packages/eslint-plugin) Updates `@types/node` from 24.7.2 to 24.9.2 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Updates `eslint` from 9.37.0 to 9.38.0 - [Release notes](https://github.com/eslint/eslint/releases) - [Commits](https://github.com/eslint/eslint/compare/v9.37.0...v9.38.0) Updates `rollup` from 4.52.4 to 4.52.5 - [Release notes](https://github.com/rollup/rollup/releases) - [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md) - [Commits](https://github.com/rollup/rollup/compare/v4.52.4...v4.52.5) Updates `typescript-eslint` from 8.46.1 to 8.46.2 - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.46.2/packages/typescript-eslint) --- updated-dependencies: - dependency-name: "@eslint/js" dependency-version: 9.38.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-dependencies - dependency-name: "@openpgp/web-stream-tools" dependency-version: 0.2.1 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-dependencies - dependency-name: "@rollup/plugin-commonjs" dependency-version: 28.0.9 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-dependencies - dependency-name: "@rollup/plugin-replace" dependency-version: 6.0.3 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-dependencies - dependency-name: "@rollup/plugin-typescript" dependency-version: 12.3.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-dependencies - dependency-name: "@stylistic/eslint-plugin" dependency-version: 5.5.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-dependencies - dependency-name: "@types/node" dependency-version: 24.9.2 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-dependencies - dependency-name: eslint dependency-version: 9.38.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-dependencies - dependency-name: rollup dependency-version: 4.52.5 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-dependencies - dependency-name: typescript-eslint dependency-version: 8.46.2 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-dependencies ... Signed-off-by: dependabot[bot] <support@github.com> * Tests: Rollup: drop unused rollup-typescript exception It messed with the resolution of tweet-nacl for some reason, where node:crypto references weren't properly dropped. * Tests: Rollup: drop leftover requireReturnsDefault option in commonjs plugin * Fix TS errors in eslint config file --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: larabr <7375870+larabr@users.noreply.github.com>
192 lines
6.9 KiB
JavaScript
192 lines
6.9 KiB
JavaScript
import { builtinModules } from 'module';
|
|
import { readFileSync } from 'fs';
|
|
|
|
import alias from '@rollup/plugin-alias';
|
|
import resolve from '@rollup/plugin-node-resolve';
|
|
import commonjs from '@rollup/plugin-commonjs';
|
|
import replace from '@rollup/plugin-replace';
|
|
import terser from '@rollup/plugin-terser';
|
|
import { wasm } from '@rollup/plugin-wasm';
|
|
import typescript from '@rollup/plugin-typescript';
|
|
|
|
// ESlint does not support JSON module imports yet, see https://github.com/eslint/eslint/discussions/15305
|
|
// import pkg from './package.json' assert { type: 'json' };
|
|
const pkg = JSON.parse(readFileSync('./package.json'));
|
|
|
|
const nodeDependencies = Object.keys(pkg.dependencies || {});
|
|
const nodeBuiltinModules = builtinModules.concat(['module']);
|
|
|
|
const wasmOptions = {
|
|
node: { targetEnv: 'node' },
|
|
browser: { targetEnv: 'browser', maxFileSize: undefined } // always inlline (our wasm files are small)
|
|
};
|
|
|
|
const getChunkFileName = (chunkInfo, extension) => `[name].${extension}`;
|
|
|
|
/**
|
|
* Dynamically imported modules which expose an index file as entrypoint end up with a chunk named `index`
|
|
* by default. We want to preserve the module name instead.
|
|
*/
|
|
const setManualChunkName = chunkId => {
|
|
if (chunkId.includes('seek-bzip')) {
|
|
return 'seek-bzip';
|
|
} else if (chunkId.includes('argon2id')) {
|
|
return 'argon2id';
|
|
} else {
|
|
return undefined;
|
|
}
|
|
};
|
|
|
|
const banner =
|
|
`/*! OpenPGP.js v${pkg.version} - ` +
|
|
`${new Date().toISOString().split('T')[0]} - ` +
|
|
`this is LGPL licensed code, see LICENSE/our website ${pkg.homepage} for more information. */`;
|
|
|
|
const intro = "const globalThis = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};";
|
|
|
|
const terserOptions = {
|
|
ecma: 2017,
|
|
compress: {
|
|
unsafe: true
|
|
},
|
|
output: {
|
|
comments: '/^(?:!|#__)/',
|
|
preserve_annotations: true
|
|
}
|
|
};
|
|
|
|
const nodeBuild = {
|
|
input: 'src/index.js',
|
|
external: nodeBuiltinModules.concat(nodeDependencies),
|
|
output: [
|
|
{ file: 'dist/node/openpgp.cjs', format: 'cjs', name: pkg.name, banner, intro },
|
|
{ file: 'dist/node/openpgp.min.cjs', format: 'cjs', name: pkg.name, banner, intro, plugins: [terser(terserOptions)], sourcemap: true },
|
|
{ file: 'dist/node/openpgp.mjs', format: 'es', banner, intro },
|
|
{ file: 'dist/node/openpgp.min.mjs', format: 'es', banner, intro, plugins: [terser(terserOptions)], sourcemap: true }
|
|
].map(options => ({ ...options, inlineDynamicImports: true })),
|
|
plugins: [
|
|
resolve({
|
|
exportConditions: ['node'] // needed for resolution of noble-curves import of '@noble/crypto' in Node 18
|
|
}),
|
|
typescript({
|
|
compilerOptions: { outDir: './dist/node' } // temporary output location, needed to avoid js files being overwritten under `src`
|
|
}),
|
|
commonjs(),
|
|
replace({
|
|
'OpenPGP.js VERSION': `OpenPGP.js ${pkg.version}`
|
|
}),
|
|
wasm(wasmOptions.node)
|
|
]
|
|
};
|
|
|
|
const fullBrowserBuild = {
|
|
input: 'src/index.js',
|
|
external: nodeBuiltinModules.concat(nodeDependencies),
|
|
output: [
|
|
{ file: 'dist/openpgp.js', format: 'iife', name: pkg.name, banner, intro },
|
|
{ file: 'dist/openpgp.min.js', format: 'iife', name: pkg.name, banner, intro, plugins: [terser(terserOptions)], sourcemap: true },
|
|
{ file: 'dist/openpgp.mjs', format: 'es', banner, intro },
|
|
{ file: 'dist/openpgp.min.mjs', format: 'es', banner, intro, plugins: [terser(terserOptions)], sourcemap: true }
|
|
].map(options => ({ ...options, inlineDynamicImports: true })),
|
|
plugins: [
|
|
resolve({
|
|
browser: true
|
|
}),
|
|
typescript({
|
|
compilerOptions: { outDir: './dist' } // temporary output location, needed to avoid js files being overwritten under `src`
|
|
}),
|
|
commonjs({
|
|
ignore: nodeBuiltinModules.concat(nodeDependencies)
|
|
}),
|
|
replace({
|
|
'OpenPGP.js VERSION': `OpenPGP.js ${pkg.version}`,
|
|
"import { createRequire } from 'module';": 'const createRequire = () => () => {}',
|
|
delimiters: ['', '']
|
|
}),
|
|
wasm(wasmOptions.browser)
|
|
]
|
|
};
|
|
|
|
const lightweightBrowserBuild = {
|
|
input: 'src/index.js',
|
|
external: nodeBuiltinModules.concat(nodeDependencies),
|
|
output: [
|
|
{ entryFileNames: 'openpgp.mjs', chunkFileNames: chunkInfo => getChunkFileName(chunkInfo, 'mjs') },
|
|
{ entryFileNames: 'openpgp.min.mjs', chunkFileNames: chunkInfo => getChunkFileName(chunkInfo, 'min.mjs'), plugins: [terser(terserOptions)], sourcemap: true }
|
|
].map(options => ({ ...options, dir: 'dist/lightweight', manualChunks: setManualChunkName, format: 'es', banner, intro })),
|
|
preserveEntrySignatures: 'exports-only',
|
|
plugins: [
|
|
resolve({
|
|
browser: true
|
|
}),
|
|
typescript({
|
|
compilerOptions: { outDir: './dist/lightweight' }
|
|
}),
|
|
commonjs({
|
|
ignore: nodeBuiltinModules.concat(nodeDependencies)
|
|
}),
|
|
replace({
|
|
'OpenPGP.js VERSION': `OpenPGP.js ${pkg.version}`,
|
|
"import { createRequire } from 'module';": 'const createRequire = () => () => {}',
|
|
delimiters: ['', '']
|
|
}),
|
|
wasm(wasmOptions.browser)
|
|
]
|
|
};
|
|
|
|
const getBrowserTestBuild = useLightweightBuild => ({
|
|
input: 'test/unittests.js',
|
|
output: [
|
|
{ file: 'test/lib/unittests-bundle.js', format: 'es', intro, sourcemap: true, inlineDynamicImports: true }
|
|
],
|
|
external: nodeBuiltinModules.concat(nodeDependencies),
|
|
plugins: [
|
|
alias({
|
|
entries: {
|
|
openpgp: `./dist/${useLightweightBuild ? 'lightweight/' : ''}openpgp.mjs`
|
|
}
|
|
}),
|
|
resolve({
|
|
browser: true
|
|
}),
|
|
typescript({
|
|
compilerOptions: { outDir: './test/lib' }
|
|
}),
|
|
commonjs({
|
|
ignore: nodeBuiltinModules.concat(nodeDependencies)
|
|
}),
|
|
replace({
|
|
"import { createRequire } from 'module';": 'const createRequire = () => () => {}',
|
|
delimiters: ['', '']
|
|
}),
|
|
wasm(wasmOptions.browser)
|
|
]
|
|
});
|
|
|
|
/**
|
|
* Rollup CLI supports custom options; their name must start with `config`,
|
|
* e.g. see `--configDebug` example at
|
|
* https://rollupjs.org/command-line-interface/#configuration-files
|
|
*
|
|
* The custom options we support are:
|
|
* - "config-build-only": 'dist'|'node'|'lightweight'|'test'|string - to specify a build target;
|
|
* defaults to 'dist', which does not build tests;
|
|
* - "config-test-lightweight-build": Boolean - in the context of building browser tests,
|
|
* whether the lightweight build should be included instead of the standard one
|
|
*/
|
|
export default commandLineArgs => Object.assign([
|
|
nodeBuild,
|
|
fullBrowserBuild,
|
|
lightweightBrowserBuild,
|
|
getBrowserTestBuild(commandLineArgs['config-test-lightweight-build'])
|
|
].filter(rollupConfig => {
|
|
rollupConfig.output = rollupConfig.output.filter(output => {
|
|
return (output.file || output.dir + '/' + output.entryFileNames).includes(
|
|
commandLineArgs['config-build-only'] || 'dist' // Don't build test bundle by default.
|
|
);
|
|
});
|
|
return rollupConfig.output.length;
|
|
}), {
|
|
allow_empty: true // Fake option to trick rollup into accepting empty config array when filtered above.
|
|
});
|