Description
For a bit of context: I recently started fiddling with converting a couple of my projects to a monorepo using yarn workspaces. One of the downstream dependencies of one of my addons is ember-cli-dropzonejs.
I am getting an error when trying to resolve the dropzone dependency, I believe originating from treeForVendor and treeForStyles, which use this.project.root as the directory root when including dropzone in the vendor tree. Since dependencies are hoisted to the parent of the workspace, dropzone cannot be resolved and the following error is given:
Directory not found: /path/to/parent/workspace-a/node_modules/dropzone/dist/min
|
var dropzoneJs = new Funnel( |
|
path.join(this.project.root, 'node_modules', 'dropzone/dist/min'), |
|
{ files: ['dropzone.min.js'] } |
|
); |
Project layout, in case it is useful
-> parent
-> node_modules/
-> ember-cli-dropzonejs/
-> dropzone/
-> workspace-a/ [this.project.root]
Proposal
Use require.resolve to locate the needed dropzone dependency. This should follow the expected resolution whether in a workspace or not. Inspiration taken from ember-highcharts:
https://github.com/ahmadsoe/ember-highcharts/blob/4a326f0528bcf6236e18fa44ebbe30a185dc271d/index.js#L86-L98
Example:
https://github.com/daniellubovich/ember-cli-dropzonejs/blob/a83b70dd7d36c415b3b196520668eccd46dcbd69/index.js#L14-L17
var dropzoneJs = new Funnel(
path.join(path.dirname(require.resolve('dropzone')), 'min'),
{ files: ['dropzone.min.js'] }
);
Description
For a bit of context: I recently started fiddling with converting a couple of my projects to a monorepo using yarn workspaces. One of the downstream dependencies of one of my addons is ember-cli-dropzonejs.
I am getting an error when trying to resolve the
dropzonedependency, I believe originating fromtreeForVendorandtreeForStyles, which usethis.project.rootas the directory root when including dropzone in the vendor tree. Since dependencies are hoisted to the parent of the workspace, dropzone cannot be resolved and the following error is given:Directory not found: /path/to/parent/workspace-a/node_modules/dropzone/dist/minember-cli-dropzonejs/index.js
Lines 14 to 17 in 7e26e6c
Project layout, in case it is useful
Proposal
Use
require.resolveto locate the neededdropzonedependency. This should follow the expected resolution whether in a workspace or not. Inspiration taken from ember-highcharts:https://github.com/ahmadsoe/ember-highcharts/blob/4a326f0528bcf6236e18fa44ebbe30a185dc271d/index.js#L86-L98
Example:
https://github.com/daniellubovich/ember-cli-dropzonejs/blob/a83b70dd7d36c415b3b196520668eccd46dcbd69/index.js#L14-L17