Bläddra i källkod

Merge pull request #20403 from marcofugaro/polyfills

Rollup: include polyfills only in browser bundle
Mr.doob 4 år sedan
förälder
incheckning
33acbbef6b
2 ändrade filer med 26 tillägg och 1 borttagningar
  1. 0 1
      src/Three.js
  2. 26 0
      utils/build/rollup.config.js

+ 0 - 1
src/Three.js

@@ -1,4 +1,3 @@
-import './polyfills.js';
 import { REVISION } from './constants.js';
 import { REVISION } from './constants.js';
 
 
 export { WebGLMultisampleRenderTarget } from './renderers/WebGLMultisampleRenderTarget.js';
 export { WebGLMultisampleRenderTarget } from './renderers/WebGLMultisampleRenderTarget.js';

+ 26 - 0
utils/build/rollup.config.js

@@ -299,6 +299,30 @@ function header() {
 
 
 }
 }
 
 
+function polyfills() {
+
+	return {
+
+		transform( code, filePath ) {
+
+			if ( filePath.endsWith( 'src/Three.js' ) ) {
+
+				code = "import './polyfills';\n" + code;
+
+			}
+
+
+			return {
+				code: code,
+				map: null
+			};
+
+		}
+
+	};
+
+}
+
 const babelrc = {
 const babelrc = {
 	presets: [
 	presets: [
 		[
 		[
@@ -327,6 +351,7 @@ export default [
 	{
 	{
 		input: 'src/Three.js',
 		input: 'src/Three.js',
 		plugins: [
 		plugins: [
+			polyfills(),
 			addons(),
 			addons(),
 			glconstants(),
 			glconstants(),
 			glsl(),
 			glsl(),
@@ -351,6 +376,7 @@ export default [
 	{
 	{
 		input: 'src/Three.js',
 		input: 'src/Three.js',
 		plugins: [
 		plugins: [
+			polyfills(),
 			addons(),
 			addons(),
 			glconstants(),
 			glconstants(),
 			glsl(),
 			glsl(),