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

Webpack doesn't start with this plugin #1

Open
eugenet8k opened this issue Dec 10, 2018 · 3 comments
Open

Webpack doesn't start with this plugin #1

eugenet8k opened this issue Dec 10, 2018 · 3 comments

Comments

@eugenet8k
Copy link

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
Copy link
Author

If I remove parser from

var formatOpts = {
// By using a custom parser we can use the already parsed AST.
// This is better than using __debug.formatAST, because this way prettier still handles comments;
// comments would be lost when using the formatAST API.
parser: function () {
return ast
}
}

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
Copy link

ouweiya commented Feb 1, 2019

+1
The same problem

@mmiller42
Copy link
Contributor

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

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