Skip to content

Commit c9e84b0

Browse files
committed
Added build time compression, removed debug print
1 parent 63c66e2 commit c9e84b0

File tree

4 files changed

+169
-48
lines changed

4 files changed

+169
-48
lines changed

package-lock.json

Lines changed: 159 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"devDependencies": {
1818
"@types/highlight.js": "^9.12.3",
1919
"@types/node": "^10.14.6",
20+
"compression-webpack-plugin": "^2.0.0",
2021
"css-loader": "^1.0.0",
2122
"file-loader": "^2.0.0",
2223
"gh-pages": "^2.0.1",
@@ -32,6 +33,7 @@
3233
"typescript": "^3.4.5",
3334
"url-loader": "^1.1.2",
3435
"webpack": "^4.30.0",
36+
"webpack-bundle-analyzer": "^3.3.2",
3537
"webpack-cli": "^3.3.1",
3638
"webpack-dev-server": "^3.3.1",
3739
"webpack-merge": "^4.2.1",

src/playground/tstlWorker.ts

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,57 +3,13 @@ import {LuaTranspiler, TranspileResult} from "typescript-to-lua/dist/LuaTranspil
33

44
import * as ts from "typescript";
55

6-
// TODO this needs to be improved it's a mess;
7-
const luaLib: { [key: string]: string } = {
8-
ArrayConcat: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/ArrayConcat.lua"),
9-
ArrayEvery: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/ArrayEvery.lua"),
10-
ArrayFilter: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/ArrayFilter.lua"),
11-
ArrayForEach: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/ArrayForEach.lua"),
12-
ArrayIndexOf: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/ArrayIndexOf.lua"),
13-
ArrayMap: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/ArrayMap.lua"),
14-
ArrayPush: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/ArrayPush.lua"),
15-
ArrayReverse: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/ArrayReverse.lua"),
16-
ArrayShift: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/ArrayShift.lua"),
17-
ArrayUnshift: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/ArrayUnshift.lua"),
18-
ArraySort: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/ArraySort.lua"),
19-
ArraySlice: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/ArraySlice.lua"),
20-
ArraySome: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/ArraySome.lua"),
21-
ArraySplice: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/ArraySplice.lua"),
22-
ArrayFlat: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/ArrayFlat.lua"),
23-
ArrayFlatMap: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/ArrayFlatMap.lua"),
24-
ArraySetLength: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/ArraySetLength.lua"),
25-
ClassIndex: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/ClassIndex.lua"),
26-
ClassNewIndex: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/ClassNewIndex.lua"),
27-
FunctionApply: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/FunctionApply.lua"),
28-
FunctionBind: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/FunctionBind.lua"),
29-
FunctionCall: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/FunctionCall.lua"),
30-
Index: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/Index.lua"),
31-
InstanceOf: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/InstanceOf.lua"),
32-
Iterator: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/Iterator.lua"),
33-
Map: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/Map.lua"),
34-
NewIndex: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/NewIndex.lua"),
35-
ObjectAssign: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/ObjectAssign.lua"),
36-
ObjectEntries: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/ObjectEntries.lua"),
37-
ObjectFromEntries: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/ObjectFromEntries.lua"),
38-
ObjectKeys: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/ObjectKeys.lua"),
39-
ObjectValues: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/ObjectValues.lua"),
40-
Set: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/Set.lua"),
41-
WeakMap: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/WeakMap.lua"),
42-
WeakSet: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/WeakSet.lua"),
43-
SourceMapTraceBack: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/SourceMapTraceBack.lua"),
44-
StringReplace: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/StringReplace.lua"),
45-
StringSplit: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/StringSplit.lua"),
46-
StringConcat: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/StringConcat.lua"),
47-
Symbol: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/Symbol.lua"),
48-
SymbolRegistry: require("raw-loader!../../node_modules/typescript-to-lua/dist/lualib/SymbolRegistry.lua"),
49-
}
50-
516
declare var self: any;
527

8+
/** Dummy fs for lualib compatibility */
539
self.fs = {
5410
readFileSync: (fileName: string) => {
5511
let featureName = fileName.replace("/dist/lualib/", "").replace(".lua", "");
56-
return new Buffer(luaLib[featureName]);
12+
return new Buffer(require(`raw-loader!../../node_modules/typescript-to-lua/dist/lualib/${featureName}.lua`));
5713
}
5814
}
5915

@@ -76,7 +32,6 @@ function transpileString(str: string, options: CompilerOptions = {
7632
getNewLine: () => '\n',
7733

7834
getSourceFile: (filename: string, languageVersion: any) => {
79-
console.log(filename);
8035
if (filename === 'file.ts') {
8136
return ts.createSourceFile(
8237
filename, str, ts.ScriptTarget.Latest, false);

src/playground/webpack.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const path = require('path');
22
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
33
const HtmlWebpackPlugin = require('html-webpack-plugin');
44
const fs = require('fs');
5+
const CompressionPlugin = require('compression-webpack-plugin');
56

67
const merge = require('webpack-merge');
78
const common = require('../webpack.common.js');
@@ -34,7 +35,11 @@ module.exports = merge( common, {
3435
inject: 'head',
3536
filename: 'play.html',
3637
contentFile: 'play.html'
37-
})
38+
}),
39+
new CompressionPlugin({
40+
test: /\.js$|\.css$|\.html$/,
41+
threshold: 8192,
42+
}),
3843
],
3944
output:{filename: 'play_bundle.js'},
4045
});

0 commit comments

Comments
 (0)