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

Use of optional chaining results in errors #27

Closed
Barabazs opened this issue Jul 18, 2021 · 2 comments
Closed

Use of optional chaining results in errors #27

Barabazs opened this issue Jul 18, 2021 · 2 comments

Comments

@Barabazs
Copy link

Hi @sindresorhus When I use optional chaining in my file (anywhere) it results in an error when running gulp-strip-debug.

node:eve unts:371
      throw er; // Unhandled 'error' event
      ^
PluginError [SyntaxError]: Unexpected token .
    at Espree.raise (./node_modules/espree/lib/espree.js:190:25)
    at Espree.unexpected (./node_modules/espree/lib/espree.js:235:18)
    at Espree.pp$3.parseExprAtom (./node_modules/acorn/dist/acorn.js:2326:12)
    at Espree.parseExprAtom (./node_modules/acorn-jsx/index.js:445:22)
    at Espree.pp$3.parseExprSubscripts (./node_modules/acorn/dist/acorn.js:2129:21)
    at Espree.pp$3.parseMaybeUnary (./node_modules/acorn/dist/acorn.js:2106:19)
    at Espree.pp$3.parseExprOps (./node_modules/acorn/dist/acorn.js:2041:21)
    at Espree.pp$3.parseMaybeConditional (./node_modules/acorn/dist/acorn.js:2024:21)
    at Espree.pp$3.parseMaybeAssign (./node_modules/acorn/dist/acorn.js:1997:21)
    at Espree.pp$3.parseMaybeConditional (./node_modules/acorn/dist/acorn.js:2029:30)
