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.

ts-loader seems not to load modules from node_modules, but awesome-typescript-loader does

See original GitHub issue

Hello! I eventullay discovered that ts loader won’t load modules from node_modules for some reason. For example, i have some entry file, like this, and tere is @somespace/foo/index.ts file:

// index.ts
import {Foo} from "@somespace/foo"

I enableTypeScriptLoader and all my in-project ts is ok. But when trying to import some ts stuff from node_modules it says:

Error loading ./node_modules/@somespace/foo/index.ts

FIX  To process TypeScript files:
        1. Add Encore.enableTypeScriptLoader() to your webpack.config.js file.

When i replaced built-in ts-loader with awesome-typescript-loader, the problem has gone, and everthing has compiled well.

So, why webpack-encore uses ts-loader, and not awesome-typescript-loader?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:9

github_iconTop GitHub Comments

3reactions
Lyrkancommented, May 20, 2019

Maybe we could add a second parameter to Encore.enableTypeScriptLoader() to change the exclude rule or include some node_modules the same way Encore.configureBabel() works?

Encore.enableTypeScriptLoader(options => {
  // Loader-specific options
  // (...)
}, {
  // Directly change the exclude rule
  exclude: /foo/,

  // Or include *some* modules
  includeNodeModules: ['foo', 'bar'],
});

Note that in the meantime you can use Encore.configureLoaderRule() as a cleaner workaround:

Encore.configureLoaderRule('typescript', rule => {
  delete rule.exclude;
});
3reactions
lalandcommented, Oct 18, 2017

May be some configuration option can be introduced? `cause we have lots of internal packages in our organization, written in pure typescript, that are consumed and compiled by some end-projects, and there is no need to pre-build those packages.

Read more comments on GitHub >

github_iconTop Results From Across the Web

2 - Stack Overflow
awesome-typescript-loader is no longer maintained and is not compatible with Webpack 5 (or with recent TypeScript versions).
Read more >
s-panferov/awesome-typescript-loader - Gitter
Hi. I'm trying to upgrade an application from webpack 1 to 2 and cannot because it relies heavily on webpack aliasing (but not...
Read more >
Compiling and bundling TypeScript libraries with Webpack
There are a couple of TS loaders and we eventually settled on awesome-typescript-loader for a couple of reasons: it's faster, by forking the...
Read more >
TypeScript Config - Storybook
This is a central reference for using Storybook with TypeScript. Setting up TypeScript with awesome-typescript-loader. Dependencies you may need.
Read more >
Handbook - React & Webpack - TypeScript
How to use TypeScript with React and Webpack. ... Please note that ts-loader is not the only loader for typescript.
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