ts-loader

How can self made ambient modules be created and imported in typescript?

眉间皱痕 提交于 2020-01-04 05:44:07
问题 I have an external javascript library that creates a global object in window. To use this object in typescript code, I have created an ambient module file (d.ts) that is imported inside other typescript file. The problem I am facing is that the compiler says that the module file is not a module src/App.ts(6,22): error TS2306: File '/Users/user/ts-problems/src/abc.d.ts' is not a module. I'm also using webpack with ts-loader but compiling it alone with (tsc) gives me the same result. This is

Exclude ts/js file from bundle using webpack

你说的曾经没有我的故事 提交于 2019-12-23 13:24:33
问题 I am new to webpack. Currently I am working on angular2 application with webpack. As part of requirement we want to have a settings file which should not be bundled so that one can change URL in settings.js file after bundle also. Below is the code for two files. settings.ts const foo = { url:'localhost' }; export { foo }; script.ts import { foo } from 'settings'; Both ts files will be compiled to js file before bundle. And now i want to exclude settings.ts file from bundle and want to copy

Webpack cant resolve TypeScript modules

落爺英雄遲暮 提交于 2019-12-18 11:47:35
问题 I build a relay small webpack and typescript demo to play with. If i run webpack with the webpack.config.js i get this error: ERROR in ./js/app.ts Module not found: Error: Can't resolve './MyModule' in '/Users/timo/Documents/Dev/Web/02_Tests/webpack_test/js' @ ./js/app.ts 3:17-38 I have no clue what the problem could be. The module export should be correct. Folder Structure webpack.config.js const path = require('path'); module.exports = { entry: './js/app.ts', output: { path: path.resolve(_

TypeScript 2.1.4 breaking changes in webpack ts-loader

╄→尐↘猪︶ㄣ 提交于 2019-12-12 18:03:07
问题 Upgrading from Typescript 2.0.10 to 2.1.4 appears to break something in webpack, webpack-stream, ts-loader, or gulp as it’s no longer respecting my entry point or gulp source glob. It appears to be including all .ts files in my project (including the ones in the /server source folder) rather than just the ts files in /client and app.ts as per the gulp.src and web pack entry point. Is there a different/newer/better way I should be doing this? in gulp file: const serverPath = 'server'; const

Exported TypeScript Class not included in WebPack bundle if not used directly

泄露秘密 提交于 2019-12-12 02:54:26
问题 I'm converting a javascript project with Angular 1.x to WebPack and TypeScript (using ts-loader). I got it mostly working, but I'm running into trouble when ts-loader seems to be optimizing my scripts out of the bundle when the exports are not directly used. Here's a sample project demonstrating the issue (npm install, webpack, then load index.html and watch the console). https://github.com/bbottema/webpack-typescript The logging from ClassA is showing up, but angular is reporting ClassB

Attempted import error: 'SomeObject' is not exported from file

这一生的挚爱 提交于 2019-12-11 02:54:34
问题 I've upgraded to Webpack 4 from 3. Since then, I get a lot of warnings regarding imports that were not exported from certain files. ./packages/utils/logging/index.ts Attempted import error: ‘Options' is not exported from './loggers/log'. @ ./packages/utils/index.ts @ ./src/App.tsx @ multi whatwg-fetch @babel/polyfill ./src/App.tsx I use ts-loader along with ForkTsCheckerWebpackPlugin . I've examined the exports from the warnings and they look good. The code does work, however I still get

Angular 2 - Webpack 2 - template-loader not working with templateUrl

a 夏天 提交于 2019-12-08 04:17:54
问题 I've created a minimal webpack example for my Application and I try to use templateUrl with "./file.name.html" to get compiled. But the only thing my Application shows is the name of the templateUrl "./file.name.html" on my Index page. The applications seems to work, because there are no errors in the console and the <app>... Loading </app> is not shown any more. Before I tried to use webpack I've used systemJs and My App was working very well. So I don't think its a app problem. my starting

WebPack ts-loader compiling all files when I only want it to run in one folder/file

戏子无情 提交于 2019-12-06 02:23:53
问题 I found a problem in my app structure and build process using WebPack, TypeScript, and TS-Loader that I thought was caused by TypeScript 2.1.4, but apparently was there the whole time. You can see all the details from my other post: TypeScript 2.1.4 breaking changes in webpack ts-loader In short, I have Gulp and WebPack set to an entry point of /client/app.ts which for now has almost nothing in it (certainly nothing referencing /server/) but the TypeScript compilation stage of the WebPack

WebPack ts-loader compiling all files when I only want it to run in one folder/file

房东的猫 提交于 2019-12-04 05:50:41
I found a problem in my app structure and build process using WebPack, TypeScript, and TS-Loader that I thought was caused by TypeScript 2.1.4, but apparently was there the whole time. You can see all the details from my other post: TypeScript 2.1.4 breaking changes in webpack ts-loader In short, I have Gulp and WebPack set to an entry point of /client/app.ts which for now has almost nothing in it (certainly nothing referencing /server/) but the TypeScript compilation stage of the WebPack build process is still trying to run on /server (and in my other post, showing a compilation error from