generated at
esbuild-gas-pluginをDenoから使うsample code
esbuild-gas-pluginはNode用packageしか用意されていない
Denoから使うときはesm.shなどを経由させて使う

使う時の注意点
outfile を必ず指定する
write: false は使えない

2021-07-13
18:06:08 (codeの変更はなし)
とりあえずownerに聞こう
reply
I'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`
18:13:14 聞いた
2021-07-11
14:32:35 なんとかなった
esbuild-gas-pluginをDenoから使うsample code#60ea849d1280f00000b183b1に注意すれば、Node版のもちゃんと動いた
import GasPlugin from "https://raw.githubusercontent.com/takker99/esbuild-gas-plugin/feature/deno/mod.ts"; からも使える
PR出しておいた
今度は error: [plugin: gas-plugin] "outfile" must be string, not undefined. になった
stdin を使っているのが行けなかったみたい
直す
outfile をそもそも指定していないのがまずかった
esbuild pluginの onEnd()は何も返せないので、 outputFiles をいじって再び outputFiles として返すことが不可能
最初から write: false を禁止するしかない
10:51:06 なぜかエラーが出る
error: [plugin: gas-plugin] Error parsing args: serde_v8 error: ExpectedString
11:07:15 httpFetch と別にして二段階でbuildしてもだめだった
どこで引っかかっているんだろう?
gas-entry-generatorでエラーが出てる場合はどうしようもないが
それ以外の部分なら、esbuild-gas-pluginをDeno用に書き直すことでなんとかなるかも

sample code
sh
deno 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.ts
import { 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.ts
import {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.ts
export const add = (a: number, b:number,) => a + b;

#2021-07-11 10:31:44