rails / webpacker

Use Webpack to manage app-like JavaScript modules in Rails
MIT License
5.31k stars 1.47k forks source link

currently no loaders are configured to process this file #3293

Closed timscott closed 1 year ago

timscott commented 1 year ago

Ruby version: 3.1.2 Rails version: 6.1.6.1 Webpacker version: 5.4.3

Expected behavior: Compile app/javascript/internal/components/Events/index.tsx

Actual behavior:

Error: Module parse failed: Unexpected token (6:4) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.

I ran:

$ bundle exec rails webpacker:install:typescript
$ yarn add @types/react @types/react-dom

Which added to webpacker.yml extensions:

    - .tsx
    - .ts

And added to presets of babel.config.js

['@babel/preset-typescript', { 'allExtensions': true, 'isTSX': true }]

As well as various dependencies to package.json

timscott commented 1 year ago

I actually ran the install task before upgrading to 5.4.3 from 4.0.7.

I reversed everything, upgraded webpacker to to 5.4.3, ran the install task, and it's working now.