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

webpacker uses tsloader 4 which requires webpack 4 #1307

Closed
sunnyrjuneja opened this issue Mar 1, 2018 · 0 comments
Closed

webpacker uses tsloader 4 which requires webpack 4 #1307

sunnyrjuneja opened this issue Mar 1, 2018 · 0 comments

Comments

@sunnyrjuneja
Copy link
Contributor

sunnyrjuneja commented Mar 1, 2018

Hello there!

As of 4 days ago, ts-loader 4 is released. According to the ts loader read me, they no longer support webpack 2 / 3 in version 4. https://github.com/TypeStrong/ts-loader#compatibility

If you do:

rails new webpacker-ts-issue --webpack=typescript

It produces a package.json of:

{                                                                                                                                        
  "name": "webpacker-ts-issue",                                                                                                          
  "private": true,                                                                                                                       
  "dependencies": {                                                                                                                      
    "@rails/webpacker": "^3.2.2",                                                                                                        
    "ts-loader": "^4.0.0",                                                                                                               
    "typescript": "^2.7.2"                                                                                                               
  },                                                                                                                                     
  "devDependencies": {                                                                                                                   
    "webpack-dev-server": "^3.1.0"                                                                                                       
  }                                                                                                                                      
}                                                                                                                                        

If you go to any page that uses the pack, you'll see this error in your console:

bootstrap 1c9266352ca2b91cf17c:62 Uncaught Error: Module build failed: TypeError: Cannot read property 'afterCompile' of undefined
    at successfulTypeScriptInstance (/home/wasd/Programs/webpacker-ts-issue/node_modules/ts-loader/dist/instances.js:147:28)
    at Object.getTypeScriptInstance (/home/wasd/Programs/webpacker-ts-issue/node_modules/ts-loader/dist/instances.js:48:12)
    at Object.loader (/home/wasd/Programs/webpacker-ts-issue/node_modules/ts-loader/dist/index.js:16:41)
    at successfulTypeScriptInstance (/home/wasd/Programs/webpacker-ts-issue/node_modules/ts-loader/dist/instances.js:147:28)
    at Object.getTypeScriptInstance (/home/wasd/Programs/webpacker-ts-issue/node_modules/ts-loader/dist/instances.js:48:12)
    at Object.loader (/home/wasd/Programs/webpacker-ts-issue/node_modules/ts-loader/dist/index.js:16:41)
    at Object.<anonymous> (http://www.lvh.me:3000/packs/hello_typescript-7e7af262ac0ad77286c1.js:76:7)
    at __webpack_require__ (http://www.lvh.me:3000/packs/hello_typescript-7e7af262ac0ad77286c1.js:20:30)
    at http://www.lvh.me:3000/packs/hello_typescript-7e7af262ac0ad77286c1.js:63:18
    at http://www.lvh.me:3000/packs/hello_typescript-7e7af262ac0ad77286c1.js:66:10

If you change your package.json to read:

    "ts-loader": "^3.5.0",

Everything will operate normally.

Sorry for all the issues I've created over the last two weeks but I'm really excited to use webpacker and typescript :).

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

1 participant