Skip to content
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

swc-plugin inserts imports before "use client" #21

Closed
hehex9 opened this issue Feb 23, 2023 · 2 comments · Fixed by #22
Closed

swc-plugin inserts imports before "use client" #21

hehex9 opened this issue Feb 23, 2023 · 2 comments · Fixed by #22
Labels
bug Something isn't working

Comments

@hehex9
Copy link

hehex9 commented Feb 23, 2023

The "use client" directive must be placed before other expressions.

ref: https://beta.nextjs.org/docs/rendering/server-and-client-components#convention

Minimal reproducible example

input.js

'use client'
import {t} from '@lingui/macro'
import foo from 'bar'
t`Text`

package.json

{
  "devDependencies": {
    "@lingui/swc-plugin": "0.2.0",
    "@swc/cli": "0.1.62",
    "@swc/core": "1.3.36"
  }
}

Actual

import { i18n } from "@lingui/core";
"use client";
import foo from "bar";
i18n._("Text");

Expected

"use client";
import { i18n } from "@lingui/core";
import foo from "bar";
i18n._("Text");
@timofei-iatsenko
Copy link
Collaborator

Thanks for reporting, i will take a look

timofei-iatsenko added a commit that referenced this issue Feb 23, 2023
@andrii-bodnar andrii-bodnar added the bug Something isn't working label Feb 23, 2023
@andrii-bodnar
Copy link
Contributor

Fixed in the 0.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants