isleofcode / ember-cli-asset-sizes-shim

Shim for future ember-cli feature
MIT License
12 stars 3 forks source link

Cannot find module ember-cli/lib/broccoli/ember-app error in monorepo #7

Open tomwayson opened 6 years ago

tomwayson commented 6 years ago

After installing this into my ember app I get the following error when running ember asset-sizes:

Cannot find module '/Users/tom/<monorepo-root>/packages/<ember-app>/node_modules/ember-cli/lib/broccoli/ember-app'

Stack Trace and Error Report: /var/folders/_6/dgtlmj695fv5yds8f5hwvcbs8snz_f/T/error.dump.e5067a82d42b320f08aa37979af1831a.log
An error occurred in the constructor for ember-cli-asset-sizes-shim at /Users/tom/<monorepo-root>/node_modules/ember-cli-asset-sizes-shim

Note that my app is in a monorepo using yarn workspaces, so I have to use yarn add ember-cli-asset-sizes-shim and then ember generate ember-cli-asset-sizes-shim to install the addon, and that also returns the above error.

It looks like the error comes from these hardcoded paths: https://github.com/isleofcode/ember-cli-asset-sizes-shim/blob/1c7d8035e9d5d38ee5bd45fdfbdc0402c7ceb8fc/index.js#L81-L82

Those would probably need to use require.resolve() in order to work in a monorepo.