Skip to content

Commit

Permalink
fix #27 sim-ecs not working in WebPack release builds
Browse files Browse the repository at this point in the history
  • Loading branch information
minecrawler committed May 24, 2021
1 parent 1b7a382 commit 1ddd498
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ npm install sim-ecs
- [Adding Entities](#adding-entities)
- [Working with States](#working-with-states-optional)
- [Update loop](#Update-loop)
- [Using Prefabs](#using-prefabs)
- [Saving and using Prefabs](#saving-and-using-prefabs)
- [Save and Load a World](#save-and-load-a-world)
- [Building for Production](#building-for-production)
- [Comparison with other TS ECS libs](#comparison-with-other-ts-ecs-libs)
- [Features](#features)
- [Performance](#performance)
Expand Down Expand Up @@ -275,6 +276,13 @@ At this point, the data can also be manipulated, for example updating timestamps
Usually, though, registering the Components is enough for sim-ecs to correctly handle deserialization.


## Building for Production

When building for production, it is important to keep class names.
Some minimizers need to be adjusted. For example WebPack (using Terser) needs to pass this as configuration.
The Pong example uses WebPack and demonstrates how to set up WebPack for proper production usage (in `make.js`).


## Comparison with other TS ECS libs

In an attempt to make sim-ecs best in class, it is important to compare it to other ECS libraries,
Expand Down
9 changes: 9 additions & 0 deletions examples/pong/make.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const webpack = require('webpack');
const fs = require('fs-extra');
const path = require('path');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const TerserPlugin = require("terser-webpack-plugin");

// arg handling
const args = arg({
Expand Down Expand Up @@ -51,6 +52,14 @@ const log = (...strs) => console.log.apply(console.log, ['[make]'].concat(strs))
path: outDir,
filename: 'bundle.js'
},
optimization: {
minimize: true,
minimizer: [new TerserPlugin({
terserOptions: {
keep_classnames: true,
},
})],
},
resolve: {
extensions: ['.js', '.ts'],
modules: ['node_modules'],
Expand Down
1 change: 1 addition & 0 deletions examples/pong/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"sass-loader": "^11.0.1",
"sim-ecs": "file://../..",
"style-loader": "^2.0.0",
"terser-webpack-plugin": "^5.1.2",
"to-string-loader": "^1.1.6",
"ts-loader": "^8.1.0",
"tslib": "latest",
Expand Down

0 comments on commit 1ddd498

Please sign in to comment.