question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sometimes all files that should be passed are not passed to loaders

See original GitHub issue

Bug report

What is the current behavior? I have a ts / js / tsx / jsx loader like this:

module: {
    rules: [
        {
            test: /\.[jt]sx?$/,
            include: [/src/],
            exclude: [/node_modules/, /server/],
            use: [
                {
                    loader: 'babel-loader',
                    // ...
                    },
                },
                {
                    loader: 'ts-loader',
                    // ...
                },
            ],
        },

But it doesn’t pass all .ts files to the ts-loader first, and because of that I get the unexpected token error:

ERROR in ./wireWebapp/src/script/ui/viewportObserver.ts 26:15
Module parse failed: Unexpected token (26:15)
File was processed with these loaders:
 * ./node_modules/@pmmmwh/react-refresh-webpack-plugin/loader/index.js
You may need an additional loader to handle the result of these loaders.
| 
| const observedElements = new Map();
> const tolerance: number = 0.8;
| 
| const onIntersect: IntersectionObserverCallback = entries => {

If the current behavior is a bug, please provide the steps to reproduce. Minimal reproducible example: GitHub

What is the expected behavior?

It should pass all tsx/jsx/js/ts files to the appropriate loader, and not “most” of them. Maybe my config is wrong, but the include specifies that all file-paths that include src in them and have a ts/js/tsx/jsx extension should be processed by the babel-loader & ts-loader combo, but instead it is not passed at all.

Other relevant information: webpack version:

webpack: 5.64.3
webpack-cli: 4.9.1
webpack-dev-server 4.5.0

Node.js version: v14.18.1 / v15.14.0 Operating System: 5.10.70-1-MANJARO Additional tools: -

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Twiggehcommented, Nov 26, 2021

Thank you so much! I missed it completely 😅

1reaction
sokracommented, Nov 26, 2021

yep Observer matches /server/ so it’s excluded.

Read more comments on GitHub >

github_iconTop Results From Across the Web

webpack loaders and include - Stack Overflow
The test is a condition applied to all files. So if you include a folder, each file must pass the test condition. I...
Read more >
re-run of sql*loader - Oracle Communities
Dear All, While loading data from huge .DAT files through sql*loader the the load may remain incomplete due to 1 or 2 bad/discarded...
Read more >
less-loader | webpack - JS.ORG
webpack provides an advanced mechanism to resolve files. less-loader applies a Less plugin that passes all queries to the webpack resolver if less...
Read more >
Data Loading - Remix
While loading data it's common for a record to be "not found". As soon as you know you can't render the component as...
Read more >
Content Types - ESBuild
This loader is enabled by default for .js , .cjs , and .mjs files. ... These syntax features are currently always passed through...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found