Skip to content

Commit a14ea40

Browse files
committed
Support export default
1 parent fd98571 commit a14ea40

File tree

8 files changed

+23
-10
lines changed

8 files changed

+23
-10
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ It is easiest to clone this repository and copy relevant files across from there
1717
- The `Promise` library under Shared *must* exist - or the AeroClient will not be able to load.
1818
- The `Internal` folder under Shared *must* exist - or the AeroClient will not be able to load.
1919
- Create a file under your desired location, and add it to `src/GlobalRegistry.d.ts` in the defined format
20+
- You will need to export a class which extends from an `Aero.x` class. This class has to be exported either as the only object exported, or through `export default`
2021
- For examples on how to do this, see [examples](https://github.com/OverHash/aeroTS/tree/master/examples)
2122

2223
## Recommendations

examples/exampleController.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Aero from 'internal/Aero/Aero';
22

3-
export = class exampleController extends Aero.Controller {
3+
export default class exampleController extends Aero.Controller {
44
protected static Start(): void {
55
print('exampleController.ts started!');
66
}
@@ -12,4 +12,4 @@ export = class exampleController extends Aero.Controller {
1212
static foo(str: string): void {
1313
print('Someone sent a message!\n' + str);
1414
}
15-
};
15+
}

examples/exampleModule.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Aero from 'internal/Aero/Aero';
22

3-
export = class exampleModule extends Aero.SharedModule {
3+
export default class exampleModule extends Aero.SharedModule {
44
protected static Start(): void {
55
print('exampleModule.ts started!');
66
}
@@ -12,4 +12,4 @@ export = class exampleModule extends Aero.SharedModule {
1212
foo(str: string): void {
1313
print(str);
1414
}
15-
};
15+
}

examples/exampleService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Aero from 'internal/Aero/Aero';
22

3-
export = class exampleService extends Aero.Service {
3+
export default class exampleService extends Aero.Service {
44
protected static Start(): void {
55
print('exampleService.ts started!');
66

@@ -11,4 +11,4 @@ export = class exampleService extends Aero.Service {
1111
protected static Init(): void {
1212
print('Initiated from exampleService.ts!');
1313
}
14-
};
14+
}

src/Client/Controllers/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import Aero from 'internal/Aero/Aero';
22

3-
export = class clientTest extends Aero.Controller {
3+
export default class clientTest extends Aero.Controller {
44
protected static Start(): void {
55
print("Started from test.ts!");
66
}
77

88
protected static Init(): void {
99
print("Initiated from test.ts!");
1010
}
11-
};
11+
}

src/Server/Services/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import Aero = require("internal/Aero/Aero");
22

3-
export = class test extends Aero.Service {
3+
export default class test extends Aero.Service {
44
protected static Start(): void {
55
print('Started from test.ts!');
66
}
77

88
protected static Init(): void {
99
print('Initiated from test.ts!');
1010
}
11-
};
11+
}

src/internal/client/AeroClient.client.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ local function LazyLoadSetup(tbl, folder)
152152
if (child:IsA("ModuleScript")) then
153153
local objSettings = Settings:Get(child)
154154
local obj = require(child)
155+
if (type(obj) == 'table' and not objSettings.Standalone and obj['default']) then
156+
obj = obj.default
157+
end
155158
settingsPerTbl[obj] = objSettings
156159
rawset(t, i, obj)
157160
if (type(obj) == "table" and not objSettings.Standalone) then
@@ -176,6 +179,9 @@ end
176179
local function LoadController(module, controllersTbl)
177180
local controllerSettings = Settings:Get(module)
178181
local controller = require(module)
182+
if (type(controller) == 'table' and controller['default']) then
183+
controller = controller.default
184+
end
179185
controllersTbl[module.Name] = controller
180186
controller._events = {}
181187
setmetatable(controller, mt)

src/internal/server/AeroServer.server.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ local function LazyLoadSetup(tbl, folder)
181181
if (child:IsA("ModuleScript")) then
182182
local objSettings = Settings:Get(child)
183183
local obj = require(child)
184+
if (type(obj) == 'table' and not objSettings.Standalone and obj['default']) then
185+
obj = obj.default
186+
end
184187
settingsPerTbl[obj] = objSettings
185188
rawset(t, i, obj)
186189
if (type(obj) == "table" and not objSettings.Standalone) then
@@ -212,6 +215,9 @@ local function LoadService(module, servicesTbl, parentFolder)
212215
remoteFolder.Parent = parentFolder
213216

214217
local service = require(module)
218+
if (type(service) == 'table' and service['default']) then
219+
service = service.default
220+
end
215221
servicesTbl[module.Name] = service
216222

217223
if (type(service.Client) ~= "table") then

0 commit comments

Comments
 (0)