I'm trying to use a loader to augment my existing ts files with extra data, so that we can leverage the typechecking features. In the webpack config, I have something like this:
{ test: /\.ts$/, loader: 'ts!extra-data' }
The Typescript files are otherwise normal, but the extra-data loader puts in additional lines (a representation of a template for compile time validation).
The ts-loader doesn't always apply the extra-data loader, however.
If I import a file like this:
import "src/needs-extra";
Then ts-loader will apply the extra-data loader and import the file with extra data.
But if I import it like this:
import data from "src/needs-extra";
Then ts-loader will skip the extra-data loader and interpret it directly as TypeScript. I would expect that all files imported use the loaders specified in the webpack config.
I'm trying to use a loader to augment my existing ts files with extra data, so that we can leverage the typechecking features. In the webpack config, I have something like this:
The Typescript files are otherwise normal, but the
extra-dataloader puts in additional lines (a representation of a template for compile time validation).The ts-loader doesn't always apply the extra-data loader, however.
If I import a file like this:
Then ts-loader will apply the extra-data loader and import the file with extra data.
But if I import it like this:
Then ts-loader will skip the extra-data loader and interpret it directly as TypeScript. I would expect that all files imported use the loaders specified in the webpack config.