Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

capi serve --target dev broken in vite #1171

Open
ryanleecode opened this issue Jul 12, 2023 · 2 comments · May be fixed by paritytech/docs.capi.dev#48
Open

capi serve --target dev broken in vite #1171

ryanleecode opened this issue Jul 12, 2023 · 2 comments · May be fixed by paritytech/docs.capi.dev#48
Assignees
Labels
bug Something is broken compatibility needs input We need input from the team and/or others

Comments

@ryanleecode
Copy link
Contributor

ryanleecode commented Jul 12, 2023

When changing the dev command in the package json of this PR to capi serve --target dev -- vite, vite throws an error only after the browser webpage is opened.

3:21:40 PM [vite] Internal server 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.
  Plugin: vite:import-analysis
  File: /home/ryan/Documents/Repositories/capi-vite-example/vite/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/client/env.mjs:4:0
  1  |  const context = (() => {
     |  ^
  2  |      if (typeof globalThis !== 'undefined') {
  3  |          return globalThis;
      at formatError (file:///home/ryan/Documents/Repositories/capi-vite-example/vite/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:42645:46)
      at TransformContext.error (file:///home/ryan/Documents/Repositories/capi-vite-example/vite/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:42641:19)
      at TransformContext.transform (file:///home/ryan/Documents/Repositories/capi-vite-example/vite/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:40447:22)
      at async Object.transform (file:///home/ryan/Documents/Repositories/capi-vite-example/vite/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:42919:30)
      at async loadAndTransform (file:///home/ryan/Documents/Repositories/capi-vite-example/vite/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:53385:29)
@ryanleecode ryanleecode added the bug Something is broken label Jul 12, 2023
@robocapi robocapi added this to Capi Jul 12, 2023
@tjjfvi tjjfvi added compatibility needs input We need input from the team and/or others labels Jul 16, 2023
@ryanleecode ryanleecode self-assigned this Jul 17, 2023
@ryanleecode
Copy link
Contributor Author

Initial assessment is it doesn't like the CAPI_SERVER environment variable. When removed it works

@ryanleecode
Copy link
Contributor Author

It works when you add JSON.stringify to the vite env variables similar to webpack. docs.capi.dev will need to be updated.

define: {
  "process.env.CAPI_SERVER": JSON.stringify(process.env.CAPI_SERVER),
  "process.env.CAPI_TARGET": JSON.stringify(process.env.CAPI_TARGET),
}

@ryanleecode ryanleecode closed this as not planned Won't fix, can't repro, duplicate, stale Jul 18, 2023
@github-project-automation github-project-automation bot moved this to Done in Capi Jul 18, 2023
@ryanleecode ryanleecode reopened this Jul 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something is broken compatibility needs input We need input from the team and/or others
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants