# \[Solved\] Bundler: Failed to do transforms

**URL:** <https://discourse.aurelia.io/t/solved-bundler-failed-to-do-transforms/3749>\
**Category:** Help Requests\
**Created:** [September 2, 2020, 9:56pm UTC](https://discourse.aurelia.io/t/solved-bundler-failed-to-do-transforms/3749 "2020-09-02T21:56:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![LetsZiggy](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/letsziggy/32/2312_2.png) [@LetsZiggy](https://discourse.aurelia.io/u/LetsZiggy)\
**Post date:** [September 2, 2020, 9:56pm UTC](https://discourse.aurelia.io/t/solved-bundler-failed-to-do-transforms/3749/1 "2020-09-02T21:56:20Z")

</div>

Hi,

[Solution](https://discourse.aurelia.io/t/bundler-failed-to-do-transforms/3749/2)

I’m trying to move my side project to TypeScript. I’m new to TS. I get this error when added a file with method/function that returns a function (ie Aurelia Store `nextStateHistory`). Just adding the file, not even imported in the component, causes the error.

Any idea?

Error when `npm start`:

```bash
Local aurelia-cli v2.0.0
Starting 'clean'...
Finished 'clean'
Starting 'readProjectConfiguration'...
INFO [Bundle] Manually adding package: 2.3.3 aurelia-bootstrapper
INFO [Bundle] Manually adding package: 1.2.1 aurelia-loader-default
INFO [Bundle] Manually adding package: 1.8.1 aurelia-pal-browser
INFO [Bundle] Manually adding package: 1.0.0 aurelia-testing
INFO [Bundle] Manually adding package: 2.0.16 text
Finished 'readProjectConfiguration'
Starting 'processMarkup'...
Starting 'processJson'...
Starting 'processCSS'...
Starting 'copyFiles'...
Starting 'configureEnvironment'...
Finished 'copyFiles'
Finished 'processJson'

risk - There are upcoming breaking changes: removeDeprecatedGapUtilities
risk - We highly recommend opting-in to these changes now to simplify upgrading Tailwind in the future.
risk - https://tailwindcss.com/docs/upcoming-changes
Finished 'processMarkup'
Finished 'configureEnvironment'
Starting 'buildTypeScript'...
Finished 'buildTypeScript'
Finished 'processCSS'
Starting 'writeBundles'...
INFO [Bundler] Tracing files ...
ERROR [Bundler] Failed to do transforms
INFO [Bundler] Error: Line 8: Unexpected token ...
{
  uid: 14,
  name: 'writeBundles',
  branch: false,
  error: Error: Line 8: Unexpected token ...
      at ErrorHandler.constructError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:5012:22)
      at ErrorHandler.createError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:5028:27)
      at Parser.unexpectedTokenError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:1985:39)
      at Parser.throwUnexpectedToken (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:1995:21)
      at Parser.parseObjectPropertyKey (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2499:33)
      at Parser.parseObjectProperty (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2534:25)
      at Parser.parseObjectInitializer (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2602:35)
      at Parser.inheritCoverGrammar (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2285:37)
      at Parser.parsePrimaryExpression (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2354:38)
      at Parser.inheritCoverGrammar (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2285:37) {
    index: 283,
    lineNumber: 8,
    description: 'Unexpected token ...'
  },
  duration: [0, 403833207],
  time: 1599083299772
}
{
  uid: 4,
  name: '<series>',
  branch: true,
  error: Error: Line 8: Unexpected token ...
      at ErrorHandler.constructError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:5012:22)
      at ErrorHandler.createError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:5028:27)
      at Parser.unexpectedTokenError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:1985:39)
      at Parser.throwUnexpectedToken (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:1995:21)
      at Parser.parseObjectPropertyKey (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2499:33)
      at Parser.parseObjectProperty (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2534:25)
      at Parser.parseObjectInitializer (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2602:35)
      at Parser.inheritCoverGrammar (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2285:37)
      at Parser.parsePrimaryExpression (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2354:38)
      at Parser.inheritCoverGrammar (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2285:37) {
    index: 283,
    lineNumber: 8,
    description: 'Unexpected token ...'
  },
  duration: [32, 956520038],
  time: 1599083299777
}
{
  uid: 2,
  name: '<series>',
  branch: true,
  error: Error: Line 8: Unexpected token ...
      at ErrorHandler.constructError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:5012:22)
      at ErrorHandler.createError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:5028:27)
      at Parser.unexpectedTokenError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:1985:39)
      at Parser.throwUnexpectedToken (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:1995:21)
      at Parser.parseObjectPropertyKey (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2499:33)
      at Parser.parseObjectProperty (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2534:25)
      at Parser.parseObjectInitializer (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2602:35)
      at Parser.inheritCoverGrammar (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2285:37)
      at Parser.parsePrimaryExpression (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2354:38)
      at Parser.inheritCoverGrammar (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2285:37) {
    index: 283,
    lineNumber: 8,
    description: 'Unexpected token ...'
  },
  duration: [32, 970438268],
  time: 1599083299778
}
{
  uid: 1,
  name: '<series>',
  branch: true,
  error: Error: Line 8: Unexpected token ...
      at ErrorHandler.constructError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:5012:22)
      at ErrorHandler.createError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:5028:27)
      at Parser.unexpectedTokenError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:1985:39)
      at Parser.throwUnexpectedToken (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:1995:21)
      at Parser.parseObjectPropertyKey (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2499:33)
      at Parser.parseObjectProperty (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2534:25)
      at Parser.parseObjectInitializer (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2602:35)
      at Parser.inheritCoverGrammar (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2285:37)
      at Parser.parsePrimaryExpression (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2354:38)
      at Parser.inheritCoverGrammar (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2285:37) {
    index: 283,
    lineNumber: 8,
    description: 'Unexpected token ...'
  },
  duration: [32, 970994982],
  time: 1599083299778
}
{
  uid: 0,
  name: '<series>',
  branch: true,
  error: Error: Line 8: Unexpected token ...
      at ErrorHandler.constructError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:5012:22)
      at ErrorHandler.createError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:5028:27)
      at Parser.unexpectedTokenError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:1985:39)
      at Parser.throwUnexpectedToken (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:1995:21)
      at Parser.parseObjectPropertyKey (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2499:33)
      at Parser.parseObjectProperty (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2534:25)
      at Parser.parseObjectInitializer (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2602:35)
      at Parser.inheritCoverGrammar (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2285:37)
      at Parser.parsePrimaryExpression (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2354:38)
      at Parser.inheritCoverGrammar (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2285:37) {
    index: 283,
    lineNumber: 8,
    description: 'Unexpected token ...'
  },
  duration: [32, 972759703],
  time: 1599083299778
}
Error: Line 8: Unexpected token ...
    at ErrorHandler.constructError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:5012:22)
    at ErrorHandler.createError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:5028:27)
    at Parser.unexpectedTokenError (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:1985:39)
    at Parser.throwUnexpectedToken (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:1995:21)
    at Parser.parseObjectPropertyKey (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2499:33)
    at Parser.parseObjectProperty (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2534:25)
    at Parser.parseObjectInitializer (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2602:35)
    at Parser.inheritCoverGrammar (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2285:37)
    at Parser.parsePrimaryExpression (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2354:38)
    at Parser.inheritCoverGrammar (/home/shafiq/code/abc/au-ts/node_modules/esprima/dist/esprima.js:2285:37) {
  index: 283,
  lineNumber: 8,
  description: 'Unexpected token ...'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! wordpress-theme-builder-aureliajs@0.1.0 start: `au run --watch`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the wordpress-theme-builder-aureliajs@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/shafiq/.npm/_logs/2020-09-02T21_48_19_867Z-debug.log

```

example file:

```auto
import { nextStateHistory, StateHistory } from "aurelia-store"

// import { setDeepProp } from "resources/helpers/dictionary-helper"
import { /* Block, Screen, */ State } from "../../state"

/**
 * @namespace demoActions
 * @description Store actions for Demo Component
 *
 * @requires aurelia-store/nextStateHistory
 * @requires resources/helpers/dictionary-helper/setDeepProp
 * @requires ../../state/Block
 * @requires ../../state/Screen
 * @requires ../../state/State
 */
export const demoActions = {
  /**
   * @method
   * @memberOf demoActions
   * @description Sets whether app is in dark mode
   *
   * @return {Function} Updated state
   */
  toggleDarkMode: (state: StateHistory<State>, bool: boolean = false) => {
    return nextStateHistory(state, {
      ...state.present,
      isDarkMode: bool,
    })
  },

  /* ... */
}

```

aurelia skeleton:  
`npx makes aurelia/v1 PROJECT_NAME --here -s cli-bundler,alameda,typescript,htmlmin,sass,postcss,karma,cypress`

tsconfig.json:

```json
{
  "compileOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  },
  "include": [
    "src",
    "test"
  ],
  "compilerOptions": {
    "allowJs": true,
    "declaration": false,
    "lib": ["ESNext", "DOM"],
    "removeComments": true,
    "sourceMap": true,
    "target": "ES2018",
    "baseUrl": "src",
    "moduleResolution": "Node",
    "typeRoots": ["node_modules/@types"],
    "types": ["jasmine", "lodash"],
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "resolveJsonModule": true
  }
}

```

Edits:

- Add more details about the problem
- Add solution

---

<div class="post-metadata">

**Author:** ![huochunpeng](https://avatars.discourse-cdn.com/v4/letter/h/49beb7/32.png) [@huochunpeng](https://discourse.aurelia.io/u/huochunpeng)\
**Post date:** [September 2, 2020, 10:31pm UTC](https://discourse.aurelia.io/t/solved-bundler-failed-to-do-transforms/3749/2 "2020-09-02T22:31:39Z")

</div>

Because your target is ES2018, the `...state.present,` is preserved and the old parser (esprima which cli-bundler uses) did not understand.

---

<div class="post-metadata">

**Author:** ![LetsZiggy](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/letsziggy/32/2312_2.png) [@LetsZiggy](https://discourse.aurelia.io/u/LetsZiggy)\
**Post date:** [September 3, 2020, 8:18am UTC](https://discourse.aurelia.io/t/solved-bundler-failed-to-do-transforms/3749/3 "2020-09-03T08:18:36Z")

</div>

Thanks. Problem solved. 😊
