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

chore: Remove path aliases - the fun parts #2245

Open
wants to merge 5 commits into
base: chore/remove-aliases-temp
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/gulp/plugins/gulp-example-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Vinyl from 'vinyl'

const prettierConfig = require('../../../.prettierrc.json')

import { ExampleSource } from '../../../docs/src/types'
import { ExampleSource } from './util/docs-types'
import transformStarImportPlugin from '../../babel/transform-star-import-plugin'
import { getRelativePathToSourceFile } from './util'

Expand Down
5 changes: 5 additions & 0 deletions build/gulp/plugins/util/docs-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Temporary workaround to prevent having a circular dependency on @fluentui/docs or
// outside-package path imports in several files. Long-term the types and/or docs build scripts
// should move somewhere else.
// TODO (@ecraig12345) - remove relative docs import
export * from '../../.././../docs/src/types'
2 changes: 1 addition & 1 deletion build/gulp/plugins/util/getComponentInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import _ from 'lodash'
import path from 'path'
import fs from 'fs'

import { BehaviorInfo, ComponentInfo, ComponentProp } from 'docs/src/types'
import { BehaviorInfo, ComponentInfo, ComponentProp } from './docs-types'
import * as docgen from './docgen'
import parseDefaultValue from './parseDefaultValue'
import parseDocblock from './parseDocblock'
Expand Down
2 changes: 1 addition & 1 deletion build/gulp/plugins/util/getShorthandInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as Babel from '@babel/core'
import { NodePath } from '@babel/traverse'
import * as t from '@babel/types'

import { ComponentInfo } from 'docs/src/types'
import { ComponentInfo } from './docs-types'

type ShorthandInfo = Required<
Pick<ComponentInfo, 'implementsCreateShorthand' | 'mappedShorthandProp'>
Expand Down
2 changes: 1 addition & 1 deletion build/gulp/plugins/util/parseDefaultValue.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import _ from 'lodash'
import * as React from 'react'

import { ComponentPropType } from 'docs/src/types'
import { ComponentPropType } from './docs-types'
import { PropItem } from './docgen'

const parseDefaultValue = (
Expand Down
2 changes: 1 addition & 1 deletion build/gulp/plugins/util/parseType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { NodePath } from '@babel/traverse'
import * as t from '@babel/types'
import _ from 'lodash'

import { ComponentPropType } from 'docs/src/types'
import { ComponentPropType } from './docs-types'
import { PropItem } from './docgen'
import parseTypeAnnotation from './parseTypeAnnotation'

Expand Down
2 changes: 1 addition & 1 deletion build/gulp/plugins/util/parseTypeAnnotation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as t from '@babel/types'
import _ from 'lodash'

import { ComponentPropType } from 'docs/src/types'
import { ComponentPropType } from './docs-types'

const keywords: Record<string, Function> = {
any: t.isTSAnyKeyword,
Expand Down
2 changes: 1 addition & 1 deletion build/gulp/tasks/perf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from '../../../perf/types'
import config from '../../config'
import webpackPlugin from '../plugins/gulp-webpack'
import { safeLaunchOptions } from 'build/puppeteer.config'
import { safeLaunchOptions } from '../../puppeteer.config'

const { paths } = config

Expand Down
6 changes: 1 addition & 5 deletions build/gulp/tasks/test-dependencies/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,7 @@ export const prepareWebpackConfig = (options: WebpackOptions) => {
],
resolve: {
extensions: ['.ts', '.tsx', '.js', '.json'],
alias: {
...lernaAliases(),
src: paths.packageSrc('react'),
docs: paths.base('docs'),
},
alias: lernaAliases(),
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion build/gulp/tasks/test-projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import del from 'del'
import config from '../../config'
import tmp from 'tmp'
import http from 'http'
import { safeLaunchOptions } from 'build/puppeteer.config'
import { safeLaunchOptions } from '../../puppeteer.config'

type PackedPackages = Record<string, string>

Expand Down
10 changes: 2 additions & 8 deletions build/tsconfig.docs.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
{
"extends": "./tsconfig.common.json",
"compilerOptions": {
"module": "esnext",
"paths": {
"@fluentui/*": ["packages/*/src"],
"docs/*": ["docs/*"],
"src/*": ["packages/react/src/*"],
"test/*": ["packages/react/test/*"]
}
"module": "esnext"
},
"include": ["../docs/src", "../packages/react/src", "../types"]
"include": ["../docs/src", "../types"]
}
2 changes: 0 additions & 2 deletions build/webpack.config.perf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ const webpackConfig: any = {
extensions: ['.ts', '.tsx', '.js', '.json'],
alias: {
...lernaAliases(),
docs: paths.base('docs'),
src: paths.packageSrc('react'),

// We are using React in production mode with tracing.
// https://gist.github.com/bvaughn/25e6233aeb1b4f0cdb8d8366e54a3977
Expand Down
6 changes: 1 addition & 5 deletions build/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,7 @@ const webpackConfig: any = {
].filter(Boolean),
resolve: {
extensions: ['.ts', '.tsx', '.js', '.json'],
alias: {
...lernaAliases(),
src: paths.packageSrc('react'),
docs: paths.base('docs'),
},
alias: lernaAliases(),
},
optimization: {
// Automatically split vendor and commons
Expand Down
3 changes: 1 addition & 2 deletions packages/perf-test/.digest/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import * as React from 'react'
import { Provider, themes } from '@fluentui/react'

const reqContexts = [
// TODO: Relative pathing isn't the best here, but docs containing perf stories isn't a package that can be added as a dep.
require.context('../../../docs/src', true, /\.perf\.tsx$/),
require.context('@fluentui/docs/src', true, /\.perf\.tsx$/),
require.context('..', true, /\.perf\.tsx$/),
// TODO: why does this break index.html?? seems to pull in stories the same way...
// require.context('../stories', true, /\.perf\.tsx$/),
Expand Down
1 change: 1 addition & 0 deletions packages/perf-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"version": "0.43.0",
"private": true,
"dependencies": {
"@fluentui/docs": "^0.43.0",
"office-ui-fabric-react": "^7.44.0",
"react": "^16.8.0",
"react-dom": "^16.8.0"
Expand Down
1 change: 1 addition & 0 deletions perf/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"license": "MIT",
"devDependencies": {
"@babel/polyfill": "^7.7.0",
"@fluentui/docs": "^0.43.0",
"@fluentui/internal-tooling": "^0.43.0",
"@fluentui/react": "^0.43.0",
"minimatch": "^3.0.4"
Expand Down
6 changes: 5 additions & 1 deletion perf/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import { ProfilerMeasure, ProfilerMeasureCycle } from '../types'
const Profiler = (React as any).unstable_Profiler

const mountNode = document.querySelector('#root')
const performanceExamplesContext = require.context('docs/src/examples/', true, /.perf.tsx$/)
const performanceExamplesContext = require.context(
'@fluentui/docs/src/examples/',
true,
/.perf.tsx$/,
)

// Heads up!
// We want to randomize examples to avoid any notable issues with always first example
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "./build/tsconfig.docs.json",
"extends": "./build/tsconfig.common.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {
Expand Down