Skip to content

📝 Switch to ?raw imports for advents#6830

Merged
dubzzz merged 3 commits into
mainfrom
claude/raw-imports-buggy-code-x1jUd
Apr 9, 2026
Merged

📝 Switch to ?raw imports for advents#6830
dubzzz merged 3 commits into
mainfrom
claude/raw-imports-buggy-code-x1jUd

Conversation

@dubzzz

@dubzzz dubzzz commented Apr 9, 2026

Copy link
Copy Markdown
Owner

Replace the function-returning-function pattern in buggy.mjs files with
direct exports, and use ?raw imports to get the source code as text for
StackBlitz sandboxes and downloads. This eliminates the need for the
String(fn) + regex extraction workaround in AdventOfTheDayBuilder.

https://claude.ai/code/session_016asJDuBocZ76J4KQrxy8A9

Replace the function-returning-function pattern in buggy.mjs files with
direct exports, and use ?raw imports to get the source code as text for
StackBlitz sandboxes and downloads. This eliminates the need for the
String(fn) + regex extraction workaround in AdventOfTheDayBuilder.

https://claude.ai/code/session_016asJDuBocZ76J4KQrxy8A9
@changeset-bot

changeset-bot Bot commented Apr 9, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 3ab75b1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

👋 It looks like the PR template was not used for this pull request.

Please edit the PR description to use the template, or close this PR and open a new one that uses it.
Not using the template may result in your change not being reviewed.

The template includes:

  • A Description section
  • A Checklist section with items to verify before submitting

Thank you for your contribution! 🙏

@pkg-pr-new

pkg-pr-new Bot commented Apr 9, 2026

Copy link
Copy Markdown
@fast-check/ava

npm i https://pkg.pr.new/@fast-check/ava@6830

fast-check

npm i https://pkg.pr.new/fast-check@6830

@fast-check/jest

npm i https://pkg.pr.new/@fast-check/jest@6830

@fast-check/packaged

npm i https://pkg.pr.new/@fast-check/packaged@6830

@fast-check/poisoning

npm i https://pkg.pr.new/@fast-check/poisoning@6830

@fast-check/vitest

npm i https://pkg.pr.new/@fast-check/vitest@6830

@fast-check/worker

npm i https://pkg.pr.new/@fast-check/worker@6830

commit: 3ab75b1

@dubzzz

dubzzz commented Apr 9, 2026

Copy link
Copy Markdown
Owner Author

@claude fix typecheck

website typecheck: blog/2024-12-01-advent-of-pbt-day-1/AdventOfTheDayBuilder.tsx(61,13): error TS7022: 'buggyAdvent' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
website typecheck: blog/2024-12-01-advent-of-pbt-day-1/AdventOfTheDayBuilder.tsx(61,52): error TS2448: Block-scoped variable 'buggyAdvent' used before its declaration.
website typecheck: blog/2024-12-01-advent-of-pbt-day-1/AdventOfTheDayBuilder.tsx(80,13): error TS7022: 'buggyAdvent' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
website typecheck: blog/2024-12-01-advent-of-pbt-day-1/AdventOfTheDayBuilder.tsx(80,52): error TS2448: Block-scoped variable 'buggyAdvent' used before its declaration.

@claude

claude Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Claude finished @dubzzz's task in 1m 29s —— View job


Fixed TypeScript errors in AdventOfTheDayBuilder.tsx

  • Read the file and understand the typecheck errors
  • Fix the buggyAdvent variable declaration/usage issue
  • Commit and push the fix

Root cause: On lines 61 and 80, const buggyAdvent = buggyAdventSurcharged ?? buggyAdvent declared a new block-scoped variable that shadowed the outer buggyAdvent from the destructured options. The ?? buggyAdvent on the right side then referenced the not-yet-initialized local variable (itself) instead of the outer one, causing both TS7022 (implicit any) and TS2448 (used before declaration).

Fix: Renamed the local variable to buggyFn to avoid shadowing the outer buggyAdvent.

@dubzzz

dubzzz commented Apr 9, 2026

Copy link
Copy Markdown
Owner Author

@claude fix

