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

marked_1.default is not a function. returns "null" in source #1320

Closed
mlncstr opened this issue Aug 10, 2018 · 3 comments
Closed

marked_1.default is not a function. returns "null" in source #1320

mlncstr opened this issue Aug 10, 2018 · 3 comments

Comments

@mlncstr
Copy link

mlncstr commented Aug 10, 2018

Looks like Angular Universal's server.js doesn't like something with one of your functions. Getting this on the node server:

ERROR TypeError: marked_1.default is not a function
/dist/server.js:151583:40

The Component

import {Component, Input, OnInit} from '@angular/core';
import {ContentBlock} from '../../../../app/api-modules/FRApi/Models/api-models';
import marked from 'marked';

@Component({
  selector: 'app-textview-block',
  templateUrl: './app-textview-block.component.html',
  styleUrls: ['./app-textview-block.component.scss']
})
export class AppTextviewBlockComponent implements OnInit {

  @Input()
  block: ContentBlock;
  content: any;
  constructor() { }

  ngOnInit() {
    this.content = marked(this.block.content);
  }
}

Server.js line 151583

var marked_1 = __webpack_require__(/*! marked */ "marked");
var AppTextviewBlockComponent = /** @class */ (function () {
    function AppTextviewBlockComponent() {
    }
    AppTextviewBlockComponent.prototype.ngOnInit = function () {
        this.content = marked_1.default(this.block.content);
    };
    return AppTextviewBlockComponent;
}());

Our QA site

https://other98uias-qa.azurewebsites.net/week-1-of-fall-camp-offensive-recap/308/10

The HTML

<div class="text-view" [innerHTML]="content"></div>

The generated source

<div _ngcontent-sc17="" class="text-view">null</div>

@styfle
Copy link
Member

styfle commented Aug 11, 2018

There is no default export because it’s not a ES Module.

Maybe this will work:

import * as marked from 'marked';

@mlncstr
Copy link
Author

mlncstr commented Aug 11, 2018

100% right. Everything works perfectly now.

Appreciate the prompt and working answer!

@mlncstr mlncstr closed this as completed Aug 11, 2018
@styfle
Copy link
Member

styfle commented Aug 11, 2018

Glad I could help 👍🏼

We have a proposal to move to ESM but node.js is not ready and there are some debates about should we continue shipping CJS and UMD builds. Follow along here: #1288

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants