Three.js: The tree-shaking is not working with three.modules.js

Created on 3 Feb 2017  路  1Comment  路  Source: mrdoob/three.js

index.js

import { Math as tMath } from './lib/three.modules.js'

console.log(tMath.DEG2RAD);

When I use gulp + rollup to bundle the index.js , It merge the all three.module.js to the build.js file NOT ONLY the Math section.

gulpfile.js

var gulp = require('gulp'),

    rollup = require('gulp-better-rollup'),

    babel = require('rollup-plugin-babel'),

    concat = require('gulp-concat'),

    uglify = require('gulp-uglify');

gulp.task('bundle', function() {

    var isRelease = process.argv.indexOf('-r') > -1;

    return gulp.src('./src/index.js')
       .pipe(rollup({
            plugins: [
                    // babel({
                    //  exclude: 'node_modules/**',
                    //  presets: ['es2015-rollup']
                    // })
                ]
        }, 'iife'))

       .pipe(rename('build.js'))
       .pipe(gulp.dest('./build/'))

So how to config this?

Most helpful comment

The issue is that Rollup can't shake Object.AssignProperties or Object.DefineProperties, which are used a lot throughout the three codebase.

This is not something that can be fixed at the moment. See this Rollup issue.

>All comments

The issue is that Rollup can't shake Object.AssignProperties or Object.DefineProperties, which are used a lot throughout the three codebase.

This is not something that can be fixed at the moment. See this Rollup issue.

Was this page helpful?
0 / 5 - 0 ratings