diff --git a/examples/avalanche.js b/examples/avalanche.js index 6f6aea6..3ba3145 100644 --- a/examples/avalanche.js +++ b/examples/avalanche.js @@ -1,9 +1,13 @@ var Example = Example || {}; Example.avalanche = function() { - Matter.use( - 'matter-wrap' - ); + if (typeof require !== 'undefined') { + // either require the plugin directly (Node.js, Webpack etc.) + Matter.use(require('matter-wrap')); + } else { + // or by name from plugin registry (Browser global) + Matter.use('matter-wrap'); + } var Engine = Matter.Engine, Render = Matter.Render, diff --git a/examples/ballPool.js b/examples/ballPool.js index 1aa7d0b..2708937 100644 --- a/examples/ballPool.js +++ b/examples/ballPool.js @@ -1,9 +1,13 @@ var Example = Example || {}; Example.ballPool = function() { - Matter.use( - 'matter-wrap' - ); + if (typeof require !== 'undefined') { + // either require the plugin directly (Node.js, Webpack etc.) + Matter.use(require('matter-wrap')); + } else { + // or by name from plugin registry (Browser global) + Matter.use('matter-wrap'); + } var Engine = Matter.Engine, Render = Matter.Render, diff --git a/package-lock.json b/package-lock.json index b24eae7..e6202fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7612,6 +7612,12 @@ } } }, + "matter-wrap": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/matter-wrap/-/matter-wrap-0.2.0.tgz", + "integrity": "sha512-Gp3tETlN6uZftc1Jnv1sogQd8uB2Xh4c5bQ18qKR6KOMfUlsS8vztrC1vDrZS8eg4MuwE1AgZEcwxI41BSW6oQ==", + "dev": true + }, "pathseg": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/pathseg/-/pathseg-1.2.0.tgz", diff --git a/package.json b/package.json index 57ed0fb..20df457 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "jest-worker": "^24.9.0", "json-stringify-pretty-compact": "^2.0.0", "matter-tools": "^0.12.3", + "matter-wrap": "^0.2.0", "pathseg": "^1.2.0", "poly-decomp": "^0.3.0", "puppeteer-core": "^5.5.0", @@ -39,7 +40,7 @@ "build-alpha": "webpack --mode=production --env.ALPHA & webpack --mode=production --env.MINIMIZE --env.ALPHA", "build-examples": "webpack --config webpack.examples.config.js --mode=production & webpack --config webpack.examples.config.js --mode=production --env.MINIMIZE", "build-examples-alpha": "webpack --config webpack.examples.config.js --mode=production --env.ALPHA & webpack --config webpack.examples.config.js --mode=production --env.MINIMIZE --env.ALPHA", - "build-demo": "mkdir -p demo/lib && cp node_modules/matter-tools/build/matter-tools.demo.js demo/lib & cp node_modules/matter-tools/build/matter-tools.gui.js demo/lib & cp node_modules/matter-tools/build/matter-tools.inspector.js demo/lib & cp node_modules/pathseg/pathseg.js demo/lib & cp node_modules/poly-decomp/build/decomp.js demo/lib", + "build-demo": "mkdir -p demo/lib && cp node_modules/matter-tools/build/matter-tools.demo.js demo/lib & cp node_modules/matter-tools/build/matter-tools.gui.js demo/lib & cp node_modules/matter-tools/build/matter-tools.inspector.js demo/lib & cp node_modules/pathseg/pathseg.js demo/lib & cp node_modules/poly-decomp/build/decomp.js demo/lib & cp node_modules/matter-wrap/build/matter-wrap.js demo/lib", "lint": "eslint 'src/**/*.js' 'demo/js/Demo.js' 'demo/js/Compare.js' 'examples/*.js' 'webpack.*.js'", "doc": "yuidoc --config yuidoc.json --project-version $npm_package_version", "test": "npm run test-node", diff --git a/webpack.config.js b/webpack.config.js index 207807b..f76d019 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -32,6 +32,12 @@ License ${pkg.license}${!minimize ? '\n\n' + license : ''}`; commonjs2: 'poly-decomp', amd: 'poly-decomp', root: 'decomp' + }, + 'matter-wrap': { + commonjs: 'matter-wrap', + commonjs2: 'matter-wrap', + amd: 'matter-wrap', + root: 'MatterWrap' } }; diff --git a/webpack.examples.config.js b/webpack.examples.config.js index 914c985..ea08a09 100644 --- a/webpack.examples.config.js +++ b/webpack.examples.config.js @@ -48,6 +48,12 @@ License ${pkg.license}${!minimize ? '\n\n' + license : ''}`; commonjs2: 'matter-js', amd: 'matter-js', root: 'Matter' + }, + 'matter-wrap': { + commonjs: 'matter-wrap', + commonjs2: 'matter-wrap', + amd: 'matter-wrap', + root: 'MatterWrap' } } };