{"message":" ⚠ Critical dependency: require function is used in a way in which dependencies cannot be statically extracted\n ╭─[3:24]\n 1 │ (function (factory) {\n 2 │ if (typeof module === "object" && typeof module.exports === "object") {\n 3 │ var v = factory(require, exports);\n · ───────\n 4 │ if (v !== undefined) module.exports = v;\n 5 │ }\n ╰────\n","moduleIdentifier":"/home/runner/work/fast-check/fast-check/node_modules/.pnpm/vscode-languageserver-types@3.17.5/node_modules/vscode-languageserver-types/lib/umd/main.js","moduleName":"../node_modules/.pnpm/vscode-languageserver-types@3.17.5/node_modules/vscode-languageserver-types/lib/umd/main.js","loc":"3:25-31","compilerPath":"server"}
Docusaurus static site generation process emitted warnings for 1 paths
This is non-critical and can be disabled with DOCUSAURUS_IGNORE_SSG_WARNINGS=true
Troubleshooting guide: facebook/docusaurus#10580

  • "/docs/core-blocks/arbitraries/composites/object/":
    • [HTML minifier diagnostic - error] Noncharacter in input stream - {"primary_spans":[{"end":136616,"start":136612}],"span_labels":[]}

Error: Unable to build website for locale en.
at tryToBuildLocale (/home/runner/work/fast-check/fast-check/node_modules/.pnpm/@Docusaurus+core@3.9.2_@docusaurus+faster@3.9.2_@docusaurus+types@3.9.2_@swc+core@1.15.3c1e915bf00e89f7a2a52dceef07a572/node_modules/@docusaurus/core/lib/commands/build/build.js:83:15)
at async /home/runner/work/fast-check/fast-check/node_modules/.pnpm/@Docusaurus+core@3.9.2
@Docusaurus+faster@3.9.2_@docusaurus+types@3.9.2_@swc+core@1.15.3c1e915bf00e89f7a2a52dceef07a572/node_modules/@docusaurus/core/lib/commands/build/build.js:35:9
... 4 lines matching cause stack trace ...
at async file:///home/runner/work/fast-check/fast-check/node_modules/.pnpm/@Docusaurus+core@3.9.2
@Docusaurus+faster@3.9.2_@docusaurus+types@3.9.2_@swc+core@1.15._3c1e915bf00e89f7a2a52dceef07a572/node_modules/@docusaurus/core/bin/docusaurus.mjs:44:3 {
[cause]: Error: Docusaurus static site generation failed for 1 paths:

  • "/blog/2024/12/06/advent-of-pbt-day-6/"
    at throwSSGError (/home/runner/work/fast-check/fast-check/node_modules/.pnpm/@Docusaurus+core@3.9.2_@docusaurus+faster@3.9.2_@docusaurus+types@3.9.2_@swc+core@1.15.3c1e915bf00e89f7a2a52dceef07a572/node_modules/@docusaurus/core/lib/ssg/ssgGlobalResult.js:56:11)
    at createGlobalSSGResult (/home/runner/work/fast-check/fast-check/node_modules/.pnpm/@Docusaurus+core@3.9.2
    @Docusaurus+faster@3.9.2_@docusaurus+types@3.9.2_@swc+core@1.15.3c1e915bf00e89f7a2a52dceef07a572/node_modules/@docusaurus/core/lib/ssg/ssgGlobalResult.js:66:9)
    ... 11 lines matching cause stack trace ...
    at async file:///home/runner/work/fast-check/fast-check/node_modules/.pnpm/@Docusaurus+core@3.9.2
    @Docusaurus+faster@3.9.2_@docusaurus+types@3.9.2_@swc+core@1.15.3c1e915bf00e89f7a2a52dceef07a572/node_modules/@docusaurus/core/bin/docusaurus.mjs:44:3 {
    [cause]: AggregateError
    at throwSSGError (/home/runner/work/fast-check/fast-check/node_modules/.pnpm/@Docusaurus+core@3.9.2
    @Docusaurus+faster@3.9.2_@docusaurus+types@3.9.2_@swc+core@1.15.3c1e915bf00e89f7a2a52dceef07a572/node_modules/@docusaurus/core/lib/ssg/ssgGlobalResult.js:57:16)
    at createGlobalSSGResult (/home/runner/work/fast-check/fast-check/node_modules/.pnpm/@Docusaurus+core@3.9.2
    @Docusaurus+faster@3.9.2_@docusaurus+types@3.9.2_@swc+core@1.15.3c1e915bf00e89f7a2a52dceef07a572/node_modules/@docusaurus/core/lib/ssg/ssgGlobalResult.js:66:9)
    at Object.run (/home/runner/work/fast-check/fast-check/node_modules/.pnpm/@Docusaurus+core@3.9.2
    @Docusaurus+faster@3.9.2_@docusaurus+types@3.9.2_@swc+core@1.15.3c1e915bf00e89f7a2a52dceef07a572/node_modules/@docusaurus/core/lib/ssg/ssgExecutor.js:118:64)
    at async executeSSG (/home/runner/work/fast-check/fast-check/node_modules/.pnpm/@Docusaurus+core@3.9.2
    @Docusaurus+faster@3.9.2_@docusaurus+types@3.9.2_@swc+core@1.15.3c1e915bf00e89f7a2a52dceef07a572/node_modules/@docusaurus/core/lib/ssg/ssgExecutor.js:144:20)
    at async buildLocale (/home/runner/work/fast-check/fast-check/node_modules/.pnpm/@Docusaurus+core@3.9.2
    @Docusaurus+faster@3.9.2_@docusaurus+types@3.9.2_@swc+core@1.15.3c1e915bf00e89f7a2a52dceef07a572/node_modules/@docusaurus/core/lib/commands/build/buildLocale.js:84:31)
    at async runBuildLocaleTask (/home/runner/work/fast-check/fast-check/node_modules/.pnpm/@Docusaurus+core@3.9.2
    @Docusaurus+faster@3.9.2_@docusaurus+types@3.9.2_@swc+core@1.15.3c1e915bf00e89f7a2a52dceef07a572/node_modules/@docusaurus/core/lib/commands/build/build.js:98:5)
    at async /home/runner/work/fast-check/fast-check/node_modules/.pnpm/@Docusaurus+core@3.9.2
    @Docusaurus+faster@3.9.2_@docusaurus+types@3.9.2_@swc+core@1.15.3c1e915bf00e89f7a2a52dceef07a572/node_modules/@docusaurus/core/lib/commands/build/build.js:79:13
    at async tryToBuildLocale (/home/runner/work/fast-check/fast-check/node_modules/.pnpm/@Docusaurus+core@3.9.2
    @Docusaurus+faster@3.9.2_@docusaurus+types@3.9.2_@swc+core@1.15.3c1e915bf00e89f7a2a52dceef07a572/node_modules/@docusaurus/core/lib/commands/build/build.js:75:9)
    at async /home/runner/work/fast-check/fast-check/node_modules/.pnpm/@Docusaurus+core@3.9.2
    @Docusaurus+faster@3.9.2_@docusaurus+types@3.9.2_@swc+core@1.15.3c1e915bf00e89f7a2a52dceef07a572/node_modules/@docusaurus/core/lib/commands/build/build.js:35:9
    at async mapAsyncSequential (/home/runner/work/fast-check/fast-check/node_modules/.pnpm/@Docusaurus+utils@3.9.2
    @swc+core@1.15.21_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/@docusaurus/utils/lib/jsUtils.js:21:24)
    at async Command.build (/home/runner/work/fast-check/fast-check/node_modules/.pnpm/@Docusaurus+core@3.9.2_@docusaurus+faster@3.9.2_@docusaurus+types@3.9.2_@swc+core@1.15.3c1e915bf00e89f7a2a52dceef07a572/node_modules/@docusaurus/core/lib/commands/build/build.js:34:5)
    at async Promise.all (index 0)
    at async runCLI (/home/runner/work/fast-check/fast-check/node_modules/.pnpm/@Docusaurus+core@3.9.2
    @Docusaurus+faster@3.9.2_@docusaurus+types@3.9.2_@swc+core@1.15.3c1e915bf00e89f7a2a52dceef07a572/node_modules/@docusaurus/core/lib/commands/cli.js:56:5)
    at async file:///home/runner/work/fast-check/fast-check/node_modules/.pnpm/@Docusaurus+core@3.9.2
    @Docusaurus+faster@3.9.2_@docusaurus+types@3.9.2_@swc+core@1.15.3c1e915bf00e89f7a2a52dceef07a572/node_modules/@docusaurus/core/bin/docusaurus.mjs:44:3 {
    [errors]: [
    Error: Can't render static file for pathname "/blog/2024/12/06/advent-of-pbt-day-6/"
    at generateStaticFile (/home/runner/work/fast-check/fast-check/node_modules/.pnpm/@Docusaurus+core@3.9.2
    @Docusaurus+faster@3.9.2_@docusaurus+types@3.9.2_@swc+core@1.15._3c1e915bf00e89f7a2a52dceef07a572/node_modules/@docusaurus/core/lib/ssg/ssgRenderer.js:131:20)
    at async /home/runner/work/fast-check/fast-check/node_modules/.pnpm/p-map@4.0.0/node_modules/p-map/index.js:57:22 {
    [cause]: DOMException [InvalidCharacterError]: Invalid character
    at btoa (node:buffer:1315:11)
    at AdventPlayground (/home/runner/work/fast-check/fast-check/website/build/__server/assets/js/9d04e2eb.ddca4b4a.js:18780:75)
    at renderWithHooks (server.bundle.js:14199:18)
    at renderElement (server.bundle.js:14337:14)
    at retryNode (server.bundle.js:15055:16)
    at renderNodeDestructive (server.bundle.js:14849:7)
    at finishFunctionComponent (server.bundle.js:14240:9)
    at renderElement (server.bundle.js:14339:7)
    at retryNode (server.bundle.js:15055:16)
    at renderNodeDestructive (server.bundle.js:14849:7)
    }
    ]
    }
    }
    }
    [INFO] Docusaurus version: 3.9.2
    Node version: v24.14.1
    /home/runner/work/fast-check/fast-check/website:
     ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  website@ build: pnpm run sync:sponsors && cp ../.all-contributorsrc src/components/HomepageContributors/all-contributors.json && node prebuild/optimize-images.mjs && docusaurus build
    Exit status 1
    Process completed with exit code 1.

