Cli build should support loading modules with *.tsx extension.
See original GitHub issueBug Report or Feature Request (mark with an x
)
- [x] bug report
- [ ] feature request
Versions.
Angular CLI: 1.5.0-rc.0
Node: 6.11.0
OS: win32 x64
Angular: 5.0.0-rc.2
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic
... platform-server, router
@angular/cli: 1.5.0-rc.0
@angular-devkit/build-optimizer: 0.0.27
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.33
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0-rc.0
@schematics/angular: 0.0.45
typescript: 2.5.3
webpack: 3.7.1
Repro steps.
- call
ng new testproject
- cd testproject
- rename src\app\app.component.ts to src\app\app.component.tsx
- add to tsconfig.json compilerOptions “jsx”: “react”, “jsxFactory”: “h”
- call
ng build
The log given by the failure.
ERROR in ./src/app/app.module.ts
Module not found: Error: Can't resolve './app.component' in 'c:\temp\testproject\src\app'
resolve './app.component' in 'c:\temp\testproject\src\app'
using description file: c:\temp\testproject\package.json (relative path: ./src/app)
Field 'browser' doesn't contain a valid alias configuration
after using description file: c:\temp\testproject\package.json (relative path: ./src/app)
using description file: c:\temp\testproject\package.json (relative path: ./src/app/app.component)
no extension
Field 'browser' doesn't contain a valid alias configuration
c:\temp\testproject\src\app\app.component doesn't exist
.ts
Field 'browser' doesn't contain a valid alias configuration
c:\temp\testproject\src\app\app.component.ts doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
c:\temp\testproject\src\app\app.component.js doesn't exist
as directory
c:\temp\testproject\src\app\app.component doesn't exist
[c:\temp\testproject\src\app\app.component]
[c:\temp\testproject\src\app\app.component.ts]
[c:\temp\testproject\src\app\app.component.js]
[c:\temp\testproject\src\app\app.component]
@ ./src/app/app.module.ts 9:0-47
@ ./src/main.ts
@ multi ./src/main.ts
Desired functionality.
The tsx is providing just extended syntax sugar, which can be used for different porpoises. In my case I’m using mono-repo approach and I’m delivering part of components as web-components where I’m using jsx/tsx.
For compiler there should not be difference in extension of module.
Ropen of https://github.com/angular/angular/issues/19691#issuecomment-336222081
Issue Analytics
- State:
- Created 6 years ago
- Reactions:11
- Comments:37 (16 by maintainers)
Top Results From Across the Web
Documentation - Module Resolution - TypeScript
Module resolution is the process the compiler uses to figure out what an import refers to. Consider an import statement like import {...
Read more >Webpack Error when trying to run reactJS app (w. typescript)
To solve library issue, you can use alternative approach of renaming Webpack config file to webpack.config.cjs . The .cjs extension tells ...
Read more >tsx - npm
tsx is a CLI command (alternative to node ) for seamlessly running TypeScript & ESM, in both commonjs & module package types.
Read more >React with Typescript and Webpack - Pluralsight
module - We can enable Webpack to load a particular file when requested by the app, using loaders. In our example project, we...
Read more >Setting TypeScript For Modern React Projects Using Webpack
TypeScript will help you find all instances of the refactored bit, ... .ts , and .tsx for bundling. module We can enable webpack...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just sent a PR to make it work with the latest CLI (6.x). I’m using this in one of my projects successfully. Fingers crossed! 🤞
UGLY workaround: https://gist.github.com/majo44/4862b8e7db6254975669e0a3f9d67a2a#file-angular-cli-1-5-0-tsx-loading-ugly-fix (we have this in postinstall)
We are working on PR.