-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
__NG_CLI_RESOURCE__0 is not defined #18718
Comments
I found this link which is saying I should not sure |
Any reason why you are using commonjs as a module for a web application? Typically commonjs is used for Node.Js applications. Also using commonjs doesn’t breaks several things such as tree-shaking, requires extra ngcc entry-point processing and lazy loading among others. Possibly, we can revert the change in introduce it in a major version if there are more people impacted by this, but I’d like to understand the reason why the module was set to commonjs in the first place. Unfortunately TypeScript is unable to emit the created ES default import to a |
I agree with everything you said there is no good reason to use Also, the error is very hard to debug if the |
Should I open bug for typescript or this is known limitation? |
More info: microsoft/TypeScript#18369 (comment) Will land a fix tomorrow. |
I'm seeing the same error just running ng serve since going from 10.0.8 to 10.1.0, can't start my project |
… CommonJS as module When using CommonJs as module format TypeScript will generate unreferenced `require` when using `ts.createImportDeclaration`. ```js const external_component_html_1 = require("!raw-loader!./external.component.html"); const core_1 = require("@angular/core"); let ExampleComponent = class ExampleComponent { }; ExampleComponent = __decorate([ core_1.Component({ selector: 'example-compoent', template: __NG_CLI_RESOURCE__0, }) ], ExampleComponent); ``` More context: microsoft/TypeScript#18369 (comment) Closes #18718
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
… CommonJS as module When using CommonJs as module format TypeScript will generate unreferenced `require` when using `ts.createImportDeclaration`. ```js const external_component_html_1 = require("!raw-loader!./external.component.html"); const core_1 = require("@angular/core"); let ExampleComponent = class ExampleComponent { }; ExampleComponent = __decorate([ core_1.Component({ selector: 'example-compoent', template: __NG_CLI_RESOURCE__0, }) ], ExampleComponent); ``` More context: microsoft/TypeScript#18369 (comment) Closes angular#18718
🐞 Bug report
Command (
ng test
)Is this a regression?
Did this behavior used to work in the previous version?
Yes, 10.0 was working
Description
when running
ng test
and I have ng template with template url I got an error🔬 Minimal Reproduction
commands:
npm install -g @angular/cli
ng new template-url-ng-cli-issue ? Would you like to add Angular routing? No ? Which stylesheet format would you like to use? CSS
"module": "CommonJS"
tsconfig.spec.json🔥 Exception or Error
Example Repo
https://github.com/alyahmedaly/template-url-ng-cli-issue
Findings
I tried to debug the problem and here a repo with my findings
https://github.com/alyahmedaly/ng-bug-resourceload
if you checked output file for es2015 build looks correct
But for commonJS it's not correct.
If you check line 10 and line 17 you will see the variable name is not correct
Note: I did copy
angular-cli/packages/ngtools/webpack/src/transformers/replace_resources.ts
Line 131 in 60a42c2
looks like it's typescript issue or because this happening in transform phase and ts symbols is already created I don't know 🤷♂️
🌍 Your Environment
The text was updated successfully, but these errors were encountered: