-
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.
- Loading branch information
Showing
15 changed files
with
679 additions
and
77 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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 @@ | ||
import bench from "benny"; | ||
import { inlined, notInlined } from "./dist/esbuild.js"; | ||
|
||
bench.suite( | ||
"My suite", | ||
bench.add("Inlined", inlined), | ||
bench.add("Not inlined", notInlined), | ||
bench.cycle(), | ||
bench.complete() | ||
); |
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,25 +1,13 @@ | ||
import esbuild from "esbuild"; | ||
import inlineFunction from "../dist/esbuild.js"; | ||
|
||
let counter = 0; | ||
const macros = { | ||
add: (a, b) => { | ||
const _a = `_a${counter++}`; | ||
const _b = `_b${counter++}`; | ||
return ` | ||
const ${_a} = ${a}; | ||
const ${_b} = ${b}; | ||
${_a}[0] = ${_a}[0] + ${_b}[0]; | ||
${_a}[1] = ${_a}[1] + ${_b}[1]; | ||
`; | ||
}, | ||
}; | ||
import { macros } from "./macros.js"; | ||
|
||
esbuild | ||
.build({ | ||
entryPoints: ["./test/test.ts"], | ||
bundle: true, | ||
format: "esm", | ||
outfile: "./test/dist/esbuild.js", | ||
plugins: [inlineFunction({ macros })], | ||
plugins: [inlineFunction({ macros, verbose: false })], | ||
}) | ||
.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
let counter = 0; | ||
export const macros = { | ||
add: (a, b) => { | ||
const _a = `_a${counter++}`; | ||
const _b = `_b${counter++}`; | ||
return ` | ||
const ${_a} = ${a}; | ||
const ${_b} = ${b}; | ||
${_a}[0] = ${_a}[0] + ${_b}[0]; | ||
${_a}[1] = ${_a}[1] + ${_b}[1]; | ||
`; | ||
}, | ||
crossProduct: (a, b, d) => { | ||
const _a = `_a${counter++}`; | ||
const _b = `_b${counter++}`; | ||
const _d = `_d${counter++}`; | ||
return ` | ||
const ${_a} = ${a}; | ||
const ${_b} = ${b}; | ||
const ${_d} = ${d}; | ||
${_d}[0] = ${_a}[0] * ${_b}[0]; | ||
${_d}[1] = ${_a}[1] * ${_b}[1]; | ||
`; | ||
}, | ||
}; |
Oops, something went wrong.