esbuild-gas-pluginをDenoから使うsample code
Denoから使うときはesm.shなどを経由させて使う
使う時の注意点
outfile
を必ず指定する
write: false
は使えない
2021-07-13
18:06:08 (codeの変更はなし)
とりあえずownerに聞こう
replyI'm sorry to be late for the reply.
I'm not sure I understand what you mean, because I don't know about `git rebase`(I'm not master git at all...).
Is this the same way you want me to do?
1. `git switch feature/deno`
2. `git rebase -i HEAD~5`
3. follow a wizard and squash all commits
4. `git push -f origin feature/deno`
2021-07-11
14:32:35 なんとかなった
import GasPlugin from "https://raw.githubusercontent.com/takker99/esbuild-gas-plugin/feature/deno/mod.ts";
からも使える
今度は error: [plugin: gas-plugin] "outfile" must be string, not undefined.
になった
stdin
を使っているのが行けなかったみたい
直す
outfile
をそもそも指定していないのがまずかった
最初から write: false
を禁止するしかない
10:51:06 なぜかエラーが出る
error: [plugin: gas-plugin] Error parsing args: serde_v8 error: ExpectedString
11:07:15 httpFetch
と別にして二段階でbuildしてもだめだった
どこで引っかかっているんだろう?
sample code
shdeno run -A -r=https://scrapbox.io/api/code/takker/esbuild-gas-pluginをDenoから使うsample_code/build.ts https://scrapbox.io/api/code/takker/esbuild-gas-pluginをDenoから使うsample_code/build.ts
build.tsimport { build, stop } from 'https://deno.land/x/esbuild@v0.12.15/mod.js';
//import { GasPlugin } from "https://esm.sh/esbuild-gas-plugin@0.1.0";
import GasPlugin from "https://raw.githubusercontent.com/takker99/esbuild-gas-plugin/feature/deno/mod.ts";
import { dirname } from "https://deno.land/std@0.100.0/path/mod.ts";
import httpFetch from 'https://deno.land/x/esbuild_plugin_http_fetch@v1.0.2/index.js';
await build({
stdin: {
contents: `import "${dirname(import.meta.url)}/index.ts";`,
loader: 'ts',
},
platform: 'neutral',
bundle: true,
minify: true,
outfile: 'dist/index.bundle.js',
plugins: [httpFetch, GasPlugin],
});
console.log(await Deno.readTextFile('dist/index.bundle.js'));
stop();
変換するcode
index.tsimport {add} from './add.ts';
function main() {
const a = 23;
const b = 24;
console.log(`${a} + ${b} = ${add(a, b)}.`);
}
declare let global: any;
global.main = main;
add.tsexport const add = (a: number, b:number,) => a + b;