linkedin / linkedin/eyeglass

cannot Sass-import a file with an eyeglass dependency

Open
#195 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

package:eyeglass
Dominant language
TypeScript
Stars
738
Forks
48
PR merge metrics
No merged PRs in 30d

Description

### Background

Given this tree:
```
eyeglass:modules discovered modules
eyeglass:modules :root(snowcat)
eyeglass:modules ├─┬ @fastly/fui-chrome@5.1.1
eyeglass:modules │ └─┬ @fastly/style-guide@6.0.0-beta.4
eyeglass:modules │ └── @fastly/fui-color@1.1.0
eyeglass:modules ├─┬ @fastly/style-guide@6.0.0-beta.4
eyeglass:modules │ └── @fastly/fui-color@1.1.0
eyeglass:modules └── eyeglass@1.6.0
```
and these files:
```scss
// 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`](https://github.com/sass-eyeglass/eyeglass/blob/ea89b37403d9f547cbc09988e968032efe46be3b/lib/modules/EyeglassModules.js#L263-L290) 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?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with lib/modules/EyeglassModules.js, especially canAccessFrom at lines 263-290, and trace how the eyeglass:modules dependency tree becomes branches for each package origin. Reproduce the nested @fastly/style-guide and @fastly/fui-color case from the issue, then determine why the import is rejected and verify that the Sass import succeeds with appropriate regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js, scss
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.