module is not defined
zircxnium opened this issue · comments
UE Logs
Javascript: This is a test with TypeScript
Javascript: Warning: Create UClass(Test_C4) Elapsed: 0.000300
Javascript: Error: file:///../../../../../../Users/Moi/Documents/Unreal%20Projects/UEjs/Content/Scripts/out/Test.js:13: ReferenceError: module is not defined
Javascript: Error: ReferenceError: module is not defined
Javascript: Error: at file:///../../../../../../Users/Moi/Documents/Unreal%20Projects/UEjs/Content/Scripts/out/Test.js:13:1
Javascript: Error: at file:///../../../../../../Users/Moi/Documents/Unreal%20Projects/UEjs/Content/Scripts/out/Test.js:15:3
Code
@UCLASS()
class Test extends Actor
{
/**
* What do you call a cow with two legs? Lean beef. If the cow has no legs, then it's ground beef.
*
* Test's Constructor
*/
constructor(GWorld: World) {
super(GWorld);
console.log("This is a test with TypeScript");
}
}
export = Test;
(obviously the module is from the compiled js file. not the ts one provided upside)
I'm creating a new release in just a few moments switching to https://github.com/AidasPa/babel-plugin-uts from my custom compiler implementation. Hang tight!
Sorry for the issues! But the babel compiler should address this issue as it introduced the export default Class
syntax,
Alright. Thanks for your reply. I'll try to contribute to the project as much as i can :)
Just published a new release - how to upgrade is in the readme file; This should address your module issue - please tell me if everything worked out!
I'm re-opening the issue because it may still break (it shouldn't 😛 ). If it does please attach the compiled .js
code from out
Now getting
Javascript: Error: file:///../../../../../../Users/Moi/Documents/Unreal%20Projects/UEjs/Content/Scripts/out/Test.u.js:3: ReferenceError: exports is not defined
Javascript: Error: ReferenceError: exports is not defined
Javascript: Error: at file:///../../../../../../Users/Moi/Documents/Unreal%20Projects/UEjs/Content/Scripts/out/Test.u.js:3:23
Javascript: Error: at file:///../../../../../../Users/Moi/Documents/Unreal%20Projects/UEjs/Content/Scripts/out/Test.u.js:28:3
JS:
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
Context.RunFile('aliases.js');
Context.RunFile('polyfill/unrealengine.js');
Context.RunFile('polyfill/timers.js');
/// <reference path="../typings/ue.d.ts">/>
class Test extends Actor {
/**
* What do you call a cow with two legs? Lean beef. If the cow has no legs, then it's ground beef.
*
* Test's Constructor
*/
ctor() {
console.log("This is a test with TypeScript");
}
}
const Test_COMPILED = require('uclass')()(global, Test);
var _default = Test_COMPILED;
exports.default = _default;
Hmm. Give me a second.
Can you try removing export default
from your source?
I think we found a caveat here: there cannot be an export on a file you're going to add via the blueprint. Which in a way, makes no sense anyways. On the file you're adding via the blueprint you also must create a new instance of the class (even if you have no use for it, so it would spawn the actor):
new Test(GWorld);
The only place where you are allowed to use exports are modules/script files that you're not going to be adding via the blueprint
Can you try removing
export default
from your source?I think we found a caveat here: there cannot be an export on a file you're going to add via the blueprint. Which in a way, makes no sense anyways. On the file you're adding via the blueprint you also must create a new instance of the class (even if you have no use for it, so it would spawn the actor):
new Test(GWorld);
The only place where you are allowed to use exports are modules/script files that you're not going to be adding via the blueprint
Okay, you should add exemple then cause it's a bit confusing. Exemples for uses with c++, bp etc
I'll be adding a caveat list soon - and examples are on my TODO list
Currently added this as a comment when creating new actors.
Seems like the initial module issue is resolved now.
Can I close the issue?
Update. Instead of the note thing, added a new @UCLASS()
argument, docs on how it works are in the readme, full changelog in the releases.
Thanks, yes you can close it :)