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

Can’t compile TypeScript; requires Webpack 4 #1678

Closed
martinbean opened this issue Jun 12, 2018 · 4 comments
Closed

Can’t compile TypeScript; requires Webpack 4 #1678

martinbean opened this issue Jun 12, 2018 · 4 comments

Comments

@martinbean
Copy link

martinbean commented Jun 12, 2018

  • Laravel Mix Version: 2.1.11
  • Node Version: 8.9.4
  • NPM Version: 5.6.0
  • OS: Windows

Description:

Brand new Laravel project. Trying to compile a JavaScript file using TypeScript. Throws the following error:

ERROR in ./resources/assets/js/src/order.ts
Module build failed: Error: You may be using an old version of webpack; please check you're using at least version 4
    at successfulTypeScriptInstance (C:\Users\MartinBean\Developer\TypeScriptTest\node_modules\ts-loader\dist\instances.js:168:15)
    at Object.getTypeScriptInstance (C:\Users\MartinBean\Developer\TypeScriptTest\node_modules\ts-loader\dist\instances.js:51:12)
    at Object.loader (C:\Users\MartinBean\Developer\TypeScriptTest\node_modules\ts-loader\dist\index.js:16:41)
 @ ./resources/assets/js/app.js 1:0-32
 @ multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss

Steps To Reproduce:

  1. Create a brand new Laravel project (composer create-project laravel/laravel).
  2. Add a tsconfig.json file with the following contents:
{
    "include": [
        "resources/assets/js/**/*"
    ]
}
  1. Try to compile JavaScript file as TypeScript: mix.ts('resources/assets/js/app.js', 'public/js')
  2. Receive error about needing webpack 4.

I don’t think I’ve ever got TypeScript to compile successfully. It would be good if the Mix documentation could be updated with the minimum options needed to get TypeScript to compile successfully.

@ankurk91
Copy link
Contributor

TypeStrong/ts-loader#786

@ankurk91
Copy link
Contributor

ankurk91 commented Jun 13, 2018

You should be using ts-loader v3.5, update your package.json

Right now laravel-mix does not support webpack 4

@martinbean
Copy link
Author

@ankurk91 Thank you.

@arcanedev-maroc
Copy link
Contributor

Hi @JeffreyWay, is there any way to specify the version of the typescript's dependencies (at this line) ?

Otherwise, upgrading webpack to v4 may solve the issue

Cheers

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