-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1457 from pixiv/extended-collider-2-v3
Extended-collider-2-v3
- Loading branch information
Showing
203 changed files
with
3,968 additions
and
4,108 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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/packages/*/docs/ | ||
/packages/*/lib/ | ||
/packages/*/node_modules/ | ||
/packages/*/ts*/ | ||
/packages/*/types/ | ||
!/packages/types-*/types/ | ||
|
||
jest.config.js |
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,7 +36,6 @@ jobs: | |
path: | | ||
packages/*/lib/ | ||
packages/*/types/ | ||
packages/*/ts*/ | ||
lint: | ||
runs-on: ubuntu-latest | ||
|
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 |
---|---|---|
|
@@ -65,4 +65,3 @@ jobs: | |
path: | | ||
packages/*/lib/ | ||
packages/*/types/ | ||
packages/*/ts*/ |
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 |
---|---|---|
|
@@ -3,5 +3,5 @@ | |
/packages/*/node_modules | ||
/packages/*/docs | ||
/packages/*/lib | ||
/packages/*/ts*/ | ||
/packages/*/types | ||
/tmp |
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,134 @@ | ||
// @ts-check | ||
import esbuild from 'esbuild'; | ||
import path from 'node:path'; | ||
import fs from 'node:fs/promises'; | ||
|
||
// == envs ========================================================================================= | ||
const NODE_ENV = process.env.NODE_ENV; | ||
const DEV = NODE_ENV === 'development'; | ||
const SERVE = process.env.SERVE === '1'; | ||
const PORT = parseInt(process.env.PORT || '10001', 10); | ||
|
||
// == build ========================================================================================= | ||
|
||
const workDir = process.argv[2] ? path.join(process.cwd(), process.argv[2]) : process.cwd(); | ||
await buildPackage(workDir); | ||
|
||
// == implement ===================================================================================== | ||
|
||
/** | ||
* | ||
* @param {string} absWorkingDir | ||
*/ | ||
async function buildPackage(absWorkingDir) { | ||
/** | ||
* @type {{ name: string, version: string, description: string, module: string }} | ||
*/ | ||
const packageJson = JSON.parse(await fs.readFile(path.join(absWorkingDir, './package.json'), 'utf-8')); | ||
|
||
// == constants ==================================================================================== | ||
/** copyright text */ | ||
const copyright = '(c) 2019-2024 pixiv Inc.'; | ||
|
||
/** name of the license */ | ||
const licenseName = 'MIT License'; | ||
|
||
/** url of the license */ | ||
const licenseUri = 'https://github.com/pixiv/three-vrm/blob/release/LICENSE'; | ||
|
||
/** filename of output */ | ||
const filename = packageJson.name.split('/').at(-1) || 'index'; | ||
|
||
// == banner ======================================================================================= | ||
const bannerTextDev = `/*! | ||
* ${packageJson.name} v${packageJson.version} | ||
* ${packageJson.description} | ||
* | ||
* Copyright ${copyright} | ||
* ${packageJson.name} is distributed under ${licenseName} | ||
* ${licenseUri} | ||
*/`; | ||
|
||
const bannerTextProd = `/*! ${copyright} - ${licenseUri} */`; | ||
|
||
/** | ||
* @param {'esm' | 'cjs'} format | ||
*/ | ||
const entryPoints = (format) => { | ||
/** | ||
* Add suffix according to the format to the given basename of the output file. | ||
* @param {string} base Basename of the output file | ||
* @returns {string} `<base>[.module][.min]` | ||
*/ | ||
const addSuffix = (base) => { | ||
let outFilename = base + (format === 'esm' ? '.module' : ''); | ||
return outFilename + (DEV ? '' : '.min'); | ||
}; | ||
|
||
const needsNodesBuild = ['@pixiv/three-vrm', '@pixiv/three-vrm-materials-mtoon'].includes(packageJson.name); | ||
const extraEntryPoints = needsNodesBuild | ||
? { [addSuffix('nodes/index')]: 'src/nodes/index.ts' } | ||
: {}; | ||
|
||
return { | ||
entryPoints: { | ||
[addSuffix(filename)]: 'src/index.ts', | ||
...extraEntryPoints, | ||
}, | ||
format, | ||
}; | ||
}; | ||
|
||
/** | ||
* @type {import('esbuild').BuildOptions} | ||
*/ | ||
const buildOptions = { | ||
banner: { | ||
js: DEV ? bannerTextDev : bannerTextProd, | ||
}, | ||
bundle: true, | ||
target: 'es6', | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
loader: { '.frag': 'text', '.vert': 'text' }, | ||
sourcemap: DEV ? 'inline' : false, | ||
absWorkingDir, | ||
logLevel: 'info', | ||
color: true, | ||
minify: !DEV, | ||
external: ['three'], | ||
}; | ||
|
||
// == serve ======================================================================================== | ||
async function serve() { | ||
const esmContext = await esbuild.context({ | ||
...buildOptions, | ||
...entryPoints('esm'), | ||
outdir: 'lib', | ||
absWorkingDir, | ||
}); | ||
|
||
await esmContext.watch(); | ||
await esmContext.serve({ servedir: '.', port: PORT }); | ||
} | ||
|
||
async function build() { | ||
await esbuild.build({ | ||
...buildOptions, | ||
...entryPoints('esm'), | ||
outdir: 'lib', | ||
}); | ||
|
||
await esbuild.build({ | ||
...buildOptions, | ||
...entryPoints('cjs'), | ||
outdir: 'lib', | ||
outExtension: { | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
'.js': '.cjs', | ||
}, | ||
}); | ||
} | ||
|
||
// == main ========================================================================================= | ||
await (SERVE ? serve : build)(); | ||
} |
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,6 @@ | ||
// it's required to make vscode-jest work properly... | ||
export default { | ||
transform: { | ||
'^.+\\.ts$': 'ts-jest', | ||
}, | ||
}; |
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 |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
"npmClient": "yarn", | ||
"useWorkspaces": true, | ||
"packages": ["packages/*"], | ||
"version": "2.1.3" | ||
"version": "3.0.0" | ||
} |
Oops, something went wrong.