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

Add vite + remix app to playground to demo ES Module bug #1293

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

matt-hernandez
Copy link

Changes

This PR adds a Remix + Vite project to the app to demonstrate issue #908 . In order to reproduce that issue, you have to do npm run build and then npm start. This runs the app as if it's in a production environment. The app will crash and produce this output:

> start
> remix-serve ./build/server/index.js

file:///Users/matt.hernandez/Desktop/Projects/posthog-js/playground/remix-vite/build/server/index.js?t=1720462096078.148:7
import { PostHogProvider } from "posthog-js/react/dist/esm/index.js";
         ^^^^^^^^^^^^^^^
SyntaxError: Named export 'PostHogProvider' not found. The requested module 'posthog-js/react/dist/esm/index.js' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'posthog-js/react/dist/esm/index.js';
const { PostHogProvider } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:122:21)
    at ModuleJob.run (node:internal/modules/esm/module_job:188:5)
    at DefaultModuleLoader.import (node:internal/modules/esm/loader:246:24)
    at importModuleDynamicallyWrapper (node:internal/vm/module:428:15)
    at run (/Users/matt.hernandez/Desktop/Projects/posthog-js/playground/remix-vite/node_modules/@remix-run/serve/dist/cli.js:112:15)

This bug is not reproducible when running npm run dev, which is the strangest behavior. It happens when running the app after build and during e2e tests that involve running a built version of the app in Playwright.
...

Checklist

  • [ *] Tests for new code (see advice on the tests we use)
  • [ *] Accounted for the impact of any changes across different browsers
  • [ *] Accounted for backwards compatibility of any changes (no breaking changes in posthog-js!)

Copy link

vercel bot commented Jul 8, 2024

@matt-hernandez is attempting to deploy a commit to the PostHog Team on Vercel.

A member of the Team first needs to authorize it.

@pauldambra
Copy link
Member

amazing, thank you for spending time on this! 💖

@pauldambra
Copy link
Member

sorry @matt-hernandez we had a replay incident this week that has absorbed a lot of my time... all sorted now
i'll pick this up as soon as i can!

@pauldambra pauldambra closed this Jul 11, 2024
@pauldambra pauldambra reopened this Jul 11, 2024
@pauldambra
Copy link
Member

(did not mean to click close 🤣 there's an indication of the kind of week I've had)

baby-circle

@matt-hernandez
Copy link
Author

@pauldambra I know the feeling too well 😆

@posthog-bot
Copy link
Collaborator

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@posthog-bot
Copy link
Collaborator

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@matt-hernandez
Copy link
Author

Still watching this

@jacobjohn-transitiv
Copy link

jacobjohn-transitiv commented Jul 29, 2024

Any update on this or quick workaround? This is preventing me from deploying feature flag functionality in our deployed app due to the same issue noted above -

file:///var/task/build/server/nodejs-eyJydW50aW1lIjoibm9kZWpzIn0/index.js:35
import { useFeatureFlagEnabled } from "posthog-js/react/dist/esm/index.js";
         ^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Named export 'useFeatureFlagEnabled' not found. The requested module 'posthog-js/react/dist/esm/index.js' is a CommonJS module, which may not support all module.exports as named exports.

As noted in the original comment, feature flags are working just fine locally with npm run dev but the deployed version does not work

@pauldambra

@pauldambra pauldambra added waiting and removed stale labels Jul 29, 2024
@posthog-bot
Copy link
Collaborator

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@posthog-bot
Copy link
Collaborator

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@matt-hernandez
Copy link
Author

Still watching this

@posthog-bot posthog-bot removed the stale label Aug 15, 2024
@posthog-bot
Copy link
Collaborator

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@matt-hernandez
Copy link
Author

Still watching this

@posthog-bot posthog-bot removed the stale label Aug 23, 2024
@pauldambra
Copy link
Member

hey @matt-hernandez i've been unexpectedly out of the office for three weeks so my to-do list is a little unhealthy right now 🙈

haven't forgotten about this though

i don't know if @robbie-c has time to look at this before i do but i'll tag him in case i can nerd snipe him

https://xkcd.com/356/

@posthog-bot
Copy link
Collaborator

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@posthog-bot
Copy link
Collaborator

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@matt-hernandez
Copy link
Author

We’ve seen a workaround for this that doesn’t seem unreasonable. I need to implement it to verify it on my end

@pauldambra pauldambra removed the stale label Sep 10, 2024
@posthog-bot
Copy link
Collaborator

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@matt-hernandez
Copy link
Author

Going to try the workaround today. If it works, I'll add it to this PR

@posthog-bot posthog-bot removed the stale label Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants