Skip to content

Commit

Permalink
definitive toolchain compilation
Browse files Browse the repository at this point in the history
esm and cjs are produced by tsc
rollup build all wasm loaders
  • Loading branch information
StEvUgnIn committed Apr 1, 2021
1 parent 79a3b97 commit 3a12ac0
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module.exports = {
"presets": ["@babel/preset-typescript"],
"presets": ["@babel/preset-env"],
"env": {
"esm": {
"presets": [["@babel/preset-typescript", { "modules": false }]],
"presets": [["@babel/preset-env", { "modules": false }]],
}
}
};
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.DS_Store
tmp
node_modules
npm-debug.log
*.log
package-lock.json
yarn.lock
dist
Expand Down
6 changes: 3 additions & 3 deletions .size-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"gzipped": 13273
},
"dist\\gl-matrix-min.js": {
"bundled": 228852,
"minified": 52941,
"gzipped": 13521
"bundled": 52941,
"minified": 52870,
"gzipped": 13467
}
}
14 changes: 14 additions & 0 deletions build/loader-debug.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import wasm from './untouched.wasm';

let modules;

wasm({ ...imports }).then(({ instance }) => {
modules = instance.exports
})

export const {
glMatrix,
mat2, mat2d, mat3, mat4,
quat, quat2,
vec2, vec3, vec4
} = modules;
14 changes: 14 additions & 0 deletions build/loader-release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import wasm from './optimized.wasm';

let modules;

wasm({ ...imports }).then(({ instance }) => {
modules = instance.exports
})

export const {
glMatrix,
mat2, mat2d, mat3, mat4,
quat, quat2,
vec2, vec3, vec4
} = modules;
18 changes: 7 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,35 +31,31 @@
"doc": "jsdoc -c jsdoc.config.json",
"update-license-version": "node utils/update-license-version.js",
"build-umd": "rollup -c",
"build-esm": "cross-env BABEL_ENV=esm babel assembly -d dist/esm",
"build-cjs": "babel assembly -d dist/cjs",
"build-esm": "tsc --module es6 assembly/index.ts --outDir dist/esm",
"build-cjs": "tsc --module commonjs assembly/index.ts -outDir dist/cjs",
"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",
"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",
"build": "npm run build-portable && npm run asbuild",
"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",
"prepare": "npm run build",
"asbuild:untouched": "asc assembly/index.ts --target debug",
"asbuild:optimized": "asc assembly/index.ts --target release",
"asbuild": "npm run asbuild:untouched && npm run asbuild:optimized"
},
"devDependencies": {
"@assemblyscript/loader": "^0.18.17",
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"@babel/preset-typescript": "^7.13.0",
"@babel/core": "7.9.0",
"@babel/register": "^7.9.0",
"@rollup/plugin-replace": "^2.4.2",
"@rollup/plugin-typescript": "^8.2.1",
"@rollup/plugin-wasm": "^5.1.2",
"assemblyscript": "^0.18.16",
"cross-env": "^7.0.2",
"del-cli": "^3.0.0",
"jsdoc": "^3.6.3",
"mocha": "^7.1.1",
"node-libs-browser": "^2.2.1",
"rollup": "^2.3.2",
"rollup-plugin-assemblyscript": "^2.0.0",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-size-snapshot": "^0.11.0",
"rollup-plugin-terser": "^5.3.0",
"rollup-plugin-terser": "5.3.0",
"typescript": "^3.8.3"
},
"dependencies": {}
Expand Down
35 changes: 27 additions & 8 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import babel from 'rollup-plugin-babel';
import { terser } from 'rollup-plugin-terser';
import { sizeSnapshot } from 'rollup-plugin-size-snapshot';
import { terser } from 'rollup-plugin-terser';
import replace from '@rollup/plugin-replace';
import typescript from '@rollup/plugin-typescript';
import wasm from '@rollup/plugin-wasm';

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

export default [
{
input: './build/loader-debug.js',
output: { file: 'dist/wasm/gl-matrix-loader-debug.js', format: 'umd', name },
plugins: [
replace({ preventAssignment: true }),
wasm(),
bannerPlugin
]
},
{
input: './build/loader-release.js',
output: { file: 'dist/wasm/gl-matrix-loader-release.js', format: 'umd', name },
plugins: [
replace({ preventAssignment: true }),
wasm(),
bannerPlugin
]
},
{
input,
output: { file: 'dist/gl-matrix.js', format: 'umd', name },
plugins: [
replace({ preventAssignment: true }),
typescript(),
bannerPlugin,
babel()
bannerPlugin
]
},
{
input,
output: { file: 'dist/gl-matrix-min.js', format: 'umd', name },
plugins: [
replace({ preventAssignment: true }),
typescript(),
bannerPlugin,
babel(),
sizeSnapshot(),
terser({
output: { comments: /^!/ }
})
}),
sizeSnapshot(),
bannerPlugin
]
}
];

0 comments on commit 3a12ac0

Please sign in to comment.