✅entry pointとなるコードブロック中で使われている相対URLによるimportを解決できない (@takker/ScrapJupyter)
現象
以下のcode blockを実行しようとするとエラーが出る
code:ts
import {say} from "./sample.ts";
say();
code:sample.ts
export const say = () => alert("Hello.");
code:error
Error: Build failed with 3 errors:
error: Cannot read directory ".": not implemented on js
error: Cannot read directory "https:/scrpabox.io/api/code/takker/entry_pointとなるコードブロック中で使われている相対urlによるimportを解決できない_(@takker%2Fscrapjupyter)": not implemented on js
<stdin>:1:23: error: Could not resolve "./sample.ts"
絶対URLで指定すればエラーにならない
code:ts
import {say} from "https://scrapbox.io/api/code/takker/entry_point%E3%81%A8%E3%81%AA%E3%82%8B%E3%82%B3%E3%83%BC%E3%83%89%E3%83%96%E3%83%AD%E3%83%83%E3%82%AF%E4%B8%AD%E3%81%A7%E4%BD%BF%E3%82%8F%E3%82%8C%E3%81%A6%E3%81%84%E3%82%8B%E7%9B%B8%E5%AF%BEURL%E3%81%AB%E3%82%88%E3%82%8Bimport%E3%82%92%E8%A7%A3%E6%B1%BA%E3%81%A7%E3%81%8D%E3%81%AA%E3%81%84_(@takker%2FScrapJupyter)/sample.ts";
say();
原因
entry pontのimport.meta.urlが正しく設定されていない
https://scrapbox.io/api/code/:project/:titleをcurrent directoryとして設定している(v.1.1.0)が、それが間違いのようだ
おそらくPluginで使っているpath (e.g. deno-cache://...)が正しい
2021-12-31 10:55:05 ↑自分で書いてて、一体何をいっているのか全くわからないのだが……
解決策
resolveDirをPluginの仕様に沿ったpathに変える
Plugin自体を既存のものではなく、このUserScript専用のものに変えるという手段もある
それは後々考える
他のTODOとも関わることだし
scrapbox-bundlerで使っているPluginを流用すれば簡単に実装できそう
2021-12-31
05:24:58 codingした
試してみる
UI codeのページを生成する
worker codeのページを生成する
06:02:17 merged
URL importが壊れていたのを直した by takker99 · Pull Request #7 · takker99/ScrapJupyter
#2021-12-31 01:28:03
#2021-09-18 06:21:04