-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bundle): change bundling configuration
- Loading branch information
Showing
23 changed files
with
835 additions
and
3,054 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import * as esbuild from 'esbuild'; | ||
import readPkg from 'read-pkg'; | ||
|
||
const pkg = readPkg.sync(); | ||
|
||
if (process.env.FORMAT !== 'cjs' && process.env.FORMAT !== 'esm') { | ||
console.log(`support "cjs" or "esm"`); | ||
console.log(`eg. FORMAT=cjs node esbuild.mjs`); | ||
|
||
process.exit(1); | ||
} | ||
|
||
console.log('esbuild start bundling'); | ||
console.log(`version: ${pkg.version}`); | ||
console.log(`FORMAT: ${process.env.FORMAT}`); | ||
console.log(`MINIFY: ${process.env.FORMAT}`); | ||
|
||
console.log('external: '); | ||
|
||
await esbuild.build({ | ||
entryPoints: ['src/index.ts'], | ||
target: 'es2021', | ||
bundle: true, | ||
sourcemap: true, | ||
platform: 'node', | ||
minify: process.env.MINIFY === 'true', | ||
outfile: process.env.FORMAT === 'cjs' ? 'dist/cjs/index.cjs' : 'dist/esm/index.mjs', | ||
format: process.env.FORMAT, | ||
external: [ | ||
...Object.keys(pkg.dependencies ?? {}), | ||
...Object.keys(pkg.devDependencies ?? {}), | ||
...Object.keys(pkg.peerDependencies ?? {}), | ||
], | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,28 @@ | ||
import { nodeResolve } from '@rollup/plugin-node-resolve'; | ||
import readPackage from 'read-pkg'; | ||
import { dts } from 'rollup-plugin-dts'; | ||
|
||
const pkg = readPackage.sync(); | ||
|
||
const resolveOnly = (module) => { | ||
return ( | ||
pkg?.dependencies?.[module] != null && | ||
pkg?.devDependencies?.[module] != null && | ||
pkg?.peerDependencies?.[module] != null | ||
); | ||
}; | ||
|
||
const config = [ | ||
{ | ||
input: 'dist/types/origin/index.d.ts', | ||
output: [{ file: 'dist/types/index.d.ts', format: 'esm' }], | ||
plugins: [ | ||
nodeResolve({ resolveOnly }), | ||
dts({ | ||
tsconfig: './tsconfig.dts.json', | ||
}), | ||
], | ||
}, | ||
]; | ||
|
||
export default config; |
This file was deleted.
Oops, something went wrong.
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
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,10 @@ | ||
const urlna = require('../../dist/cjs/index.cjs').urlna; | ||
|
||
const url = urlna('', 'hero/:hid/comic/:cid/name/:name', { | ||
name: 'ironman', | ||
hid: 1, | ||
cid: 13, | ||
tid: '72368bb0-a6cc-4fa1-9288-c903fd45c333', | ||
}); | ||
|
||
console.log(url); |
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,21 @@ | ||
const urlna = require('../../dist/cjs/index.cjs').urlna; | ||
|
||
const url01 = urlna('', 'heros/comics', { | ||
name: ['ironman', 'spiderman'], | ||
tid: '72368bb0-a6cc-4fa1-9288-c903fd45c333', | ||
}); | ||
|
||
const url02 = urlna( | ||
'', | ||
'heros/comics', | ||
{ | ||
name: ['ironman', 'spiderman'], | ||
tid: '72368bb0-a6cc-4fa1-9288-c903fd45c333', | ||
}, | ||
{ | ||
indices: false, | ||
}, | ||
); | ||
|
||
console.log(url01); | ||
console.log(url02); |
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,10 @@ | ||
import { urlna } from '../../dist/esm/index.mjs'; | ||
|
||
const url = urlna('', 'hero/:hid/comic/:cid/name/:name', { | ||
name: 'ironman', | ||
hid: 1, | ||
cid: 13, | ||
tid: '72368bb0-a6cc-4fa1-9288-c903fd45c333', | ||
}); | ||
|
||
console.log(url); |
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,21 @@ | ||
import { urlna } from '../../dist/esm/index.mjs'; | ||
|
||
const url01 = urlna('', 'heros/comics', { | ||
name: ['ironman', 'spiderman'], | ||
tid: '72368bb0-a6cc-4fa1-9288-c903fd45c333', | ||
}); | ||
|
||
const url02 = urlna( | ||
'', | ||
'heros/comics', | ||
{ | ||
name: ['ironman', 'spiderman'], | ||
tid: '72368bb0-a6cc-4fa1-9288-c903fd45c333', | ||
}, | ||
{ | ||
arrayFormat: 'repeat', | ||
}, | ||
); | ||
|
||
console.log(url01); | ||
console.log(url02); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.