-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🏗️build (browser): add a browserify-based browser build, complete wit…
…h polyfills.
- Loading branch information
Showing
9 changed files
with
404 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,3 +36,5 @@ coverage | |
/examples | ||
/.github | ||
/lib/__tests__ | ||
/rollup.config.js | ||
/.prettierrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import replace from '@rollup/plugin-replace' | ||
import esbuild from 'rollup-plugin-esbuild' | ||
import node from '@rollup/plugin-node-resolve' | ||
import commonjs from '@rollup/plugin-commonjs' | ||
|
||
|
||
export default { | ||
input: './src/browser.ts', | ||
output: { file: './lib/browser.js', format: 'es', exports: 'named', sourcemap: true }, | ||
plugins: [ | ||
node({ | ||
preferBuiltins: false | ||
}), | ||
commonjs(), | ||
// Set some node specific globals | ||
replace({ | ||
values: { | ||
'process.env.NODE_DEBUG': false, | ||
'process.pid': 42, | ||
'process.nextTick': 'setTimeout', | ||
'process.stdout': 'null', | ||
'process.stderr': 'null', | ||
'process.env.READABLE_STREAM': 'false', | ||
'process.browser': 'true', | ||
'process.env.NODE_ENV': '"production"', | ||
'process': 'undefined' | ||
} | ||
}), | ||
esbuild({ | ||
target: 'es2017', | ||
minify: true | ||
}), | ||
// Map modules to polyfill | ||
{ | ||
name: 'module-map', | ||
resolveId(id) { | ||
if (id === 'vm') { | ||
return this.resolve('vm-browserify') | ||
} | ||
if (id === 'stream') { | ||
return this.resolve('stream-browserify') | ||
} | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import { Buffer } from 'buffer/'; | ||
|
||
(<any>globalThis).Buffer = Buffer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import './browser-polyfill'; | ||
export * from './index'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,9 @@ | |
}, | ||
"include": [ | ||
"src" | ||
], | ||
"exclude": [ | ||
"src/browser-polyfill.ts", | ||
"src/browser.ts", | ||
] | ||
} |
Oops, something went wrong.