Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

dev-server: Uncaught ReferenceError: __decorate is not defined #91

Closed
unlight opened this issue Jan 20, 2017 · 9 comments
Closed

dev-server: Uncaught ReferenceError: __decorate is not defined #91

unlight opened this issue Jan 20, 2017 · 9 comments
Labels

Comments

@unlight
Copy link

unlight commented Jan 20, 2017

Updating "app.component.js" ...

app.js:formatted:1907 Uncaught ReferenceError: __decorate is not defined
    at eval (eval at <anonymous> (app.js:formatted:75646), <anonymous>:11:16)
    at Number.<anonymous> (app.js:formatted:75647)
    at p (app.js:formatted:75585)
    at w.require (app.js:formatted:75572)
    at Number.<anonymous> (app.js:formatted:58)
    at p (app.js:formatted:75585)
    at w.require (app.js:formatted:75572)
    at Number.<anonymous> (app.js:formatted:46)
    at p (app.js:formatted:75585)
    at Function.t.import (app.js:formatted:75611)
    at EventEmitter.FuseBox.pkg.___scope___.file.module.exports.connect.client.on (app.js:formatted:112)
    at EventEmitter.FuseBox.pkg.___scope___.file.EventEmitter.emit (app.js:formatted:300)
    at WebSocket.FuseBox.pkg.___scope___.file.__dirname.bindEvents.fn.client.onmessage (app.js:formatted:218)
    at WebSocket.wrapFn [as _onmessage] (app.js:formatted:2784)
    at ZoneDelegate.FuseBox.pkg.___scope___.file.ZoneDelegate.invokeTask (app.js:formatted:2009)

app.component.ts

import { Component } from '@angular/core';

@Component({
    selector: 'my-app',
    template: require('./app.component.html'),
    styles: [require('./app.component.css')],
})
export class AppComponent {
    name = 'Angular';
}
Error is here:
var res = new Function('__fbx__dnm__', 'exports', 'require', 'module', '__filename', '__dirname', '__root__', str);
res(true, exports, require, module, __filename, __dirname, __root__) // <--- Error is here

transpiled app.component (str)

"use strict";
var core_1 = require("@angular/core");
var AppComponent = (function () {
    function AppComponent() {
        this.name = 'Angular21';
    }
    return AppComponent;
}());
AppComponent = __decorate([
    core_1.Component({
        selector: 'my-app',
        template: require('./app.component.html'),
        styles: [require('./app.component.css')],
    })
], AppComponent);
exports.AppComponent = AppComponent;

I'm using TypeScriptHelpers plugin.

@nchanged
Copy link
Contributor

Hm.. you are using the new devServer?

@nchanged
Copy link
Contributor

I have just released 1.3.63 that should pick up plugin transformation

@unlight
Copy link
Author

unlight commented Jan 20, 2017

I'm not sure what you mean by new.
Thanks, I will try it later.

unlight added a commit to unlight/angular2-blank-project that referenced this issue Jan 20, 2017
@unlight
Copy link
Author

unlight commented Jan 20, 2017

Same error stays (v 1.3.65)

But I found workaround. There is tslib (This is a runtime library for TypeScript that contains all of the TypeScript helper functions.)

{
    "compilerOptions": {
        "importHelpers": true
    }
}

Generated code will be:

var tslib_1 = require("tslib");
var core_1 = require("@angular/core");
...
AppComponent = tslib_1.__decorate([
...

It allows to get rid of TypeScriptHelpers plugin, here is commit for my boilerplate repo.

@nchanged
Copy link
Contributor

Hey I fixed it, but have not released it yet (I actually tested it) will comment when it gets out

@nchanged
Copy link
Contributor

Please, check the version 1.3.66 should be fixed there. Along with HTML reload
Updated here
run

node fuse

@unlight
Copy link
Author

unlight commented Jan 21, 2017

It works. Super! Thanks.
This issue can be closed.

@devmondo devmondo added the bug label Mar 9, 2017
@davidm-public
Copy link

Same problems:

script.ts:5 Uncaught ReferenceError: __extends is not defined
    at script.ts:5
    at Object.<anonymous> (script.ts:7)
    at d (vendor.js:9984)
    at b.require (vendor.js:9984)
    at Object.<anonymous> (index.ts:3)
    at d (vendor.js:9984)
    at Function.r.import (vendor.js:9984)
    at script.ts:5
    at script.ts:5

screen shot 2018-03-15 at 12 28 18 am

adding tslib and "importHelpers": true
makes no difference.

@devmondo
Copy link
Member

@davidm-public
make sure you have latest fuse, TS ad TSlib installed.
clear cache.

here is what i did

import {default as Vue} from "vue/dist/vue.esm.js";
import {Component} from "vue-property-decorator";

@Component
export class A extends Vue {

}

const component= new A();
console.log(component);

notice the import for vue is pointing to the esm version, you can solve this globally using fuse aliases

    alias: {
        vue: `vue/dist/vue.esm.js`
    }

check the image

image

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

No branches or pull requests

4 participants