Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pure annotations house cleaning: Webpack #24336

Merged
merged 1 commit into from
Jul 18, 2022

Conversation

pschroen
Copy link
Contributor

Related issue: #24199

Troubleshooting the remaining side-effects in r142, I've gone through all the /*@__PURE__*/ annotations again with webpack this time.

@@ -7,7 +7,7 @@ import { AnimationClip } from './AnimationClip.js';
import { NormalAnimationBlendMode } from '../constants.js';


const _controlInterpolantsResultBuffer = /*@__PURE__*/ new Float32Array( 1 );
const _controlInterpolantsResultBuffer = new Float32Array( 1 );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pure annotation isn't needed.

exponentTable: _exponentTable,
offsetTable: _offsetTable
} = /*@__PURE__*/ _generateTables();
const _tables = /*@__PURE__*/ _generateTables();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object destructuring assignment with a pure annotation doesn't work in webpack/terser.

@pschroen
Copy link
Contributor Author

pschroen commented Jul 12, 2022

FWIW here's my webpack configuration I've been using for troubleshooting tree-shaking, I like having the output as human readable as possible, and process of elimination from bottom to top. 😅

mkdir test
cd test
npm init -y
npm i three webpack webpack-cli

webpack.config.js

const TerserPlugin = require('terser-webpack-plugin');
const path = require('path');

module.exports = {
  entry: './src/index.js',
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist'),
  },
  experiments: {
    outputModule: true,
  },
  optimization: {
    usedExports: true,
    minimize: true,
    minimizer: [
      new TerserPlugin({
        terserOptions: {
          compress: {
            defaults: false,
            unused: true,
          },
          mangle: false,
          format: {
            comments: true,
            beautify: true,
          },
        },
        extractComments: false,
      }),
    ],
  },
  mode: 'production',
};

src/index.js

import { Vector2 } from 'three';

console.log(new Vector2(0, 1));
npx webpack

@Mugen87 Mugen87 added this to the r143 milestone Jul 15, 2022
@Mugen87 Mugen87 merged commit b367f7d into mrdoob:dev Jul 18, 2022
@pschroen pschroen deleted the tree-shaking-pure-annotations-webpack branch July 18, 2022 13:38
@mrdoob
Copy link
Owner

mrdoob commented Jul 22, 2022

Thanks!

abernier pushed a commit to abernier/three.js that referenced this pull request Sep 16, 2022
snagy pushed a commit to snagy/three.js-1 that referenced this pull request Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants