jvandemo / jvandemo/generator-angular2-library

Angular Universal (Server side rendering) - how use *.umd.js for node.js

Open
#135 4 comments 0 reactions 0 assignees View on GitHub
help wanted Type: Question
Dominant language
JavaScript
Stars
740
Forks
116
PR merge metrics
No merged PRs in 30d

Description

When I launch my application with angular universal
i use this repo: https://github.com/evertonrobertoauler/cli-universal-demo

```
$ node dist/server.js
~/api-lib/index.js:1
(function (exports, require, module, __filename, __dirname) { import { Component, Directive, ElementRef, Injectable, NgModule, Pipe } from '@angular/core';
^^^^^^

SyntaxError: Unexpected token import

```

I see that when run build, lib is created in es2015
As in the file` tsconfig.es5.json` we have `"module": "es2015"`

But in the file `api-lib.umd.js` - this is what I need

In my application, I connect the library like this
`import {SampleModule, SampleService} from 'api-lib';`

There is a solution in my project to make webpack compile into es5
In `webpack.config.js`

```
externals: [nodeExternals({
whitelist: [
/^api-lib/
]
})],
```

But it seems to me not right,
I do not understand how I can get my application to connect
here is the `api-lib.umd.js` file when compiled
Or should it automatically do this?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.