Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

ngcc cannot handle UMD factory without parameters ( renderFactoryParameters ) #34138

Closed
Wintermoose opened this issue Nov 28, 2019 · 3 comments
Closed

Comments

@Wintermoose
Copy link

@Wintermoose Wintermoose commented Nov 28, 2019

馃悶 bug report

Affected Package

The issue is caused by package @angular/compiler-cli

Is this a regression?

Don't know

Description

As part of our internal library, we have simple module that has no dependencies (two of them actually, but here I'll pick the primitive one). When compiled, the UMD bundle looks something like this:


(function (global, factory) {
	typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
	typeof define === 'function' && define.amd ? define('us.test', factory) :
	(global = global || self, (global.us = global.us || {}, global.us.test = factory()));
}(this, (function () { 'use strict';

	/**
	 * @fileoverview added by tsickle
	 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
	 */
	var index = "";

	return index;

}))); 

You'll notice that the factory function has no parameters. When calling ngcc on our library (included in another project), the compiler crashes with the error:

Cannot read property 'getEnd' of undefined
at renderFactoryParameters (C:\Test\node_modules\@angular\compiler-cli\ngcc\src\rendering\umd_rendering_formatter.js:175:64)
    at UmdRenderingFormatter.addImports (C:\Test\node_modules\@angular\compiler-cli\ngcc\src\rendering\umd_rendering_formatter.js:50:13)
    at Renderer.renderFile (C:\Test\node_modules\@angular\compiler-cli\ngcc\src\rendering\renderer.js:91:35)
    at C:\Test\node_modules\@angular\compiler-cli\ngcc\src\rendering\renderer.js:50:84
...

It would seem, that renderFactoryParameters has no test for parameters.length being zero.

馃實 Your Environment

Angular Version:


Angular CLI: 9.0.0-rc.4
Node: 10.15.3
OS: win32 x64

Angular: 9.0.0-rc.4
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.900.0-rc.4
@angular-devkit/build-angular      0.900.0-rc.4
@angular-devkit/build-ng-packagr   0.900.0-rc.4
@angular-devkit/build-optimizer    0.900.0-rc.4
@angular-devkit/build-webpack      0.900.0-rc.4
@angular-devkit/core               9.0.0-rc.4
@angular-devkit/schematics         9.0.0-rc.4
@angular/cdk                       8.1.2
@angular/http                      
@ngtools/webpack                   9.0.0-rc.4
@schematics/angular                9.0.0-rc.4
@schematics/update                 0.900.0-rc.4
rxjs                               6.5.3
typescript                         3.6.4
webpack                            4.41.2
@petebacondarwin

This comment has been minimized.

Copy link
Member

@petebacondarwin petebacondarwin commented Dec 11, 2019

I have a fix for this...

petebacondarwin added a commit to petebacondarwin/angular that referenced this issue Dec 11, 2019
Previously the UMD rendering formatter assumed that
there would already be import (and an export) arguments
to the UMD factory function.

This commit adds support for this corner case.

Fixes angular#34138
@petebacondarwin

This comment has been minimized.

Copy link
Member

@petebacondarwin petebacondarwin commented Dec 11, 2019

Here we go: #34353

petebacondarwin added a commit to petebacondarwin/angular that referenced this issue Dec 12, 2019
Previously the UMD rendering formatter assumed that
there would already be import (and an export) arguments
to the UMD factory function.

This commit adds support for this corner case.

Fixes angular#34138
kara added a commit that referenced this issue Dec 12, 2019
Previously the UMD rendering formatter assumed that
there would already be import (and an export) arguments
to the UMD factory function.

This commit adds support for this corner case.

Fixes #34138

PR Close #34353
@kara kara closed this in 05c1398 Dec 12, 2019
@angular-automatic-lock-bot

This comment has been minimized.

Copy link

@angular-automatic-lock-bot angular-automatic-lock-bot bot commented Jan 12, 2020

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can鈥檛 perform that action at this time.