Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Remove path aliases from tests #2243

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

ecraig12345
Copy link
Member

@ecraig12345 ecraig12345 commented Jan 15, 2020

Splitting out #2233 for (slightly) easier reviewing.

Replace legacy path aliases with more standard imports. This change only modifies the imports in tests.

  • Replace src with @fluentui/react in tests, and fix unnecessary deep imports
    • For deep imports, I used paths under @fluentui/react/src I used relative paths into src with comments about why they're needed
  • Replace test with relative paths
  • A couple tests in react and accessibility import generated files which currently live under docs (componentInfo, behaviorInfo). These imports have to stay as path imports for now because having those packages depend on @fluentui/docs would cause circular imports. So we need a better all-up solution for where these generated files and/or the tests that rely on them should live (or get rid of the generated files?).

To fix the issue where .d.ts files were getting generated with relative path imports for inferred types, I removed these settings from tsconfig.common.json:

"baseUrl": "../",
"paths": {
  "@fluentui/*": ["../packages/*/src"]
}

And added to each package tsconfig:

"baseUrl": ".",
"paths": {
  "@fluentui/this-package": ["./src"]
}

And this to the root tsconfig.json (and update the places registering tsconfig-paths to use this config) to ensure that the build system and editors know where to find the packages:

    "baseUrl": ".",
    "paths": {
      "@fluentui/docs": ["docs"],
      "@fluentui/e2e": ["e2e"],
      "@fluentui/internal-tooling": ["build"],
      "@fluentui/perf": ["perf"],
      "@fluentui/*": ["packages/*/src"]
    }

(Also temporarily have it inherit from tsconfig.docs until all the aliases are removed.)

It's likely that if we switched the main field in package.json to point to src locally (like it does in staging), and added a pre-publish step to correct it to dist or whatever, we could get rid of all these aliases. But that should be done separately.

@ecraig12345
Copy link
Member Author

ecraig12345 commented Jan 15, 2020

Hmmmmm it also does the relative paths thing with just this part.

@ecraig12345
Copy link
Member Author

Slight difference is for react-bindings it does ../../../../react-bindings/src instead of ../.., but that might just be due to this additional fix.

Old before/after:
diff

Now:
image

@ecraig12345
Copy link
Member Author

I fixed the .d.ts issue by removing these settings from tsconfig.common.json:

"baseUrl": "../",
"paths": {
  "@fluentui/*": ["../packages/*/src"]
}

And added to each package tsconfig:

"baseUrl": ".",
"paths": {
  "@fluentui/this-package": ["./src"]
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant