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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aliased imports from a barrel file only work in development #7066

Closed
jak opened this issue Jul 20, 2017 · 7 comments
Closed

Aliased imports from a barrel file only work in development #7066

jak opened this issue Jul 20, 2017 · 7 comments
Labels
needs: investigation Requires some digging to determine if action is needed P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful severity3: broken type: bug/fix

Comments

@jak
Copy link

jak commented Jul 20, 2017

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.1.2
node: 6.10.1
os: darwin x64
@angular/common: 4.2.3
@angular/compiler: 4.2.3
@angular/core: 4.2.3
@angular/forms: 4.2.3
@angular/http: 4.2.3
@angular/platform-browser: 4.2.3
@angular/platform-browser-dynamic: 4.2.3
@angular/router: 4.2.3
@angular/cli: 1.1.2
@angular/compiler-cli: 4.2.3

macOS Sierra

Repro steps.

Given an example file example/foo.ts

export function foo(): number { 
  return 1;
}

Given an example/index.ts file such as

export * from 'foo.ts';

When you have an aliased import such as

import { foo as exampleFoo } from './example';

The import works fine in development with ng serve, however whilst ng build --prod --aot succeeds, the resulting code does not run due to an error TypeError: Cannot read property 'apply' of undefined

If you change the import to not use the barrel file, the resulting compiled code is fine. i.e.

import { foo as exampleFoo } from './example/foo';

The log given by the failure.

When viewing the dist code:
TypeError: Cannot read property 'apply' of undefined

No errors during ng build.
No errors when using ng serve.

Desired functionality.

Consistency between development and production builds for imports.

Mention any other details that might be useful.

@clydin
Copy link
Member

clydin commented Jul 20, 2017

Can you try with Angular 4.3? The AOT compiler received some major updates and may resolve your issue.

Also, a production build automatically includes AOT. You don't need to add the "--aot" option.

@filipesilva filipesilva added the needs: investigation Requires some digging to determine if action is needed label Jul 28, 2017
@filipesilva filipesilva added package4: @angular-sdk/webpack P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful severity3: broken type: bug/fix labels Jul 28, 2017
@hansl hansl removed their assignment Feb 6, 2018
@rubenmarcus
Copy link

still doesnt work in Angular 5.2.0

@rubenmarcus
Copy link

main.b771427faeac57797e03.bundle.js:1 Uncaught TypeError: Cannot read property '__extends' of undefined
at main.b771427faeac57797e03.bundle.js:1
at Object.x35b (main.b771427faeac57797e03.bundle.js:1)
at o (inline.c7e7d2e66b46b1ee9e69.bundle.js:1)
at Object.0 (main.b771427faeac57797e03.bundle.js:1)
at o (inline.c7e7d2e66b46b1ee9e69.bundle.js:1)
at window.webpackJsonp (inline.c7e7d2e66b46b1ee9e69.bundle.js:1)
at main.b771427faeac57797e03.bundle.js:1

code:

export * from './authenticator/company.model';
export * from './authenticator/user.model';
export * from './authenticator/person.model';

import { Company , Person, User } from '@vamos-webapp/models';

not working in ng serve --prod

@jacobbullock
Copy link

Is this getting any attention? We are experiencing this in 5.2 as well

@gnovotny
Copy link

gnovotny commented Jun 7, 2018

Experiencing this as well in version 6

Problem goes away when you build with --build-optimizer=false

@alan-agius4
Copy link
Collaborator

I'm sorry, but we can't reproduce the problem following the instructions you provided.
Remember that we have a large number of issues to resolve, and have only a limited amount of time to reproduce your issue.
Short, explicit instructions make it much more likely we'll be able to reproduce the problem so we can fix it.

If the problem persists, please open a new issue following our submission guidelines.

A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

@angular-automatic-lock-bot
Copy link

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 Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: investigation Requires some digging to determine if action is needed P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful severity3: broken type: bug/fix
Projects
None yet
Development

No branches or pull requests

8 participants