Skip to content

feat: add zile.transform hook for emitted javascript - #52

Merged
jxom merged 3 commits into
mainfrom
jxom/define-option-f81b00
Oct 30, 2026
Merged

jxom merged 3 commits into
mainfrom
jxom/define-option-f81b00

Conversation

@jxom

@jxom jxom commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Adds package.json#zile.transform, a module whose default export rewrites each emitted JavaScript file after tsc. Lets libraries replace build flag reads with literals before publishing, without zile knowing about the flag library.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T08:56:43.656905Z 80f9617 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/zile@52

commit: 80f9617

@jxom jxom changed the title feat: add zile.define replacements for emitted javascript feat: add zile.transform hook for emitted javascript Oct 30, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a6fbdb895b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Package.ts Resolved
Comment thread src/Package.ts Resolved
Comment thread src/Package.ts Resolved
Comment thread src/Package.ts Resolved
Comment thread src/Package.ts Resolved
Comment thread src/Package.ts Resolved
Comment thread src/Package.ts Resolved
@jxom
jxom merged commit a0da0b2 into main Oct 30, 2026
7 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 30, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 80f96177a1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Package.ts
const sourceDir = getSourceDir({ cwd, sources })

if (!link) {
const transform = await readTransform({ cwd, pkgJson })

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Load the transform after transpilation

When a relative transform such as ./dist/transform.js is itself emitted by the package—or the transform imports another generated file—a clean build fails during module loading because readTransform runs before transpile creates those files. Resolve and import the transform after transpilation, immediately before applying it to the emitted JavaScript.

Useful? React with 👍 / 👎.

Comment thread src/Package.ts
for await (const file of fs.glob('**/*.{js,mjs,cjs}', { cwd: outDir })) {
const filePath = path.resolve(outDir, file)
const code = await fs.readFile(filePath, 'utf-8')
await fs.writeFile(filePath, await transform(code, path.relative(cwd, filePath)))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Normalize callback paths across platforms

On Windows, path.relative returns a path such as dist\index.js, while the documented callback contract shows package-relative paths such as dist/index.js. Transforms that select files using the documented slash-separated value therefore silently skip their replacements on Windows; normalize the callback path to forward slashes before invoking the transform.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant