Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Opt-out for the module-load eval probe (strict CSP reports a violation on import)

オープン 初心者向け
#3,276 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
70/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
javascript, typescript

調査の方向性

packages/typegpu/src/data/compiledIO.ts から始めてください。モジュール読み込み時の EVAL_ALLOWED_IN_ENV プローブはここにあります。issue に示された 3 つの opt-out 設計を読み、typegpu が root/init オプションをすでにどう扱っているかを確認して、合うものを選びます。完了の条件は: script-src 'self' の下で typegpu を import しても securitypolicyviolation の報告が発生せず、eval が利用できない場合は既存の警告付きで plain writer が引き続き使われることです。

索引モデルが issue の本文から書いたものです。

説明

Problem

packages/typegpu/src/data/compiledIO.ts probes for eval support when the module loads:

export const EVAL_ALLOWED_IN_ENV: boolean = (() => {
  try {
    new Function('return true');
    return true;
  } catch {
    return false;
  }
})();

Under a strict Content Security Policy without 'unsafe-eval', the try/catch keeps this from breaking anything: typegpu falls back to the plain writer, and since #2758/#2771 it warns once. But the browser still files a securitypolicyviolation (script-src, eval) the moment typegpu is imported, before any buffer is written.

Hosts that embed apps in sandboxed iframes with a strict CSP (MCP Apps / ChatGPT apps, browser extensions, enterprise pages with CSP reporting) treat any such report as a policy failure. An app that never wants compiled writers can't avoid the report today short of patching the package.

Request

An opt-out that skips the probe, so the plain writer is used without ever calling new Function. Any of these would work for us:

  • a global flag read before the probe, like zod's globalThis.__zod_globalConfig = { jitless: true };
  • a lazy probe that runs only the first time a compiled writer is actually requested, plus a root or init option to disable compiled writers;
  • a build-time define (TYPEGPU_NO_EVAL) that tree-shakes the probe.
Repro
  1. Serve a page with Content-Security-Policy: script-src 'self'.
  2. Add document.addEventListener('securitypolicyviolation', e => console.log(e.violatedDirective, e.blockedURI)).
  3. Import typegpu. One script-src / eval violation is logged at import, with no GPU work done.

Seen on typegpu 0.12.8. We currently carry a patch-package-style patch that hard-codes the plain writer and would drop it as soon as an opt-out exists. Thanks for TypeGPU!

主要言語
TypeScript
スター
3.3k
フォーク
141
平均マージ
3日 8時間
マージ済み PR(30日)
72

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

software-mansion/TypeGPU のほかの issue

software-mansion/TypeGPU の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。