Emitted 'error' event on Domain instance at:
    at Transform.emit (node:domain:520:12)
    at Transform.onerror (./node_modules/readable-stream/lib/_stream_readable.js:640:52)
    at Transform.emit (node:events:394:28)
    at Transform.emit (node:domain:470:12)
    at Transform._transform (./node_modules/gulp-strip-debug/index.js:22:9)
    at Transform._read (./node_modules/gulp-strip-debug/node_modules/readable-stream/lib/_stream_transform.js:177:10)
    at Transform._write (./node_modules/gulp-strip-debug/node_modules/readable-stream/lib/_stream_transform.js:164:83)
    at doWrite (./node_modules/gulp-strip-debug/node_modules/readable-stream/lib/_stream_writable.js:409:139)
    at writeOrBuffer (./node_modules/gulp-strip-debug/node_modules/readable-stream/lib/_stream_writable.js:398:5)
    at Transform.Writable.write (./node_modules/gulp-strip-debug/node_modules/readable-stream/lib/_stream_writable.js:307:11) {
  index: 5672,
  lineNumber: 194,
  column: 33,
  __safety: undefined,
  _stack: undefined,
  plugin: 'gulp-strip-debug',
  showProperties: true,
  showStack: false,
  fileName: './src/main.js',
  domainEmitter: Transform {
    _readableState: ReadableState {
      objectMode: true,
      highWaterMark: 16,
      buffer: BufferList { head: null, tail: null, length: 0 },
      length: 0,
      pipes: Pumpify {
        _readableState: ReadableState {
          objectMode: true,
          highWaterMark: 16,
          buffer: BufferList { head: null, tail: null, length: 0 },
          length: 0,
          pipes: WriteStream {
            _writableState: [WritableState],
            writable: true,
            _events: [Object: null prototype],
            _eventsCount: 5,
            _maxListeners: undefined,
            _worker: [Function: sinker],
            _flush: null,
            [Symbol(kCapture)]: false
          },
          pipesCount: 1,
          flowing: true,
          ended: false,
          endEmitted: false,
          reading: true,
          sync: false,
          needReadable: true,
          emittedReadable: false,
          readableListening: false,
          resumeScheduled: false,
          destroyed: false,
          defaultEncoding: 'utf8',
          awaitDrain: 0,
          readingMore: false,
          decoder: null,
          encoding: null
        },
        readable: true,
        _events: [Object: null prototype] {
          end: [ [Function], [Function] ],
          close: [ [Function: onclose], [Function] ],
          prefinish: [Function (anonymous)],
          newListener: [Function: removeSink],
          removeListener: [ [Function: removeSink], [Function: addSink] ],
          unpipe: [Function: onunpipe],
          drain: [Function: pipeOnDrainFunctionResult],
          error: [Function: onerror],
          finish: [Function: bound onceWrapper] {
            listener: [Function: onfinish]
          },
          data: [Function: ondata]
        },
        _eventsCount: 10,
        _maxListeners: undefined,
        _writableState: WritableState {
          objectMode: true,
          highWaterMark: 16,
          finalCalled: false,
          needDrain: false,
          ending: false,
          ended: false,
          finished: false,
          destroyed: false,
          decodeStrings: true,
          defaultEncoding: 'utf8',
          length: 0,
          writing: false,
          corked: 0,
          sync: true,
          bufferProcessing: false,
          onwrite: [Function (anonymous)],
          writecb: null,
          writelen: 0,
          bufferedRequest: null,
          lastBufferedRequest: null,
          pendingcb: 0,
          prefinished: false,
          errorEmitted: false,
          bufferedRequestCount: 0,
          corkedRequestsFree: CorkedRequest {
            next: null,
            entry: null,
            finish: [Function (anonymous)]
          }
        },
        writable: true,
        allowHalfOpen: true,
        _writable: DestroyableTransform {
          _readableState: ReadableState {
            objectMode: true,
            highWaterMark: 16,
            buffer: [BufferList],
            length: 0,
            pipes: [DestroyableTransform],
            pipesCount: 1,
            flowing: true,
            ended: false,
            endEmitted: false,
            reading: true,
            sync: false,
            needReadable: true,
            emittedReadable: false,
            readableListening: false,
            resumeScheduled: false,
            destroyed: false,
            defaultEncoding: 'utf8',
            awaitDrain: 0,
            readingMore: false,
            decoder: null,
            encoding: null
          },
          readable: true,
          _events: [Object: null prototype] {
            end: [Array],
            prefinish: [Function: prefinish],
            close: [Array],
            finish: [Array],
            error: [Array],
            data: [Function: ondata],
            drain: [Function: ondrain]
          },
          _eventsCount: 7,
          _maxListeners: undefined,
          _writableState: WritableState {
            objectMode: true,
            highWaterMark: 16,
            finalCalled: false,
            needDrain: false,
            ending: false,
            ended: false,
            finished: false,
            destroyed: false,
            decodeStrings: true,
            defaultEncoding: 'utf8',
            length: 0,
            writing: false,
            corked: 0,
            sync: true,
            bufferProcessing: false,
            onwrite: [Function (anonymous)],
            writecb: null,
            writelen: 0,
            bufferedRequest: null,
            lastBufferedRequest: null,
            pendingcb: 0,
            prefinished: false,
            errorEmitted: false,
            bufferedRequestCount: 0,
            corkedRequestsFree: [CorkedRequest]
          },
          writable: true,
          allowHalfOpen: true,
          _transformState: {
            afterTransform: [Function: bound afterTransform],
            needTransform: true,
            transforming: false,
            writecb: null,
            writechunk: null,
            writeencoding: null
          },
          _destroyed: false,
          _transform: [Function: normalize],
          [Symbol(kCapture)]: false
        },
        _readable: DestroyableTransform {
          _readableState: ReadableState {
            objectMode: true,
            highWaterMark: 16,
            buffer: [BufferList],
            length: 0,
            pipes: null,
            pipesCount: 0,
            flowing: null,
            ended: false,
            endEmitted: false,
            reading: true,
            sync: false,
            needReadable: true,
            emittedReadable: false,
            readableListening: true,
            resumeScheduled: false,
            destroyed: false,
            defaultEncoding: 'utf8',
            awaitDrain: 0,
            readingMore: false,
            decoder: null,
            encoding: null
          },
          readable: true,
          _events: [Object: null prototype] {
            end: [Array],
            prefinish: [Function: prefinish],
            close: [Array],
            finish: [Array],
            error: [Array],
            unpipe: [Function: onunpipe],
            drain: [Function (anonymous)],
            readable: [Function: onreadable]
          },
          _eventsCount: 8,
          _maxListeners: undefined,
          _writableState: WritableState {
            objectMode: true,
            highWaterMark: 16,
            finalCalled: false,
            needDrain: false,
            ending: false,
            ended: false,
            finished: false,
            destroyed: false,
            decodeStrings: true,
            defaultEncoding: 'utf8',
            length: 0,
            writing: false,
            corked: 0,
            sync: true,
            bufferProcessing: false,
            onwrite: [Function (anonymous)],
            writecb: null,
            writelen: 0,
            bufferedRequest: null,
            lastBufferedRequest: null,
            pendingcb: 0,
            prefinished: false,
            errorEmitted: false,
            bufferedRequestCount: 0,
            corkedRequestsFree: [CorkedRequest]
          },
          writable: true,
          allowHalfOpen: true,
          _transformState: {
            afterTransform: [Function: bound afterTransform],
            needTransform: true,
            transforming: false,
            writecb: null,
            writechunk: null,
            writeencoding: null
          },
          _destroyed: false,
          _transform: [Function: writeFile],
          [Symbol(kCapture)]: false
        },
        _readable2: DestroyableTransform {
          _readableState: ReadableState {
            objectMode: true,
            highWaterMark: 16,
            buffer: [BufferList],
            length: 0,
            pipes: null,
            pipesCount: 0,
            flowing: null,
            ended: false,
            endEmitted: false,
            reading: true,
            sync: false,
            needReadable: true,
            emittedReadable: false,
            readableListening: true,
            resumeScheduled: false,
            destroyed: false,
            defaultEncoding: 'utf8',
            awaitDrain: 0,
            readingMore: false,
            decoder: null,
            encoding: null
          },
          readable: true,
          _events: [Object: null prototype] {
            end: [Array],
            prefinish: [Function: prefinish],
            close: [Array],
            finish: [Array],
            error: [Array],
            unpipe: [Function: onunpipe],
            drain: [Function (anonymous)],
            readable: [Function: onreadable]
          },
          _eventsCount: 8,
          _maxListeners: undefined,
          _writableState: WritableState {
            objectMode: true,
            highWaterMark: 16,
            finalCalled: false,
            needDrain: false,
            ending: false,
            ended: false,
            finished: false,
            destroyed: false,
            decodeStrings: true,
            defaultEncoding: 'utf8',
            length: 0,
            writing: false,
            corked: 0,
            sync: true,
            bufferProcessing: false,
            onwrite: [Function (anonymous)],
            writecb: null,
            writelen: 0,
            bufferedRequest: null,
            lastBufferedRequest: null,
            pendingcb: 0,
            prefinished: false,
            errorEmitted: false,
            bufferedRequestCount: 0,
            corkedRequestsFree: [CorkedRequest]
          },
          writable: true,
          allowHalfOpen: true,
          _transformState: {
            afterTransform: [Function: bound afterTransform],
            needTransform: true,
            transforming: false,
            writecb: null,
            writechunk: null,
            writeencoding: null
          },
          _destroyed: false,
          _transform: [Function: writeFile],
          [Symbol(kCapture)]: false
        },
        _autoDestroy: false,
        _forwardDestroy: false,
        _forwardEnd: true,
        _corked: 0,
        _ondrain: null,
        _drained: true,
        _forwarding: false,
        _unwrite: [Function: clear],
        _unread: [Function: clear],
        _ended: false,
        [Symbol(kCapture)]: false
      },
      pipesCount: 1,
      flowing: true,
      ended: false,
      endEmitted: false,
      reading: true,
      sync: false,
      needReadable: true,
      emittedReadable: false,
      readableListening: false,
      resumeScheduled: false,
      paused: false,
      emitClose: true,
      autoDestroy: false,
      destroyed: false,
      defaultEncoding: 'utf8',
      awaitDrain: 0,
      readingMore: false,
      decoder: null,
      encoding: null
    },
    readable: true,
    _events: [Object: null prototype] {
      prefinish: [Function: prefinish],
      end: [Function: bound onceWrapper] { listener: [Function: onend] },
      data: [Function: ondata]
    },
    _eventsCount: 3,
    _maxListeners: undefined,
    _writableState: WritableState {
      objectMode: true,
      highWaterMark: 16,
      finalCalled: false,
      needDrain: false,
      ending: false,
      ended: false,
      finished: false,
      destroyed: false,
      decodeStrings: true,
      defaultEncoding: 'utf8',
      length: 1,
      writing: true,
      corked: 0,
      sync: true,
      bufferProcessing: false,
      onwrite: [Function (anonymous)],
      writecb: [Function: nop],
      writelen: 1,
      bufferedRequest: null,
      lastBufferedRequest: null,
      pendingcb: 1,
      prefinished: false,
      errorEmitted: false,
      emitClose: true,
      autoDestroy: false,
      bufferedRequestCount: 0,
      corkedRequestsFree: CorkedRequest {
        next: null,
        entry: null,
        finish: [Function (anonymous)]
      }
    },
    writable: true,
    allowHalfOpen: true,
    _transformState: {
      afterTransform: [Function: bound afterTransform],
      needTransform: true,
      transforming: true,
      writecb: [Function (anonymous)],
      writechunk: File {
        stat: Stats {
          dev: 54,
          mode: 33204,
          nlink: 1,
          uid: 1000,
          gid: 1000,
          rdev: 0,
          blksize: 7680,
          ino: 3406080,
          size: 6547,
          blocks: 10,
          atimeMs: 1626608640926.6077,
          mtimeMs: 1626513354391.4358,
          ctimeMs: 1626513354391.4358,
          birthtimeMs: 0,
          atime: 2021-07-18T11:44:00.927Z,
          mtime: 2021-07-17T09:15:54.391Z,
          ctime: 2021-07-17T09:15:54.391Z,
          birthtime: 1970-01-01T00:00:00.000Z
        },
        _contents: Buffer(6357) [Uint8Array] [
          99, 111, 110, 115, 116,  32,  73,  78,  73,  84,  73,  65,
          76,  95,  68,  65,  84,  65,  32,  61,  32, 123,  10,  32,
          32, 103, 111,  97, 108,  58,  32,  49,  48,  48,  48,  48,
          48,  44,  10,  32,  32,  98,  97,  99, 107, 101, 100,  58,
          32,  56,  57,  57,  49,  52,  44,  10,  32,  32,  98,  97,
          99, 107, 101, 114, 115,  58,  32,  53,  48,  48,  55,  44,
          10,  32,  32, 100,  97, 121, 115,  76, 101, 102, 116,  58,
          32,  53,  54,  44,  10,  32,  32, 102, 105, 114, 115, 116,
          77, 111,  98, 105,
          ... 6257 more items
        ],
        history: [
          './src/main.js'
        ],
        _cwd: '.',
        _base: './src',
        _isVinyl: true,
        _symlink: null
      },
      writeencoding: 'utf8'
    },
    _transform: [Function (anonymous)],
    [Symbol(kCapture)]: false
  },
  domainThrown: false

@arminbw
Copy link

arminbw commented Jul 17, 2022

I can confirm this problem. Any use of .? will result in an Unexpected token . syntax error.

strip-debug-cli doesn’t have the problem, though.

Maybe an update of package.json is necessary (strip-debug v5.0 -> v6.0).

@sindresorhus
Copy link
Owner

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