mind-ar-js icon indicating copy to clipboard operation
mind-ar-js copied to clipboard

ES6 module support

Open hiukim opened this issue 4 years ago • 5 comments

Anyone has experience building library with es6 module? The goal is to allow module import for MindAR, which will be similar to importing three.js, e.g.

<script type="module">
import MindAR from './mindar-image.esm.js';
</script>

Apparently, I'm having a hard time doing that. I feel like it shouldn't be too difficult.

Currently, we are only using a simple webpack config: https://github.com/hiukim/mind-ar-js/blob/master/webpack.config.prod.cjs

Anyone can advice what are the necessary changes?

hiukim avatar Oct 18 '21 21:10 hiukim

I've been importing it like this in my tests: import 'mind-ar/dist/mindar-image.prod.js';

Don't know much about webpack though.

ThorstenBux avatar Oct 18 '21 21:10 ThorstenBux

In the output field you should add an entry libraryTarget: 'umd', in this way webpack will build for the major standards (module too).

kalwalt avatar Oct 18 '21 22:10 kalwalt

@ThorstenBux Yes, right now, I'm simply assigning it to the window object, e.g. window.MINDAR, but it isn't being exported as a module.

@kalwalt I believe I've tried that without much luck.

hiukim avatar Oct 18 '21 22:10 hiukim

Do you still have this problem ? I can have a look!

Makio64 avatar Jan 23 '22 20:01 Makio64

@Makio64 Yes, please. Appreciate it! :)

hiukim avatar Jan 24 '22 03:01 hiukim