Skip to content

Next.js app router support - #246

Merged
pablotransifex merged 2 commits into
masterfrom
nextjs-app-router-support
Jul 9, 2026
Merged

Next.js app router support#246
pablotransifex merged 2 commits into
masterfrom
nextjs-app-router-support

Conversation

@pablotransifex

@pablotransifex pablotransifex commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

NOTE: It's possible to add 'use client' manually in the source files, but when 'use client' was added to src/index.js, microbundle printed:

Module level directives cause errors when bundled, 'use client' was ignored.

Rollup/microbundle strips module-level directives when it bundles everything into a single dist/index.js. So putting it in source alone would not reach npm consumers. The script is mandatory for the current microbundle single-bundle setup, unless you change the build to inject or preserve the directive another way.

@pablotransifex
pablotransifex force-pushed the nextjs-app-router-support branch from 36719f0 to 5070047 Compare July 7, 2026 15:02
yiotaz
yiotaz previously approved these changes Jul 8, 2026

@yiotaz yiotaz 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.

Everything looks good!

Suggestion, non blocking for release: We could add a build test to assert that dist/index.js and dist/index.modern.js start with 'use client';. Right now, test:build only checks that the build succeeds — if the post-build step is removed or dist output changes, CI would still pass while Next.js consumers hit the Client Component import error again.

@pablotransifex

Copy link
Copy Markdown
Contributor Author

Everything looks good!

Suggestion, non blocking for release: We could add a build test to assert that dist/index.js and dist/index.modern.js start with 'use client';. Right now, test:build only checks that the build succeeds — if the post-build step is removed or dist output changes, CI would still pass while Next.js consumers hit the Client Component import error again.

I initially felt this might be over-testing, but it's actually a meaningful guard rather than a redundant one. Unlike the bundled components/hooks — which the bundler guarantees and the unit tests already exercise against src/ — the 'use client' directive is stripped by the bundler and re-added by a custom post-build script (add-use-client.js). Nothing in the current test suite reads dist/, so if that step is removed or a bundler upgrade changes the output, every test still passes while App Router consumers break. I've wired the check as a postbuild hook so it runs on every build (including prepare/publish), and extracted the directive into a shared constant.

@yiotaz yiotaz 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.

🚀 💯

@pablotransifex
pablotransifex merged commit 897c554 into master Jul 9, 2026
3 checks passed
@pablotransifex
pablotransifex deleted the nextjs-app-router-support branch July 9, 2026 08:28
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.

2 participants