goto-bus-stop / babel-plugin-generator-prettier

Babel plugin to use prettier for transformed code output
Other
9 stars 1 forks source link

Webpack doesn't start with this plugin #1

Open eugenet8k opened 5 years ago

eugenet8k commented 5 years ago
Module build failed (from ./node_modules/babel-loader/lib/index.js):
TypeError: Cannot read property 'slice' of undefined
    at printString (/my-project/node_modules/prettier/index.js:11518:24)
    at nodeStr (/my-project/node_modules/prettier/index.js:27324:10)
    at printPathNoParens (/my-project/node_modules/prettier/index.js:24339:16)
    at Object.genericPrint [as print] (/my-project/node_modules/prettier/index.js:23294:28)
    at callPluginPrintFunction (/my-project/node_modules/prettier/index.js:13501:18)
    at /my-project/node_modules/prettier/index.js:13452:16
    at Object.printComments (/my-project/node_modules/prettier/index.js:13186:17)
    at printGenerically (/my-project/node_modules/prettier/index.js:13451:22)
    at FastPath.call (/my-project/node_modules/prettier/index.js:13297:16)
    at printPathNoParens (/my-project/node_modules/prettier/index.js:23971:28)
    at Object.genericPrint [as print] (/my-project/node_modules/prettier/index.js:23294:28)
    at callPluginPrintFunction (/my-project/node_modules/prettier/index.js:13501:18)
    at /my-project/node_modules/prettier/index.js:13452:16
    at Object.printComments (/my-project/node_modules/prettier/index.js:13186:17)
    at printGenerically (/my-project/node_modules/prettier/index.js:13451:22)
    at /my-project/node_modules/prettier/index.js:25804:23
    at FastPath.map (/my-project/node_modules/prettier/index.js:13355:21)
    at printStatementSequence (/my-project/node_modules/prettier/index.js:25788:11)
    at /my-project/node_modules/prettier/index.js:23577:16
    at FastPath.call (/my-project/node_modules/prettier/index.js:13297:16)
    at printPathNoParens (/my-project/node_modules/prettier/index.js:23576:26)
    at Object.genericPrint [as print] (/my-project/node_modules/prettier/index.js:23294:28)
    at callPluginPrintFunction (/my-project/node_modules/prettier/index.js:13501:18)
    at /my-project/node_modules/prettier/index.js:13452:16
    at Object.printComments (/my-project/node_modules/prettier/index.js:13186:17)
    at printGenerically (/my-project/node_modules/prettier/index.js:13451:22)
    at FastPath.call (/my-project/node_modules/prettier/index.js:13297:16)
    at printPathNoParens (/my-project/node_modules/prettier/index.js:23561:26)
    at Object.genericPrint [as print] (/my-project/node_modules/prettier/index.js:23294:28)
    at callPluginPrintFunction (/my-project/node_modules/prettier/index.js:13501:18)
    at /my-project/node_modules/prettier/index.js:13452:16
    at Object.printComments (/my-project/node_modules/prettier/index.js:13186:17)
    at printGenerically (/my-project/node_modules/prettier/index.js:13451:22)
    at printAstToDoc (/my-project/node_modules/prettier/index.js:13463:16)
    at coreFormat (/my-project/node_modules/prettier/index.js:13777:16)
    at format (/my-project/node_modules/prettier/index.js:13939:16)
    at formatWithCursor (/my-project/node_modules/prettier/index.js:13951:12)
    at /my-project/node_modules/prettier/index.js:41967:15
    at Object.format (/my-project/node_modules/prettier/index.js:41986:12)
    at print (/my-project/node_modules/babel-plugin-generator-prettier/index.js:37:25)
    at generateCode (/my-project/node_modules/@babel/core/lib/transformation/file/generate.js:48:24)
    at runSync (/my-project/node_modules/@babel/core/lib/transformation/index.js:50:51)
    at runAsync (/my-project/node_modules/@babel/core/lib/transformation/index.js:35:14)
    at process.nextTick (/my-project/node_modules/@babel/core/lib/transform.js:34:34)
    at process._tickCallback (internal/process/next_tick.js:61:11)

 @ ./index.spec.js (./node_modules/mocha-loader/src?enableTimeouts=false!./index.spec.js) 4:0-212
 @ multi (webpack)-dev-server/client?http://localhost:8080 mocha-loader?enableTimeouts=false!./index.spec.js

Info:

  "devDependencies": {
    "@babel/core": "7.2.0",
    "@babel/plugin-proposal-class-properties": "7.2.1",
    "@babel/plugin-proposal-object-rest-spread": "7.2.0",
    "@babel/plugin-proposal-optional-chaining": "7.2.0",
    "@babel/polyfill": "7.0.0",
    "@babel/preset-env": "7.2.0",
    "babel-loader": "8.0.4",
    "babel-plugin-generator-prettier": "^1.1.0",
    "webpack": "4.27.1",
    "webpack-cli": "3.1.2",
    "webpack-dev-server": "3.1.10"
  },
eugenet8k commented 5 years ago

If I remove parser from

https://github.com/goto-bus-stop/babel-plugin-generator-prettier/blob/6f40051f2199f65a74fcd17bfca9bac9ca8fd627/index.js#L20-L27

it does not fail with an error, but neither does format anything and webpack gives a warning:

No parser and no filepath given, using 'babylon' the parser now but this will throw an error in the future. Please specify a parser or a filepath so one can be inferred.

ouweiya commented 5 years ago

+1 The same problem

mmiller42 commented 4 years ago

Yeah, I actually get the same error without Webpack as well, just using the latest versions of @babel/core and @babel/cli.