twgl.js: import syntax is broken

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 22 (5 by maintainers)

Most upvoted comments

I spent all weekend chasing what turned out to be a kernel bug in the new 5.x kernel which totally took down my PC, so I’ll try to tackle it again this weekend.

@Elvynia my apologies, this completely slipped my mind. I’ll get to it this weekend definitely.

Ok, when I get time next weekend I’ll PR a rollup config that should maintain backwards compatibility with existing formats while providing module support and we’ll go from there.

Let me add when I original started this project bower was still a thing. People used pre-made ready to use <script> based client side libraries. babel was not a thing. Webpack / rollup / parcel were not things.

I’m all for supporting modules but I’m not so much for breaking older stuff

Yeah, I did something similar, symlinking twgl’s /src directory into an external lib folder and just folding m4.js into my internal lib.

@greggman I don’t mind doing a PR that overhauls your whole build system if you’re not too opinionated as long as it works correctly.

I’ve experienced the same problem while trying to write some TypeScript code.

In ‘modules’ example, TWGL is imported from /src, so current workaround can be either cloning the whole /src directory or doing some Rollup:

$ git clone git://github.com/greggman/twgl.js
$ cd twgl.js
$ npm i -g rollup
$ rollup src/twgl-full.js -o twgl-full-module.js -f esm

This creates twgl-full-module.js file which can be minified/imported/etc and used like this:

import * as twgl from './path/to/twgl-full-module.js';