Closed strutcode closed 4 years ago
You have any idea which is better?
A. rollup the src to a single file, twgl.module.js, add `"module": "dist/twgl.module.js" to package.json
B. just include the src folder in files, add `"module": "src/twgl.js" to package.json
I can report at least that tree-shaking works with webpack/babel if you selectively import from src/twgl.js, eg:
import {
createFramebufferInfo,
createTexture,
resizeFramebufferInfo,
setTextureFromArray,
drawBufferInfo,
bindFramebufferInfo
} from 'twgl/twgl.js';
original file sizes:
vs actual code bundled
@zorro-fr24 Thanks for the tip! I did toy around with that since I noticed the source was written in es module syntax but there are two problems:
@greggman I think option A would be nicer since you can always just reference twgl.js
as your import, instead of finding the particular thing you're looking for from the source files or doing a bunch of import as
stuff. I would be happy with either option though!
I went for option a. I tested and it still shakes the tree
You are awesome! Thanks so much for doing that. I was going to offer to contribute a pull request but it seems like you have it all under control. Consider this case closed.
Is there any interest in providing an ES6 module version of the library to enable tree shaking? The structure of the library makes it ideal for such an application and the source files are already partially using module syntax.