@claude

claude Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Claude finished @dubzzz's task in 3m 43s —— View job


Fixed SSG build failure (btoa InvalidCharacterError)

  • Investigate the btoa error in AdventPlayground for day-6
  • Fix Unicode-safe base64 encoding in AdventPlayground.tsx — use TextEncoder to handle emoji characters
  • Fix typecheck errors — resolved conflict with previous fix (already using buggyFn)
  • Commit and push

Changes made:

  • AdventPlayground.tsx: Replaced btoa(snippet) with a TextEncoder-based encoding that handles non-Latin1 characters (emojis in day-6's buggy.mjs were causing InvalidCharacterError during SSG)

The root cause was that btoa() only supports Latin1 characters, but the ?raw imports of buggy.mjs files contain emoji characters (e.g., 🎄, 🎁, ✉️ in day-6). Using TextEncoder to first encode the string as UTF-8 bytes, then converting each byte to a Latin1 character before passing to btoa(), handles all Unicode characters correctly.
·

github-actions Bot and others added 2 commits April 9, 2026 19:30
Rename local `buggyAdvent` to `buggyFn` to avoid shadowing the outer
destructured variable, which caused TS7022 and TS2448 errors.

Co-authored-by: Nicolas DUBIEN <dubzzz@users.noreply.github.com>
Use TextEncoder for Unicode-safe base64 encoding in AdventPlayground
download link, and rename shadowing buggyAdvent variable to
resolvedBuggyAdvent in AdventOfTheDayBuilder.

Co-authored-by: Nicolas DUBIEN <dubzzz@users.noreply.github.com>
@dubzzz dubzzz changed the title Use ?raw imports for advent buggy code instead of toString+regex 📝 Switch to ?raw imports for advents Apr 9, 2026
@codecov

codecov Bot commented Apr 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.86%. Comparing base (b3c86c2) to head (3ab75b1).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6830   +/-   ##
=======================================
  Coverage   94.86%   94.86%           
=======================================
  Files         209      209           
  Lines        5665     5665           
  Branches     1489     1489           
=======================================
  Hits         5374     5374           
  Misses        283      283           
  Partials        8        8           
Flag Coverage Δ
tests 94.86% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dubzzz dubzzz merged commit 671bf8a into main Apr 9, 2026
49 checks passed
@dubzzz dubzzz deleted the claude/raw-imports-buggy-code-x1jUd branch April 9, 2026 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants