Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot Sass-import a file with an eyeglass dependency #195

Open
jamesarosen opened this issue Dec 11, 2018 · 2 comments
Open

cannot Sass-import a file with an eyeglass dependency #195

jamesarosen opened this issue Dec 11, 2018 · 2 comments
Labels
package:eyeglass Related to the core eyeglass package in this monorepo.

Comments

@jamesarosen
Copy link

Background

Given this tree:

eyeglass:modules discovered modules
eyeglass:modules 	:root(snowcat)
eyeglass:modules 	├─┬ @fastly/[email protected]
eyeglass:modules 	│ └─┬ @fastly/[email protected]
eyeglass:modules 	│   └── @fastly/[email protected]
eyeglass:modules 	├─┬ @fastly/[email protected]
eyeglass:modules 	│ └── @fastly/[email protected]
eyeglass:modules 	└── [email protected]

and these files:

// snowcat/app/styles/app.scss
@import 'fastly/variables/all';
…

// @fastly/style-guide/app/styles/fastly/variables/_all.scss
@import '@fastly/fui-color';
…

Problem

I get

eyeglass:import @fastly/fui-color cannot be imported from /Users/jamesrosen/Code/snowcat/tmp/eyeglass_compiler-input_base_path-WdAFZ1zV.tmp/fastly/variables/_all.scss +0ms
eyeglass:import @fastly/fui-color cannot be imported from /Users/jamesrosen/Code/snowcat/node_modules/@fastly/style-guide/app/styles/fastly/variables/_all.scss +0ms

I've added some logging to canAccessFrom and got

// 1
{
  branches: [
    {
      name: 'snowcat',
      version: '0.0.0',
      path: '/Users/jamesrosen/Code/snowcat',
      dependencies: {
        '@fastly/fui-chrome': [Object],
        '@fastly/style-guide': [Object],
        eyeglass: [Object]
      }
    }
  ],
  name: '@fastly/fui-color',
  pkg: '/Users/jamesrosen/Code/snowcat',
  origin: '/Users/jamesrosen/Code/snowcat/tmp/eyeglass_compiler-input_base_path-XxBdGBtB.tmp/fastly/variables/_all.scss'
}

// 2
{
  branches: [],
  name: '@fastly/fui-color',
  pkg: '/Users/jamesrosen/Code/snowcat/node_modules/@fastly/style-guide',
  origin: '/Users/jamesrosen/Code/snowcat/node_modules/@fastly/style-guide/app/styles/fastly/variables/_all.scss'
}

The first one makes sense to me. @fastly/fui-color isn't a direct dependency of snowcat, so it wouldn't appear in the ("immediate") dependencies.

But the second seems wrong. Why does @fastly/style-guide have no branches, especially given the eyeglass:modules step found the tree?

@jamesarosen
Copy link
Author

branches === [] on the second pass through because it's calculated via

var branches = findBranchesByPath({
  dependencies: this.tree
}, pkg);

where this is always the top-level EyeglassModules instance, so this.tree.dependencies is always the top-level dependencies of the application, not the package in which the reference exists.

@jamesarosen
Copy link
Author

If this is intentional behavior, then it seems that any library should declare its eyeglass-module dependencies as peerDependencies so the consumer is forced to install them as first-class dependencies.

@jamesarosen jamesarosen changed the title cannot import a file with a transitive dependency cannot Sass-import a file with an eyeglass dependency Dec 12, 2018
@chriseppstein chriseppstein added the package:eyeglass Related to the core eyeglass package in this monorepo. label Feb 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:eyeglass Related to the core eyeglass package in this monorepo.
Projects
None yet
Development

No branches or pull requests

2 participants