huozhi / bunchee

Zero config bundler for ECMAScript and TypeScript packages
https://npmjs.com/bunchee
933 stars 29 forks source link

Bunchee Syntax Error on `export type {}` after upgrading to v3 from v2 #237

Closed sannajammeh closed 1 year ago

sannajammeh commented 1 year ago

Receiving this weird Syntax Error when trying to run bunchee. I can confirm this is working if you downgrade to bunchee@2

bunchee ./src/index.tsx --target es2018

(warning) "exports.require" has overwritten "main" since they are duplicated.
Unknown input options: onLog. Allowed options: acorn, acornInjectPlugins, cache, context, experimentalCacheExpiry, experimentalLogSideEffects, external, inlineDynamicImports, input, makeAbsoluteExternalsRelative, manualChunks, maxParallelFileOps, maxParallelFileReads, moduleContext, onwarn, perf, plugins, preserveEntrySignatures, preserveModules, preserveSymlinks, shimMissingExports, strictDeprecations, treeshake, watch
Error: 
  × Expected ',', got '{'
   ╭─[1:1]
 1 │ export { classedProxy as classed } from "./proxy";
 2 │ export { createClassed, makeStrict } from "./classed";
 3 │ export { deriveClassed } from "./deriveClassed";
 4 │ export type { ClassedConfig } from "./classed";
   ·             ─
 5 │ export type { DeriveClassedFunction } from "./deriveClassed";
 6 │ export type {
 7 │   InferVariantProps,
   ╰────

Caused by:
    Syntax Error
 ELIFECYCLE  Command failed with exit code 1.

Repro (not minimal):

https://github.com/sannajammeh/tw-classed/tree/deps-export-cx

Steps:

  1. run pnpm i in root
  2. cd into packages/react
  3. run pnpm build - watch it fail
  4. run pnpm i bunchee@2 -D
  5. running pnpm build will now succeed
huozhi commented 1 year ago

Looks like it's an issue introduced in 3.6.0, 3.5.0 seems compiling as expected, still error with the repro tho but it's sth else related to the compiling order. Will investigate

sannajammeh commented 1 year ago

Can confirm its now working! Greatly appreciate the speed here, thanks!

huozhi commented 1 year ago

@sannajammeh not sure which version are you trying, also published the 3.6.1, it should fix the issue

sannajammeh commented 1 year ago

@huozhi yep thats the versjon I tested. Should've mentioned that. Was just commending how fast you fixed it 😀