-
-
Notifications
You must be signed in to change notification settings - Fork 219
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 #283 from vanruesc/dev
Version 6.21.3
- Loading branch information
Showing
40 changed files
with
2,380 additions
and
2,639 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 |
---|---|---|
@@ -1,89 +1,85 @@ | ||
import { createRequire } from "module"; | ||
import { hideBin } from "yargs/helpers"; | ||
import { glsl } from "esbuild-plugin-glsl"; | ||
import esbuild from "esbuild"; | ||
import yargs from "yargs"; | ||
|
||
const require = createRequire(import.meta.url); | ||
const pkg = require("./package"); | ||
const date = (new Date()).toDateString(); | ||
const production = (process.env.NODE_ENV === "production"); | ||
const globalName = pkg.name.replace(/-/g, "").toUpperCase(); | ||
const external = Object.keys(pkg.peerDependencies); | ||
const { argv } = yargs(hideBin(process.argv)) | ||
.option("watch", { alias: "w", type: "boolean" }); | ||
|
||
const external = Object.keys(pkg.peerDependencies || {}); | ||
const minify = (process.env.NODE_ENV === "production"); | ||
const watch = process.argv.includes("-w"); | ||
const plugins = [glsl({ minify })]; | ||
const banner = `/** | ||
* ${pkg.name} v${pkg.version} build ${date} | ||
* ${pkg.homepage} | ||
* Copyright ${date.slice(-4)} ${pkg.author.name} | ||
* @license ${pkg.license} | ||
*/`; | ||
|
||
// @todo Remove in next major release. | ||
const requireShim = `if(typeof window === "object"&&!window.require)window.require=()=>window.THREE;`; | ||
const footer = `if(typeof module==="object"&&module.exports)module.exports=${globalName};`; | ||
|
||
const common = { | ||
bundle: true, | ||
await esbuild.build({ | ||
entryPoints: [ | ||
"src/images/lut/worker.js", | ||
"src/images/smaa/worker.js" | ||
], | ||
outExtension: { ".js": ".txt" }, | ||
outdir: "tmp", | ||
logLevel: "info", | ||
plugins: [glsl({ minify: production })], | ||
loader: { | ||
".worker": "text", | ||
".png": "dataurl" | ||
} | ||
}; | ||
|
||
const workers = [{ | ||
entryPoints: ["src/images/lut/worker.js"], | ||
outfile: "tmp/lut.worker", | ||
format: "iife", | ||
minify: production, | ||
watch: argv.watch | ||
}, { | ||
entryPoints: ["src/images/smaa/worker.js"], | ||
outfile: "tmp/smaa.worker", | ||
format: "iife", | ||
minify: production, | ||
watch: argv.watch | ||
}]; | ||
bundle: true, | ||
minify, | ||
watch | ||
}).catch(() => process.exit(1)); | ||
|
||
const demo = [{ | ||
await esbuild.build({ | ||
entryPoints: ["demo/src/index.js"], | ||
outfile: "public/demo/index.js", | ||
outdir: "public/demo", | ||
logLevel: "info", | ||
format: "iife", | ||
minify: production, | ||
watch: argv.watch | ||
}]; | ||
bundle: true, | ||
plugins, | ||
minify, | ||
watch | ||
}).catch(() => process.exit(1)); | ||
|
||
const lib = [{ | ||
await esbuild.build({ | ||
entryPoints: ["src/index.js"], | ||
outfile: `build/${pkg.name}.esm.js`, | ||
banner: { js: banner }, | ||
logLevel: "info", | ||
format: "esm", | ||
external | ||
}, { | ||
bundle: true, | ||
external, | ||
plugins | ||
}).catch(() => process.exit(1)); | ||
|
||
// @todo Remove in next major release. | ||
const globalName = pkg.name.replace(/-/g, "").toUpperCase(); | ||
const requireShim = `if(typeof window==="object"&&!window.require)window.require=()=>window.THREE;`; | ||
const footer = `if(typeof module==="object"&&module.exports)module.exports=${globalName};`; | ||
|
||
await esbuild.build({ | ||
entryPoints: ["src/index.js"], | ||
outfile: `build/${pkg.name}.js`, | ||
banner: { js: `${banner}\n${requireShim}` }, | ||
footer: { js: footer }, | ||
logLevel: "info", | ||
format: "iife", | ||
bundle: true, | ||
globalName, | ||
external | ||
}, { | ||
external, | ||
plugins | ||
}).catch(() => process.exit(1)); | ||
|
||
await esbuild.build({ | ||
entryPoints: ["src/index.js"], | ||
outfile: `build/${pkg.name}.min.js`, | ||
banner: { js: `${banner}\n${requireShim}` }, | ||
footer: { js: footer }, | ||
logLevel: "info", | ||
format: "iife", | ||
minify: true, | ||
bundle: true, | ||
globalName, | ||
external | ||
}]; | ||
|
||
for(const configs of [workers, demo, lib]) { | ||
|
||
const promises = configs.map(c => esbuild.build(Object.assign(c, common))); | ||
await Promise.all(promises); | ||
|
||
} | ||
external, | ||
plugins, | ||
minify | ||
}).catch(() => process.exit(1)); |
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
Oops, something went wrong.