This repository was archived by the owner on Nov 8, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +43
-2
lines changed
Expand file tree Collapse file tree 2 files changed +43
-2
lines changed Original file line number Diff line number Diff line change 33 "version" : " 0.0.0-semantically-released" ,
44 "description" : " Validator of HTTP transactions (JavaScript implementation)" ,
55 "main" : " build/index.js" ,
6+ "unpkg" : " build/index.umd.js" ,
7+ "jsdelivr" : " build/index.umd.js" ,
68 "typings" : " typings.d.ts" ,
79 "engines" : {
810 "node" : " >= 10.18"
Original file line number Diff line number Diff line change @@ -5,10 +5,12 @@ const { terser } = require('rollup-plugin-terser');
55
66const packageJson = require ( './package.json' ) ;
77
8+ const dependencies = Object . keys ( packageJson . dependencies ) ;
9+
810const buildUmd = {
911 input : 'lib/index.js' ,
1012 output : {
11- file : packageJson . main ,
13+ file : packageJson . unpkg ,
1214 format : 'umd' ,
1315 name : 'gavel' ,
1416 exports : 'named' ,
@@ -28,4 +30,41 @@ const buildUmd = {
2830 ]
2931} ;
3032
31- module . exports = [ buildUmd ] ;
33+ const buildCjs = {
34+ input : 'lib/index.js' ,
35+ output : {
36+ file : packageJson . main ,
37+ format : 'cjs' ,
38+ exports : 'named'
39+ } ,
40+ external : ( id ) => {
41+ if ( dependencies . includes ( id ) ) {
42+ return true ;
43+ }
44+
45+ // url is a built-in module and should not be bundled either
46+ if ( id === 'url' ) {
47+ return true ;
48+ }
49+
50+ // There are some deep imports of ajv files
51+ if ( id . startsWith ( 'ajv/' ) ) {
52+ return true ;
53+ }
54+
55+ return false ;
56+ } ,
57+ plugins : [
58+ resolve ( {
59+ browser : false ,
60+
61+ // Forbid bundling of NodeJS built-ins (i.e. "fs", "path").
62+ // Throw when such modules are present in the bundle.
63+ preferBuiltins : false
64+ } ) ,
65+ json ( ) ,
66+ commonjs ( )
67+ ]
68+ } ;
69+
70+ module . exports = [ buildUmd , buildCjs ] ;
You can’t perform that action at this time.
0 commit comments