Trouble with build plugins and imports from local packages

I built a build plugin to compile Fluent-files into JS. It worked perfectly, until I tried to import a Fluent -file (*.ftl) from a local npm package. At first Meteor, and I have no idea how, shipped the file as is, not compiled. Which obviously broke the app.

I could have the exact same file in two different places and the other one breaks the app when imported:

import bundle from '@arggh/things/i18n/messages.en.ftl'; // Breaks app
import bundle from './messages.en.ftl'; // Works, file gets compiled

After some fiddling, the error message changed and Meteor started complaining about Uncaught Error: Cannot find module. I never managed to get back to the point where uncompiled files were shipped. Strange fluke. But the app was still broken.

I’m not super familiar with build plugins, even though I’ve built a few, and the documentation on them is non-existent, but at least I thought that if I have a build plugin that handles a certain file extension, I can import files with that extension even from npm packages?

import stuff from 'things/abc.stuff`;

Nopes, didn’t work. Until I thought to create a symlink to the package inside /app/imports/ and import from there. Then it worked!

import stuff from '../../imports/things/abc.stuff`;

The next surprise was when I tried using yalc.

When I installed the local npm package with yalc, suddenly the import from node_modules started working:

import stuff from 'things/abc.stuff`;

Any help in debugging / understanding what’s going on here is much appreciated!

Issue here: , There’s also a repro you can try if you want to give it a shot, instructions included.

Here is the source code for the build plugin: …in case anybody wants to have a look and let me know how to make it better :slight_smile: