Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
fix: web3.js browser cjs build (#23500)
Browse files Browse the repository at this point in the history
  • Loading branch information
jordaaash authored Mar 11, 2022
1 parent ccff006 commit 3cf31fa
Showing 1 changed file with 28 additions and 25 deletions.
53 changes: 28 additions & 25 deletions web3.js/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,34 @@ function generateConfig(configType, format) {
switch (configType) {
case 'browser':
switch (format) {
case 'esm': {
case 'iife': {
config.external = ['http', 'https'];

config.output = [
{
file: 'lib/index.iife.js',
format: 'iife',
name: 'solanaWeb3',
sourcemap: true,
},
{
file: 'lib/index.iife.min.js',
format: 'iife',
name: 'solanaWeb3',
sourcemap: true,
plugins: [terser({mangle: false, compress: false})],
},
];

break;
}
default: {
config.output = [
{
file: 'lib/index.browser.cjs.js',
format: 'cjs',
sourcemap: true,
},
{
file: 'lib/index.browser.esm.js',
format: 'es',
Expand Down Expand Up @@ -99,29 +125,6 @@ function generateConfig(configType, format) {

break;
}
case 'iife': {
config.external = ['http', 'https'];

config.output = [
{
file: 'lib/index.iife.js',
format: 'iife',
name: 'solanaWeb3',
sourcemap: true,
},
{
file: 'lib/index.iife.min.js',
format: 'iife',
name: 'solanaWeb3',
sourcemap: true,
plugins: [terser({mangle: false, compress: false})],
},
];

break;
}
default:
throw new Error(`Unknown format: ${format}`);
}

// TODO: Find a workaround to avoid resolving the following JSON file:
Expand Down Expand Up @@ -152,6 +155,6 @@ function generateConfig(configType, format) {

export default [
generateConfig('node'),
generateConfig('browser', 'esm'),
generateConfig('browser'),
generateConfig('browser', 'iife'),
];

0 comments on commit 3cf31fa

Please sign in to comment.