Decagrog's avatar

Laravel mix and import modules

Hi,

I'm trying to import the iota js library for a personal project https://github.com/iotaledger/iota.js This library doesn't have any browsers version so I think laravel-mix(webpack) should be able to generate one from the source. In my webpack.mix.js I've tried to pass the whole library

 mix.js('node_modules/@iota/','public/is');

But it doens't work and I can't find any relevat info in the laravel docs, should I pass something diffferent to the mix.js?

0 likes
3 replies
Sinnbeck's avatar

Why not just export it to window in one of your own files?

app.js

window.iota = require('@iota/core');
window.converter = require('@iota/converter');
window.extract = require('@iota/extract-json')
Decagrog's avatar

The issue for me is that i'm ignorant about nodejs and server side js, so I find very confunsing the concept of importing and exporting modules

I know that you use require() in Node and import in the browser, so you are proposing to create a node app.js with where to add the library modules and then call the app.js into mix.js src path?

Sinnbeck's avatar

No web uses require as well (I used to use it for all my projects back in the day). It just uses module.export for exporting instead of export.

Import/export is es6 and is compiled by webpack/babel

Here is a good thread on the difference https://stackoverflow.com/a/31367852/1305117

Please or to participate in this conversation.