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

When I add the declaration property and try to execute unbuild, I get an error #138

Closed
xzblog opened this issue Oct 27, 2022 · 3 comments
Closed

Comments

@xzblog
Copy link

xzblog commented Oct 27, 2022

it's error

miracle@MiracledeMacBook-Pro publish % pnpm build

> @titanjs/publish@1.0.2 build /Users/miracle/workspace/titan/packages/publish
> unbuild

ℹ Building @titanjs/publish                                                                                              23:26:29
Error building /Users/miracle/workspace/titan/packages/publish: Error: Transform failed with 1 error:
<stdin>:1:8: ERROR: Expected ";" but found "const"
Error: Transform failed with 1 error:
<stdin>:1:8: ERROR: Expected ";" but found "const"
    at failureErrorWithLog (/Users/miracle/workspace/titan/node_modules/.pnpm/esbuild@0.15.12/node_modules/esbuild/lib/main.js:1566:15)
    at /Users/miracle/workspace/titan/node_modules/.pnpm/esbuild@0.15.12/node_modules/esbuild/lib/main.js:805:29
    at responseCallbacks.<computed> (/Users/miracle/workspace/titan/node_modules/.pnpm/esbuild@0.15.12/node_modules/esbuild/lib/main.js:671:9)
    at handleIncomingPacket (/Users/miracle/workspace/titan/node_modules/.pnpm/esbuild@0.15.12/node_modules/esbuild/lib/main.js:726:9)
    at Socket.readFromStdout (/Users/miracle/workspace/titan/node_modules/.pnpm/esbuild@0.15.12/node_modules/esbuild/lib/main.js:647:7)
    at Socket.emit (node:events:390:28)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:289:9)
    at Socket.Readable.push (node:internal/streams/readable:228:10)
    at Pipe.onStreamRead (node:internal/stream_base_commons:199:23) {
  errors: [
    {
      detail: undefined,
      id: '',
      location: [Object],
      notes: [],
      pluginName: '',
      text: 'Expected ";" but found "const"'
    }
  ],
  warnings: [],
  code: 'PLUGIN_ERROR',
  plugin: 'esbuild',
  hook: 'renderChunk'
}
 ELIFECYCLE  Command failed with exit code 1.

unbuild doesn't export type declarations by default, so I added declaration: true, When I add it and try to execute unbuild, I get an error。

it's my config

import { defineBuildConfig } from 'unbuild'
export default defineBuildConfig({
  entries: ['src/index'],
  clean: true,
  failOnWarn: false,
  declaration: true,
  rollup: {
    inlineDependencies: true,
    esbuild: {
      minify: true
    }
  },
  alias: {
  },
  hooks: {
    'rollup:options'(ctx, options) {
      if (!options.plugins) {
        options.plugins = []
      }
    }
  }
})

my node version 16.18.0, unbuild version is 0.9.4

@dwightjack
Copy link
Contributor

It's difficult to understand the issue without knowing the source code, at least the line that is causing the error. Anyway, if you remove the rollup configuration object, does the error persist?

@dwightjack
Copy link
Contributor

Oh, wait! Maybe this issue is the same as #112. If so it is probably an issue using esbuild minify and declaration: true together.

@pi0
Copy link
Member

pi0 commented Jul 18, 2023

I have added declaration to the min+ sourcemap fixture (7dcda3f) and seems to be working fine on latest main (upcoming release)

Please let me know if you still had issues to reopen and track.

@pi0 pi0 closed this as completed Jul 18, 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

3 participants