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

[BUG] Transform failed with 1 error: <stdin>:1:286: ERROR: The symbol "xt" has already been declared #27

Closed
ztjhz opened this issue Mar 25, 2023 · 8 comments

Comments

@ztjhz
Copy link

ztjhz commented Mar 25, 2023

I get the following error when I run yarn build.

Error message:

➜  FreeChatGPT git:(tiktoken) yarn build
yarn run v1.22.19
$ tsc && vite build
vite v4.1.4 building for production...
✓ 1789 modules transformed.
rendering chunks (3)...[vite-plugin-top-level-await] Transform failed with 1 error:
<stdin>:1:286: ERROR: The symbol "xt" has already been declared
error during build:
Error: Transform failed with 1 error:
<stdin>:1:286: ERROR: The symbol "xt" has already been declared
    at failureErrorWithLog (/home/nixie/FreeChatGPT/node_modules/esbuild/lib/main.js:1604:15)
    at /home/nixie/FreeChatGPT/node_modules/esbuild/lib/main.js:837:29
    at responseCallbacks.<computed> (/home/nixie/FreeChatGPT/node_modules/esbuild/lib/main.js:701:9)
    at handleIncomingPacket (/home/nixie/FreeChatGPT/node_modules/esbuild/lib/main.js:756:9)
    at Socket.readFromStdout (/home/nixie/FreeChatGPT/node_modules/esbuild/lib/main.js:677:7)
    at Socket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Readable.push (node:internal/streams/readable:234:10)
    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Source code: https://github.com/ztjhz/BetterChatGPT/tree/tiktoken

I spent a long time debugging this. I discovered that the xt is actually a module called Canvg, which is an optional dependency of another module jspdf. When I remove the import of jspdf in my source code, the compilation would work.

@ztjhz
Copy link
Author

ztjhz commented Mar 25, 2023

In addition, I am using vite-plugin-top-level-await because tiktoken needs vite-plugin-wasm which needs vite-plugin-top-level-await

@MinatoHikari
Copy link

same problem here

@danielmahal
Copy link

Same problem here

@yashash-pugalia
Copy link

+1

@Menci
Copy link
Owner

Menci commented May 17, 2023 via email

@Menci
Copy link
Owner

Menci commented May 20, 2023

Hi! After investigation I found the issue is that the file being processed exported the same name Canvg as both itself and default:

export {
  AElement,
  AnimateColorElement,
  AnimateElement,
  AnimateTransformElement,
  BoundingBox,
  CB1,
  CB2,
  CB3,
  CB4,
  Canvg, # here
  CircleElement,
  ClipPathElement,
  DefsElement,
  DescElement,
  Document,
  Element,
  EllipseElement,
  FeColorMatrixElement,
  FeCompositeElement,
  FeDropShadowElement,
  FeGaussianBlurElement,
  FeMorphologyElement,
  FilterElement,
  Font,
  FontElement,
  FontFaceElement,
  GElement,
  GlyphElement,
  GradientElement,
  ImageElement,
  LineElement,
  LinearGradientElement,
  MarkerElement,
  MaskElement,
  Matrix,
  MissingGlyphElement,
  Mouse,
  PSEUDO_ZERO,
  Parser,
  PathElement,
  PathParser,
  PatternElement,
  Point,
  PolygonElement,
  PolylineElement,
  Property,
  QB1,
  QB2,
  QB3,
  RadialGradientElement,
  RectElement,
  RenderedElement,
  Rotate,
  SVGElement,
  SVGFontLoader,
  Scale,
  Screen,
  Skew,
  SkewX,
  SkewY,
  StopElement,
  StyleElement,
  SymbolElement,
  TRefElement,
  TSpanElement,
  TextElement,
  TextPathElement,
  TitleElement,
  Transform,
  Translate,
  UnknownElement,
  UseElement,
  ViewPort,
  __tla,
  compressSpaces,
  Canvg as default, # here
  getSelectorSpecificity,
  normalizeAttributeName,
  normalizeColor,
  parseExternalUrl,
  index as presets,
  toNumbers,
  trimLeft,
  trimRight,
  vectorMagnitude,
  vectorsAngle,
  vectorsRatio
};

So I generated two let entries for them.

Now I fixed it and you all may test it later in the next version. Thanks for you all and especially @ztjhz for the reproduce!

@Menci
Copy link
Owner

Menci commented May 20, 2023

Please try latest v1.3.1.

@ztjhz
Copy link
Author

ztjhz commented May 20, 2023

Thanks for the fix!

@Menci Menci closed this as completed Jun 3, 2023
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

5 participants