diff options
-rw-r--r-- | test/js/third_party/esbuild/esbuild-test.js | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/test/js/third_party/esbuild/esbuild-test.js b/test/js/third_party/esbuild/esbuild-test.js index beb34b283..09152246b 100644 --- a/test/js/third_party/esbuild/esbuild-test.js +++ b/test/js/third_party/esbuild/esbuild-test.js @@ -1,4 +1,4 @@ -import { transform, transformSync } from "esbuild"; +import { build, buildSync, transform, transformSync } from "esbuild"; { const result = await transform("console.log('hello world')", { @@ -34,4 +34,53 @@ import { transform, transformSync } from "esbuild"; } } +{ + const result = await build({ + stdin: { + "contents": "console.log('hello world')", + "loader": "js", + "sourcefile": "index.js", + }, + write: false, + target: "node12", + }); + if (result.outputFiles[0].text !== 'console.log("hello world");\n') { + throw new Error("Test failed."); + } +} + +{ + const contents = `console.log(${JSON.stringify("a".repeat(1000000))});`; + + for (let i = 0; i < 2; i++) { + const result = await build({ + target: "node12", + write: false, + stdin: { + contents, + "loader": "js", + "sourcefile": "index.js", + }, + }); + if (result.outputFiles[0].text !== contents + "\n") { + throw new Error("Test failed."); + } + } +} + +{ + const result = buildSync({ + stdin: { + "contents": "console.log('hello world')", + "loader": "js", + "sourcefile": "index.js", + }, + write: false, + target: "node12", + }); + if (result.outputFiles[0].text !== 'console.log("hello world");\n') { + throw new Error("Test failed."); + } +} + process.exit(0); |