Dynamic dynamic import (yes 2x)

I use dynamic import as this:

import('./myfile.js').then(function() {
  // do awful stuff
});

But is it possible to do dynamic dynamic import ?

const str = './myfile.js';
import(str).then(function() {
  // do awful stuff
});

in standard js, I think so, but not in Meteor, as it has no way to know which file must be in the “compiled” bundle.

How to tell Meteor that the file ‘myfile.js’ must be in the bundle and keep the dynamic aspect of the import ?

Adding it in the client with api.add_files is not dynamic.

I tried to insert it on the server, but to no avail

  api.add_files([
    './myfile.js',
  ], ['server']);

I read ben replying to this exact question on the gh issues, maybe you can find the answer there. Ill check later if I find it.

1 Like

This is relevant:

4 Likes

if(false) … Clever. Thank you, that works !