Skip to content

Commit 8a56b64

Browse files
author
Huguenin-Elie Steve
committed
definitive toolchain compilation
esm and cjs are produced by tsc rollup build all wasm loaders
1 parent 79a3b97 commit 8a56b64

7 files changed

+69
-25
lines changed

.babelrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module.exports = {
2-
"presets": ["@babel/preset-typescript"],
2+
"presets": ["@babel/preset-env"],
33
"env": {
44
"esm": {
5-
"presets": [["@babel/preset-typescript", { "modules": false }]],
5+
"presets": [["@babel/preset-env", { "modules": false }]],
66
}
77
}
88
};

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
.DS_Store
44
tmp
55
node_modules
6-
npm-debug.log
6+
*.log
77
package-lock.json
88
yarn.lock
99
dist

.size-snapshot.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"gzipped": 13273
66
},
77
"dist\\gl-matrix-min.js": {
8-
"bundled": 228852,
9-
"minified": 52941,
10-
"gzipped": 13521
8+
"bundled": 52941,
9+
"minified": 52870,
10+
"gzipped": 13467
1111
}
1212
}

build/loader-debug.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import wasm from './untouched.wasm';
2+
3+
let modules;
4+
5+
wasm({ ...imports }).then(({ instance }) => {
6+
modules = instance.exports
7+
})
8+
9+
export const {
10+
glMatrix,
11+
mat2, mat2d, mat3, mat4,
12+
quat, quat2,
13+
vec2, vec3, vec4
14+
} = modules;

build/loader-release.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import wasm from './optimized.wasm';
2+
3+
let modules;
4+
5+
wasm({ ...imports }).then(({ instance }) => {
6+
modules = instance.exports
7+
})
8+
9+
export const {
10+
glMatrix,
11+
mat2, mat2d, mat3, mat4,
12+
quat, quat2,
13+
vec2, vec3, vec4
14+
} = modules;

package.json

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,35 +31,32 @@
3131
"doc": "jsdoc -c jsdoc.config.json",
3232
"update-license-version": "node utils/update-license-version.js",
3333
"build-umd": "rollup -c",
34-
"build-esm": "cross-env BABEL_ENV=esm babel assembly -d dist/esm",
35-
"build-cjs": "babel assembly -d dist/cjs",
34+
"build-esm": "tsc --module es6 assembly/index.ts --outDir dist/esm",
35+
"build-cjs": "tsc --module commonjs assembly/index.ts -outDir dist/cjs",
3636
"build-dts": "tsc --declaration --emitDeclarationOnly --module amd --outFile ./dist/index.d.ts ./assembly/index.ts && node ./utils/bundle-dts.js && tsc --noEmit ./dist/index.d.ts",
37-
"build-portable": "del dist && npm run update-license-version && npm run build-umd && npm run build-esm && npm run build-cjs && npm run build-dts && node ./utils/build.js",
38-
"build": "npm run build-portable && npm run asbuild",
37+
"build": "del dist && npm run update-license-version && npm run asbuild && npm run build-umd && npm run build-esm && npm run build-cjs && npm run build-dts && node ./utils/build.js",
3938
"prepare": "npm run build",
4039
"asbuild:untouched": "asc assembly/index.ts --target debug",
4140
"asbuild:optimized": "asc assembly/index.ts --target release",
4241
"asbuild": "npm run asbuild:untouched && npm run asbuild:optimized"
4342
},
4443
"devDependencies": {
4544
"@assemblyscript/loader": "^0.18.17",
46-
"@babel/cli": "^7.8.4",
47-
"@babel/core": "^7.9.0",
48-
"@babel/preset-env": "^7.9.0",
49-
"@babel/preset-typescript": "^7.13.0",
45+
"@babel/core": "7.9.0",
46+
"@babel/preset-env": "^7.13.12",
5047
"@babel/register": "^7.9.0",
48+
"@rollup/plugin-replace": "^2.4.2",
5149
"@rollup/plugin-typescript": "^8.2.1",
50+
"@rollup/plugin-wasm": "^5.1.2",
5251
"assemblyscript": "^0.18.16",
5352
"cross-env": "^7.0.2",
5453
"del-cli": "^3.0.0",
5554
"jsdoc": "^3.6.3",
5655
"mocha": "^7.1.1",
5756
"node-libs-browser": "^2.2.1",
5857
"rollup": "^2.3.2",
59-
"rollup-plugin-assemblyscript": "^2.0.0",
60-
"rollup-plugin-babel": "^4.4.0",
6158
"rollup-plugin-size-snapshot": "^0.11.0",
62-
"rollup-plugin-terser": "^5.3.0",
59+
"rollup-plugin-terser": "5.3.0",
6360
"typescript": "^3.8.3"
6461
},
6562
"dependencies": {}

rollup.config.js

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import babel from 'rollup-plugin-babel';
2-
import { terser } from 'rollup-plugin-terser';
31
import { sizeSnapshot } from 'rollup-plugin-size-snapshot';
2+
import { terser } from 'rollup-plugin-terser';
3+
import replace from '@rollup/plugin-replace';
44
import typescript from '@rollup/plugin-typescript';
5+
import wasm from '@rollup/plugin-wasm';
56

67
const version = require('./package.json').version;
78
const license = require('./utils/license-template');
@@ -22,26 +23,44 @@ ${license}
2223
}
2324

2425
export default [
26+
{
27+
input: './build/loader-debug.js',
28+
output: { file: 'dist/wasm/gl-matrix-loader-debug.js', format: 'umd', name },
29+
plugins: [
30+
replace({ preventAssignment: true }),
31+
wasm(),
32+
bannerPlugin
33+
]
34+
},
35+
{
36+
input: './build/loader-release.js',
37+
output: { file: 'dist/wasm/gl-matrix-loader-release.js', format: 'umd', name },
38+
plugins: [
39+
replace({ preventAssignment: true }),
40+
wasm(),
41+
bannerPlugin
42+
]
43+
},
2544
{
2645
input,
2746
output: { file: 'dist/gl-matrix.js', format: 'umd', name },
2847
plugins: [
48+
replace({ preventAssignment: true }),
2949
typescript(),
30-
bannerPlugin,
31-
babel()
50+
bannerPlugin
3251
]
3352
},
3453
{
3554
input,
3655
output: { file: 'dist/gl-matrix-min.js', format: 'umd', name },
3756
plugins: [
57+
replace({ preventAssignment: true }),
3858
typescript(),
39-
bannerPlugin,
40-
babel(),
41-
sizeSnapshot(),
4259
terser({
4360
output: { comments: /^!/ }
44-
})
61+
}),
62+
sizeSnapshot(),
63+
bannerPlugin
4564
]
4665
}
4766
];

0 commit comments

Comments
 (0)