Skip to content

Astro support? #6

Open
Open

Description

@0x241F31

I'm trying to run macaron inside Astro project within Solid component. So I placed it inside Astro's vite config, plugins array.
but getting an error:

[vite] Internal server error: ENOENT: no such file or directory, open 'astro:scripts/before-hydration.js'
  Plugin: macaron-css-vite
  File: astro:scripts/before-hydration.js

Activity

  1. Mokshit06 commented on Nov 17, 2022

    @Mokshit06
    Member

    This is unexpected but probably has something to do with how macaron does file resolution. I'll look into why it is happening, but this should be an easy fix

  2. Mokshit06 commented on Nov 23, 2022

    @Mokshit06
    Member

    Hey, I'm not getting this error when trying out Astro with macaron. Can you try this again, and if it's still there it would be great if you could make a reproduction of this.
    You can't declare macaron styles and components inside the .astro file. That is a limitation of astro as it doesn't run the vite plugins on the js code that exists on the pages, but importing styles from another file should work fine.

  3. arstnei0 commented on Mar 5, 2023

    @arstnei0

    I also ran into a bunch of problems with Astro. The errors at dev time and build time are different, but they are all emitted by [vite:build-import-analysis].

    At dev time, the error is:

    
    - You may have created styles outside of a '.css.ts' context
    - You may have incorrect configuration. See https://vanilla-extract.style/documentation/getting-started
        at Object.getFileScope (/home/zihan/h/ohhwebdev/node_modules/.pnpm/@vanilla-extract+css@1.9.5/node_modules/@vanilla-extract/css/fileScope/dist/vanilla-extract-css-fileScope.cjs.dev.js:33:11)
        at Proxy.globalStyle (/home/zihan/h/ohhwebdev/node_modules/.pnpm/@vanilla-extract+css@1.9.5/node_modules/@vanilla-extract/css/dist/vanilla-extract-css.cjs.dev.js:382:48)
        at /home/zihan/h/ohhwebdev/course/src/styles/global.css.ts:6:0
        at async instantiateModule (file:///home/zihan/h/ohhwebdev/node_modules/.pnpm/vite@4.1.4_@types+node@18.14.6/node_modules/vite/dist/node/chunks/dep-ca21228b.js:52420:9)
    

    At build time, the error is

    Error: Parse error @:22:77
        at parse$e (file:///home/zihan/h/ohhwebdev/node_modules/.pnpm/vite@4.1.4_@types+node@18.14.6/node_modules/vite/dist/node/chunks/dep-ca21228b.js:14787:355)
        at Object.transform (file:///home/zihan/h/ohhwebdev/node_modules/.pnpm/vite@4.1.4_@types+node@18.14.6/node_modules/vite/dist/node/chunks/dep-ca21228b.js:43542:27)
    

    The behavior is so weird. Let me try to make a reproduction.

  4. arstnei0 commented on Mar 5, 2023

    @arstnei0

    This time it shows me this:

     error   Failed to parse source for import analysis because the content contains invalid JS syntax. If you are using JSX, make sure to name the file with the .jsx or .tsx extension.
      File:
        /home/projects/withastro-astro-yxe87y/src/components/Button.tsx:5:59
      Code:
        3  |  const button = _$macaron$$button2;
        4  |  export default (props => {
        5  |    return <button class={button}>{props.children}</button>;
           |                                                            ^
        6  |  });
    

    Now the problem should be obvious, that the macaron vite plugin gives vite the wrong file extension after transforming it I guess.

  5. arstnei0 commented on Mar 5, 2023

    @arstnei0

    Oh Astro's solid integration is not acting as a vite plugin, but it's using astro's renderer api. The order of the transformers may be unpredictable and the error just occured.

  6. broccolai commented on Jun 24, 2023

    @broccolai

    I've been looking into fixing this, but I've been having a hard time debugging it. A macaron integration (astros own implementation of "plugins") could be made

  7. broccolai commented on Jun 24, 2023

    @broccolai

    Posted a bounty for this

  8. Mokshit06 commented on Jun 25, 2023

    @Mokshit06
    Member

    Thanks @broccolai for creating the bounty! Glad to see people support development of macaron. Unfortunately haven't been getting time to look into this issue, but will try to see if i can find a fix this week.

  9. jasons123fortheuse commented on Aug 9, 2023

    @jasons123fortheuse

    The error message you've provided is related to the Vite build system. It appears that it's unable to find a file called 'astro:scripts/before-hydration.js'.

    There are a few steps you can take to try and resolve the issue:

    Check that the file 'astro:scripts/before-hydration.js' exists in your project and is located at the path specified. If it's not in the expected location, then move it there.

    Check that the file is not being deleted during the build process. Check your
    .vite.config.js
    or
    .vite.yaml
    file to see if there are any build steps that might be removing the file.

    Try clearing your cache by running
    npm cache clean --force
    or deleting the node_modules directory in your project and reinstalling them with
    npm install
    .

    Restart your development server and try the build again.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions