oimophysics 1.2.2: https://www.npmjs.com/package/oimophysics/v/1.2.2
My example (see source below) works with Parcel but does not work with Browserify.
Error log:
`
E:_Projects\Physics\oimo\oimo-debug-drawer-webgl-ts>npm run release
[email protected] release E:_Projects\Physics\oimo\oimo-debug-drawer-webgl-ts
npm run compile && npm run bundle && npm run uglify
[email protected] compile E:_Projects\Physics\oimo\oimo-debug-drawer-webgl-ts
tsc -p tsconfigs/tsconfig.release.json
[email protected] bundle E:_Projects\Physics\oimo\oimo-debug-drawer-webgl-ts
browserify public/js/main.js -o public/js/bundle.js
SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' (54881:0) while parsing E:_Projects\node_modules\oimophysics\OimoPhysics.js while parsing file: E:_Projects\node_modules\oimophysics\OimoPhysics.js
at DestroyableTransform.end [as _flush] (C:\Users\8Observer8\AppData\Roaming\npm\node_modules\browserify\node_modules\insert-module-globals\index.js:114:21)
at DestroyableTransform.prefinish (C:\Users\8Observer8\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib_stream_transform.js:138:10)
at DestroyableTransform.emit (events.js:400:28)
at prefinish (C:\Users\8Observer8\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib_stream_writable.js:619:14)
at finishMaybe (C:\Users\8Observer8\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib_stream_writable.js:627:5)
at endWritable (C:\Users\8Observer8\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib_stream_writable.js:638:3)
at DestroyableTransform.Writable.end (C:\Users\8Observer8\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib_stream_writable.js:594:41)
at DestroyableTransform.onend (C:\Users\8Observer8\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib_stream_readable.js:577:10)
at Object.onceWrapper (events.js:519:28)
at DestroyableTransform.emit (events.js:412:35)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] bundle: browserify public/js/main.js -o public/js/bundle.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] bundle script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\8Observer8\AppData\Roaming\npm-cache_logs\2022-09-16T11_33_02_421Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] release: npm run compile && npm run bundle && npm run uglify
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] release script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\8Observer8\AppData\Roaming\npm-cache_logs\2022-09-16T11_33_02_563Z-debug.log
E:_Projects\Physics\oimo\oimo-debug-drawer-webgl-ts>
`
Example. Browserify, UglifyJS, TypeScript were installed globally.
Project structure:
![image](https://user-images.githubusercontent.com/3908473/190630998-2c939795-3e99-4db0-b919-8f73feb53aba.png)
Command to build for release: npm run release
package.json
{
"name": "oimo-debug-drawer-webgl-ts",
"version": "1.0.0",
"description": "",
"main": "public/js/bundle.js",
"targets": {
"main": {
"includeNodeModules": true
}
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"del_files": "del /f /q /s .\\public\\js\\*.*",
"dev": "npm run del_files && parcel watch src/main.ts",
"compile": "tsc -p tsconfigs/tsconfig.release.json",
"bundle": "browserify public/js/main.js -o public/js/bundle.js",
"uglify": "uglifyjs public/js/bundle.js -o public/js/bundle.js",
"release": "npm run compile && npm run bundle && npm run uglify"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"oimophysics": "^1.2.2"
}
}
tsconfigs/tsconfig.release.json
{
"compilerOptions": {
"target": "ES5",
"outDir": "../public/js",
"sourceMap": false,
"types": [
"node"
],
"allowSyntheticDefaultImports": true,
"esModuleInterop": true
},
"include": [
"../src/**/*.ts"
],
"exclude": [
"node_modules"
]
}
src/main.ts
import { oimo } from "oimophysics";
const oimoWorld = new oimo.dynamics.World();
oimoWorld.setGravity(new oimo.common.Vec3(0, -9.8, 0));
console.log(oimoWorld.getGravity());
public/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script type="module" src="js/bundle.js"></script>
</body>
</html>
public/js/main.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var oimophysics_1 = require("oimophysics");
var oimoWorld = new oimophysics_1.oimo.dynamics.World();
oimoWorld.setGravity(new oimophysics_1.oimo.common.Vec3(0, -9.8, 0));
console.log(oimoWorld.getGravity());