chore: augment build script to build forked modules into correct bundles

This commit is contained in:
steveluscher 2022-05-25 22:21:51 -07:00 committed by Steven Luscher
parent 7d202a0be2
commit 994ae755a9
4 changed files with 235 additions and 2195 deletions

2385
web3.js/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -82,7 +82,7 @@
"@babel/register": "^7.12.13",
"@commitlint/config-conventional": "^15.0.0",
"@commitlint/travis-cli": "^17.0.0",
"@rollup/plugin-alias": "^3.1.2",
"@rollup/plugin-alias": "^3.1.9",
"@rollup/plugin-babel": "^5.2.3",
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-json": "^4.1.0",

View File

@ -1,6 +1,9 @@
import alias from '@rollup/plugin-alias';
import babel from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import * as fs from 'fs';
import json from '@rollup/plugin-json';
import path from 'path';
import nodeResolve from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import {terser} from 'rollup-plugin-terser';
@ -15,6 +18,41 @@ function generateConfig(configType, format) {
const config = {
input: 'src/index.ts',
plugins: [
alias({
entries: [
{
find: /^\./, // Relative paths.
replacement: '.',
async customResolver(source, importer, options) {
const resolved = await this.resolve(source, importer, {
skipSelf: true,
...options,
});
if (resolved == null) {
return;
}
const {id: resolvedId} = resolved;
const directory = path.dirname(resolvedId);
const moduleFilename = path.basename(resolvedId);
const forkPath = path.join(
directory,
'__forks__',
configType,
moduleFilename,
);
const hasForkCacheKey = `has_fork:${forkPath}`;
let hasFork = this.cache.get(hasForkCacheKey);
if (hasFork === undefined) {
hasFork = fs.existsSync(forkPath);
this.cache.set(hasForkCacheKey, hasFork);
}
if (hasFork) {
return forkPath;
}
},
},
],
}),
commonjs(),
nodeResolve({
browser,

View File

@ -1521,9 +1521,10 @@
dependencies:
"@octokit/openapi-types" "^11.2.0"
"@rollup/plugin-alias@^3.1.2":
"@rollup/plugin-alias@^3.1.9":
version "3.1.9"
resolved "https://registry.npmjs.org/@rollup/plugin-alias/-/plugin-alias-3.1.9.tgz"
resolved "https://registry.npmjs.org/@rollup/plugin-alias/-/plugin-alias-3.1.9.tgz#a5d267548fe48441f34be8323fb64d1d4a1b3fdf"
integrity sha512-QI5fsEvm9bDzt32k39wpOwZhVzRcL5ydcffUHMyLVaVaLeC70I8TJZ17F1z1eMoLu4E/UOcH9BWVkKpIKdrfiw==
dependencies:
slash "^3.0.0"