Skip to content

Custom directives for NextJs 13 #5840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
CarlOlson opened this issue Nov 24, 2022 · 3 comments
Closed

Custom directives for NextJs 13 #5840

CarlOlson opened this issue Nov 24, 2022 · 3 comments
Milestone

Comments

@CarlOlson
Copy link

NextJs 13 introduces a new app directory for utilizing server components. Client components imported by a server component must have a "use client"; directive similar to strict mode. Using raw doesn't work because the directive must be above all code/imports.

Here are some ideas I thought of:

// 1. With a directive at the top of file
"use client"

// 2. At anywhere in the top level with a compiler directive
@@directive("use client")

// 3. Change %%raw to put code (or just directives) above imports
%%raw(`"use client";`)

And since so many files will have the same name, #4874 would also help with a big pain point of using NextJs w/ ReScript.

@sairion
Copy link

sairion commented Feb 10, 2023

@mununki I'd like to know if it this can be achievable via ppx kind of userland apporoach

cristianoc added a commit that referenced this issue Feb 10, 2023
Allow to specify directives emitted verbatim at the top of generated js files.

See #5840
@mununki
Copy link
Member

mununki commented Feb 10, 2023

@mununki I'd like to know if it this can be achievable via ppx kind of userland apporoach

Don' think it is achievable without compiler js emitter change.
See #5998

cristianoc added a commit that referenced this issue Feb 10, 2023
Allow to specify directives emitted verbatim at the top of generated js files.

See #5840
cristianoc added a commit that referenced this issue Feb 10, 2023
Allow to specify directives emitted verbatim at the top of generated js files.

See #5840
cristianoc added a commit that referenced this issue Feb 10, 2023
Allow to specify directives emitted verbatim at the top of generated js files.

See #5840
cristianoc added a commit that referenced this issue Feb 10, 2023
Allow to specify directives emitted verbatim at the top of generated js files.

See #5840
cristianoc added a commit that referenced this issue Feb 10, 2023
Allow to specify directives emitted verbatim at the top of generated js files.

See #5840
@cristianoc cristianoc added this to the v10.1 milestone Feb 10, 2023
@cristianoc
Copy link
Collaborator

cristianoc commented Feb 10, 2023

In upcoming 10.1.3.

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

No branches or pull requests

4 participants