gjaldon / heroku-buildpack-phoenix-static

A Heroku buildpack for building Phoenix's static assets
MIT License
229 stars 224 forks source link

Loading modules from subdirectories of assets/js/ #85

Closed jacquesn closed 5 years ago

jacquesn commented 5 years ago

An error of "Could not load module" is thrown when my app.js file tries to import from files in subdirectories of assets/js/. The full line of the error:

Processing of js/app.js failed. Error: Could not load module './components/Something' from '/tmp/build_a1b2c3da3caa70b06872f08019710b7d/assets/js'. Make sure the file actually exists.

The offending line of code is import Something from "./components/Something".

I'm using brunch, and the error is thrown during brunch build --production.

If I only import from files in the same directory as app.js and comment out imports from subdirectories, the brunch build works fine.

jacquesn commented 5 years ago

After further diagnosis, I believe the problem was a namespace collision in brunch with "js/components". Changing the name of the folder fixed the problem.

Conclusion: don't make a folder under js/ called "components".