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

Angular Universal fails on importing 3rd party libraries because they are not transpiled to ES5 #7248

Closed
lukaszbachman opened this issue Aug 2, 2017 · 3 comments

Comments

@lukaszbachman
Copy link

Bug Report or Feature Request (mark with an x)

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

Versions.

@angular/cli: 1.3.0-rc.3
node: 6.10.2
os: linux x64
@angular/animations: 4.3.2
@angular/common: 4.3.2
@angular/compiler: 4.3.2
@angular/core: 4.3.2
@angular/forms: 4.3.2
@angular/http: 4.3.2
@angular/platform-browser: 4.3.2
@angular/platform-browser-dynamic: 4.3.2
@angular/router: 4.3.2
@angular/cli: 1.3.0-rc.3
@angular/compiler-cli: 4.3.2
@angular/platform-server: 4.3.0

Repro steps.

  1. Start new ng project
  2. Install and use ng-bootstrap as proposed here
  3. Follow the "universal story"

The log given by the failure.

$ node universal-test.js
/xxx/frontend-web/node_modules/@ng-bootstrap/ng-bootstrap/alert/alert.js:1
(function (exports, require, module, __filename, __dirname) { import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy, } from '@angular/core';
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.2RxQ (/xxx/frontend-web/dist-server/main.991bfecc1615c90e73c7.bundle.js:1:1646)

Desired functionality.

I am expecting the standard output for my universal app.

Mention any other details that might be useful.

It seems that the problem is that 3rd parties are not being transpiled to ES5 and node can't comprehend Type Script's import statement. People are trying to work around it by making webpack compile the external libs to ES5, example: https://github.com/evertonrobertoauler/cli-universal-demo/blob/master/webpack.config.js
This could perhaps work, but I don't want to eject my project just to work around this issue.

@cyrilletuzi
Copy link
Contributor

Duplicate of #7200

@lukaszbachman
Copy link
Author

Seems like it's the same issue. I'll close this ticket then.

@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 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants