Sfoglia il codice sorgente

Add test-treeshake script (#21437)

* Add test-treeshake script

* Add basic example from README in test-treeshake
Marco Fugaro 4 anni fa
parent
commit
4cfbf39965
5 ha cambiato i file con 6432 aggiunte e 1 eliminazioni
  1. 1 0
      .gitignore
  2. 6387 1
      package-lock.json
  3. 2 0
      package.json
  4. 18 0
      test/rollup.treeshake.config.js
  5. 24 0
      test/treeshake/index.js

+ 1 - 0
.gitignore

@@ -18,6 +18,7 @@ test/*
 !test/*.*
 !test/*.*
 test/*.cmd
 test/*.cmd
 test/unit/build
 test/unit/build
+test/treeshake/index.bundle.js
 
 
 
 
 **/node_modules
 **/node_modules

File diff suppressed because it is too large
+ 6387 - 1
package-lock.json


+ 2 - 0
package.json

@@ -59,6 +59,7 @@
     "test-unit-examples": "npm run unit-examples --prefix test",
     "test-unit-examples": "npm run unit-examples --prefix test",
     "test-e2e": "node test/e2e/puppeteer.js",
     "test-e2e": "node test/e2e/puppeteer.js",
     "test-e2e-cov": "node test/e2e/check-coverage.js",
     "test-e2e-cov": "node test/e2e/check-coverage.js",
+    "test-treeshake": "rollup -c test/rollup.treeshake.config.js",
     "make-screenshot": "node test/e2e/puppeteer.js --make"
     "make-screenshot": "node test/e2e/puppeteer.js --make"
   },
   },
   "keywords": [
   "keywords": [
@@ -94,6 +95,7 @@
     "eslint-plugin-html": "^6.1.1",
     "eslint-plugin-html": "^6.1.1",
     "regenerator-runtime": "^0.13.7",
     "regenerator-runtime": "^0.13.7",
     "rollup": "^2.40.0",
     "rollup": "^2.40.0",
+    "rollup-plugin-filesize": "^9.1.1",
     "rollup-plugin-terser": "^7.0.2",
     "rollup-plugin-terser": "^7.0.2",
     "servez": "^1.11.0"
     "servez": "^1.11.0"
   },
   },

+ 18 - 0
test/rollup.treeshake.config.js

@@ -0,0 +1,18 @@
+import resolve from '@rollup/plugin-node-resolve';
+import filesize from 'rollup-plugin-filesize';
+
+export default [
+	{
+		input: 'test/treeshake/index.js',
+		plugins: [
+			resolve(),
+			filesize(),
+		],
+		output: [
+			{
+				format: 'esm',
+				file: 'test/treeshake/index.bundle.js'
+			}
+		]
+	}
+];

+ 24 - 0
test/treeshake/index.js

@@ -0,0 +1,24 @@
+import * as THREE from '../..';
+
+let camera, scene, renderer;
+
+init();
+
+function init() {
+
+	camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.01, 10 );
+
+	scene = new THREE.Scene();
+
+	renderer = new THREE.WebGLRenderer( { antialias: true } );
+	renderer.setSize( window.innerWidth, window.innerHeight );
+	renderer.setAnimationLoop( animation );
+	document.body.appendChild( renderer.domElement );
+
+}
+
+function animation( ) {
+
+	renderer.render( scene, camera );
+
+}

Some files were not shown because too many files changed in this diff