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

Vite: SSR compile error with importing *.client.ts #7972

Closed
1 task done
na2hiro opened this issue Nov 10, 2023 · 4 comments
Closed
1 task done

Vite: SSR compile error with importing *.client.ts #7972

na2hiro opened this issue Nov 10, 2023 · 4 comments

Comments

@na2hiro
Copy link
Contributor

na2hiro commented Nov 10, 2023

What version of Remix are you using?

2.2.0

Are all your remix dependencies & dev-dependencies using the same version?

  • Yes

Steps to Reproduce

When a route imports *.client.ts, it results in compile error

import { myAlert } from '~/something.client';

export default function Index() {
  return (
...
      <button onClick={() => myAlert('clicked')}>
        click to invoke client-only method
      </button>
  )
}

Here's repro https://stackblitz.com/edit/github-suecku?file=app/something.client.ts,app/routes/_index.tsx

Expected Behavior

vite build --ssr succeeds, and myAlert is provided undefined in server (according to https://remix.run/docs/en/main/file-conventions/-client)

Actual Behavior

vite build --ssr results in compile error

vite v4.5.0 building SSR bundle for production...

  ⚠️  Remix support for Vite is unstable
     and not recommended for production

✓ 7 modules transformed.
✓ built in 87ms
"myAlert" is not exported by "app/something.client.ts", imported by "app/routes/_index.tsx".
file: /home/projects/github-suecku/app/routes/_index.tsx:2:9
1: import type { MetaFunction } from '@remix-run/node';
2: import { myAlert } from '~/something.client';
            ^
3: 
4: export const meta: MetaFunction = () => {
error during build:
RollupError: "myAlert" is not exported by "app/something.client.ts", imported by "app/routes/_index.tsx".
    at error (/home/projects/github-suecku/node_modules/rollup/dist/es/shared/node-entry.js:2312:30)
    at Module.error (/home/projects/github-suecku/node_modules/rollup/dist/es/shared/node-entry.js:13770:16)
    at Module.traceVariable (/home/projects/github-suecku/node_modules/rollup/dist/es/shared/node-entry.js:14200:29)
    at ModuleScope.findVariable (/home/projects/github-suecku/node_modules/rollup/dist/es/shared/node-entry.js:12640:39)
    at FunctionScope.findVariable (/home/projects/github-suecku/node_modules/rollup/dist/es/shared/node-entry.js:7149:38)
    at ChildScope.findVariable (/home/projects/github-suecku/node_modules/rollup/dist/es/shared/node-entry.js:7149:38)
    at ReturnValueScope.findVariable (/home/projects/github-suecku/node_modules/rollup/dist/es/shared/node-entry.js:7149:38)
    at Identifier.bind (/home/projects/github-suecku/node_modules/rollup/dist/es/shared/node-entry.js:8344:40)
    at CallExpression.bind (/home/projects/github-suecku/node_modules/rollup/dist/es/shared/node-entry.js:5917:23)
    at CallExpression.bind (/home/projects/github-suecku/node_modules/rollup/dist/es/shared/node-entry.js:9915:15)
@cliffordfajardo
Copy link
Contributor

Also running into this during a migration

@pcattori pcattori modified the milestone: Stabilize Vite Nov 20, 2023
@pcattori pcattori self-assigned this Dec 2, 2023
@pcattori
Copy link
Contributor

pcattori commented Dec 3, 2023

Fixed by #8200

@pcattori pcattori closed this as completed Dec 3, 2023
Copy link
Contributor

github-actions bot commented Dec 5, 2023

🤖 Hello there,

We just published version 2.4.0-pre.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Copy link
Contributor

🤖 Hello there,

We just published version 2.4.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

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

No branches or pull requests

4 participants