Twitter hashtag: #esspec
便利ツール
時事ネタ
morikenさんのブログ
自己紹介 (近況報告)
syumai syumai.icon
Go / TSを書いて暮らしてます
syumai Advent Calendar 2024 を無理やりちょっと書きました
楽しいクイズ情報です
最近はGhostty使ってます
MacでもUbuntuでも使えていい感じ
麻雀の勉強を始めました
iwatsurut
正月はダラダラしまくっていました。
とくに、イベントもなく過ごしています。
igrep
yebis
ひさびさの参加です
最近便利だったシリーズ
DOMノードを作る簡易テンプレートエンジンとして便利
code:js
import ReactDOM from 'react-dom';
import { html } from 'htm/react';
ReactDOM.render(html<a href="/">Hello!</a>, document.body);
(on browserで使えるテストランナーはあんまりなくて、mochaとかを使うことになりそう)
<script type="text/ruby">
前回のあらすじ
moduleのあたりを読んでいる
今回の範囲
16.2.1.6.3 ResolveExport(...)
export * from "..."の衝突
code:a.mjs
import * as b from "./b.mjs";
console.log(b.a1); // 1
console.log(b.a2); // 2
console.log(b.a); // undefined
code:b.mjs
export * from "./c1.mjs";
export * from "./c2.mjs";
code:c1.mjs
export const a = 1;
export const a1 = 1;
code:c2.mjs
export const a = 2;
export const a2 = 2;
9.e. If resolution is not null, then
これが発生するのは循環参照の場合のみ(のはず)
と思ったが違いそう
9.e.iii.2. If resolution.[[Module]] and starResolution.[[Module]] are not the same Module Record, return ambiguous.
code:js
// 同じmoduleをexportした場合は、ResolveExportの結果がresolutionとstarResolution
// で衝突してもambiguousではない
export * from "./foo.mjs";
export * from "./foo.mjs";
9.e.iii.3. If resolution.[[BindingName]] is not starResolution.[[BindingName]] and either resolution.[[BindingName]] or starResolution.[[BindingName]] is namespace, return ambiguous.
resolution.[[BindingName]]は定義上StringまたはNAMESPACEであることが保証されている
直前のif文から、resolution.[[Module]] == starResolution.[[Module]]であることも保証されている
以下のように d.mjs のexportをnamespace Objectとして c1.mjs と c2.mjs がそれぞれ同じ名前でexportしているようなケースがこれに該当する (片方がNAMESPACEで、もう一方がStringのケースも該当する)
code:a.mjs
import * as b from "./b.mjs";
console.log(b.d); // undefined
code:b.mjs
export * from "./c1.mjs";
export * from "./c2.mjs";
code:c1.mjs
export * as d from "./d.mjs";
code:c2.mjs
export * as d from "./d.mjs";
code:d.mjs
// 何もexportしなくてもOK
9.e.iii.4. 4. If resolution.[[BindingName]] is a String, starResolution.[[BindingName]] is a String, and resolution.[[BindingName]] is not starResolution.[[BindingName]], return ambiguous.
以下のように d.mjs の別々のexportを c1.mjs と c2.mjs がそれぞれ同じ名前でexportしているようなケースがこれに該当する。
code:a.mjs
import * as b from "./b.mjs";
console.log(b.d); // undefined
code:b.mjs
export * from "./c1.mjs";
export * from "./c2.mjs";
code:c1.mjs
export { x as d } from "./d.mjs";
code:c2.mjs
export { y as d } from "./d.mjs";
code:d.mjs
export const x = 3;
export const y = 4;
InnerModuleLinkingとは?
ModuleLinkingの再帰的な処理を取り出した関数
InnerなModuleLinking
InnerModuleのLikingではない
ファイルをまとめてコードブロックにするシェルスクリプト関数
code:bash
print_file_content() {
local filename="$1"
local indent=" "
if ! -f "$filename" ; then
echo "Error: File '$filename' not found." >&2
return 1
fi
while IFS= read -r line; do
printf "%s%s\n" "$indent" "$line"
done < "$filename"
}
cosense_code() {
for file in "$@"; do
echo "code:$file"
print_file_content "$file"
echo ""
done
}
# cosense_code *.mjs | pbcopy