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

Weird build/dev issue #414

Open
devinatbryt opened this issue Nov 21, 2024 · 0 comments
Open

Weird build/dev issue #414

devinatbryt opened this issue Nov 21, 2024 · 0 comments

Comments

@devinatbryt
Copy link

To prefix, I'm building a library composed of several different packages. This error only seems to happen within this branch. What's weird is I've tried using the following code from my library and using it anywhere within my example app:

export type ExtractOperationName<T extends string> =
  T extends `${infer _}${"query" | "mutation"} ${infer Name}(${infer _}) {${infer _}`
    ? Name
    : T extends `${infer _}${"query" | "mutation"} ${infer Name} {${infer _}`
      ? Name
      : never;

export const extractName = <const Operation extends string>(
  operation: Operation,
) =>
  Effect.succeed(operation).pipe(
    Effect.filterOrFail(
      (operation) => {
        const match = operation.match(/\b(query|mutation)\b\s+(\w+)/);
        return !!match;
      },
      (operation) => new ExtractOperationNameError(operation),
    ),
    Effect.andThen((operation) => {
      const match = operation.match(/\b(query|mutation)\b\s+(\w+)/);
      return Effect.succeed(match![2] as ExtractOperationName<Operation>);
    }),
  );

  export const extractOperationName = <const Operation extends string>(
    operation: Operation,
  ) => Effect.runSync(extractName(operation));

The above code when being imported and then invoked from my library forces vinxi to throw the following error:

[BABEL] Note: The code generator has deoptimised the styling of /solidifront/examples/basic/node_modules/.vinxi/client/deps/chunk-7ZA5M5KR.js as it exceeds the max of 500KB.
[BABEL] Note: The code generator has deoptimised the styling of /solidifront/examples/basic/node_modules/.vinxi/client/deps/chunk-NDCOVFYX.js as it exceeds the max of 500KB.

[vite] Internal server error: /solidifront/examples/basic/node_modules/.vinxi/client/deps/chunk-RLWJ43YW.js: Unexpected token, expected "=>" (2110:10)

  2108 |     resolve(exitDie(e));
  2109 |   }
> 2110 | }) : async((resolve) => {
       |           ^
  2111 |   try {
  2112 |     ;
  2113 |     evaluate().then((a) => resolve(exitSucceed(a)), (e) => resolve(exitDie(e)))
  
   at constructor (/solidifront/node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/lib/index.js:359:19)
      at TypeScriptParserMixin.raise (/solidifront/node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/lib/index.js:3266:19)
      at TypeScriptParserMixin.unexpected (/solidifront/node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/lib/index.js:3286:16)
      at TypeScriptParserMixin.expect (/solidifront/node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/lib/index.js:3596:12)
      at TypeScriptParserMixin.parseAsyncArrowFromCallExpression (/solidifront/node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/lib/index.js:10795:10)
      
11:35:22 AM [vite] Error when evaluating SSR module /src/routes/[[locale]]/notFound.tsx: failed to import "@solidjs/start"
|- TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".jsx" for /solidifront/node_modules/.pnpm/@[email protected][email protected][email protected]_@[email protected][email protected][email protected]_ces4gtbucflqcjtgl4a4owrqj4/node_modules/@solidjs/start/dist/index.jsx
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:218:9)
    at defaultGetFormat (node:internal/modules/esm/get_format:244:36)
    at defaultLoad (node:internal/modules/esm/load:120:22)
    at async ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:479:32)
    at async ModuleJob._link (node:internal/modules/esm/module_job:112:19)

11:35:22 AM [vite] Error when evaluating SSR module /solidifront/examples/basic/src/routes/[[locale]]/notFound.tsx?pick=default&pick=$css: failed to import "@solidjs/start"
|- TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".jsx" for /solidifront/node_modules/.pnpm/@[email protected][email protected][email protected]_@[email protected][email protected][email protected]_ces4gtbucflqcjtgl4a4owrqj4/node_modules/@solidjs/start/dist/index.jsx
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:218:9)
    at defaultGetFormat (node:internal/modules/esm/get_format:244:36)
    at defaultLoad (node:internal/modules/esm/load:120:22)
    at async ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:479:32)
    at async ModuleJob._link (node:internal/modules/esm/module_job:112:19)

11:35:22 AM [vite] Error when evaluating SSR module /solidifront/examples/basic/src/routes/[[locale]]/[...404].tsx?pick=default&pick=$css: failed to import "@solidjs/start"
|- TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".jsx" for /solidifront/node_modules/.pnpm/@[email protected][email protected][email protected]_@[email protected][email protected][email protected]_ces4gtbucflqcjtgl4a4owrqj4/node_modules/@solidjs/start/dist/index.jsx
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:218:9)
    at defaultGetFormat (node:internal/modules/esm/get_format:244:36)
    at defaultLoad (node:internal/modules/esm/load:120:22)
    at async ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:479:32)
    at async ModuleJob._link (node:internal/modules/esm/module_job:112:19)

Any code within the library that uses this function also throws the error. However, it's not the function's fault, as accessing within the library that uses it works as intended. If I also log the result using the function and console, I get the expected result, and then the error is thrown.

For context, this will get the name of a graphql as both the value and the type:

// The above utility is created within our @solidifront/storefront-client package and then remapped to: "extractOperationName"
import {extractOperationName} from "@solidifront/start"

const shopQuery = `#graphql
  query ShopQuery($shopId: ID!) {
    shop(id: $shopId) {
      id
     }
  }
`;

const operationName = extractOperationName(shopQuery)

type Test = typeof operationName // ShopQuery

console.log(operationName) // ShopQuery

I can't replicate this issue if the above code isn't within an external library. I wish I could create a stack overflow for this issue, but I don't want to merge these changes onto my main branch and publish them until I've figured out the root cause.

Anyways any help here is greatly appreciated! Thank you so much! Please let me know if you need any further information!

Also, I have tried to delete the .vinxi and node_modules folder several times but still have the same issue.

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

1 participant