Skip to content

Commit

Permalink
chore(nx): enable analyzeSourceFiles in order to build dependency gra…
Browse files Browse the repository at this point in the history
…ph based on source files instead statically defined package.json dependencies (#32359)
  • Loading branch information
Hotell authored Sep 13, 2024
1 parent 1795ce7 commit 680bbaa
Show file tree
Hide file tree
Showing 48 changed files with 192 additions and 88 deletions.
15 changes: 15 additions & 0 deletions .nxignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,19 @@ packages/fluentui/CONTRIBUTING.md
packages/fluentui/README.md
packages/fluentui/.browserslistrc


; build output
**/dist/**

; known directories to not incorporate into the workspace graph creation
**/fixtures/**
**/__fixtures__/**
**/bundle-size/**

; scaffolding templates
**/generators/**/files/**
plop-templates
plop-templates-*

; TODO: temporary ignore - remove once https://github.com/microsoft/fluentui/pull/32371 is merged
scripts/*/just.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "chore: add missing workspace scripts-cypress devDependencies",
"packageName": "@fluentui/babel-preset-global-context",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "chore: resolve circular dependencies and remove ban-context-export tests tight coupling to monorepo setup/package",
"packageName": "@fluentui/eslint-plugin",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "chore: add missing workspace scripts-cypress devDependencies",
"packageName": "@fluentui/react-aria",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "chore: reflect package.json dependencies to match actual dep graph",
"packageName": "@fluentui/react-conformance",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "chore: add missing workspace scripts-cypress devDependencies",
"packageName": "@fluentui/react-datepicker-compat",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "chore: add missing workspace scripts-cypress devDependencies",
"packageName": "@fluentui/react-infolabel",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "chore: add missing workspace scripts-cypress devDependencies",
"packageName": "@fluentui/react-list-preview",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: cleanup production dependencies and fix forbidden sub-package import within Menu",
"packageName": "@fluentui/react-migration-v8-v9",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "chore: add missing workspace scripts-cypress devDependencies",
"packageName": "@fluentui/react-table",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "chore: add missing workspace scripts-cypress devDependencies",
"packageName": "@fluentui/react-tag-picker",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "chore: add missing workspace scripts-cypress devDependencies",
"packageName": "@fluentui/react-timepicker-compat",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "chore: add missing workspace scripts-cypress devDependencies",
"packageName": "@fluentui/react-toast",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "chore: reflect package.json dependencies to match actual dep graph",
"packageName": "@fluentui/react-utilities",
"email": "[email protected]",
"dependentChangeType": "none"
}
5 changes: 0 additions & 5 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
"libsDir": "packages",
"appsDir": "apps"
},
"pluginsConfig": {
"@nx/js": {
"analyzeSourceFiles": false
}
},
"targetDefaults": {
"bundle-size": {
"dependsOn": ["build"],
Expand Down
6 changes: 6 additions & 0 deletions packages/eslint-plugin/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
// too many false positives on node types
"@typescript-eslint/naming-convention": "off"
}
},
{
"files": ["src/rules/**/fixtures/**/*.{js,ts}"],
"rules": {
"import/no-extraneous-dependencies": "off"
}
}
]
}
1 change: 1 addition & 0 deletions packages/eslint-plugin/src/configs/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module.exports = {
'@fluentui/no-context-default-value': [
'error',
{
// nx-ignore-next-line - this is a valid use case to ignore workspace packages. keeping them part of the project dependencies would be wrong assumption
imports: ['react', '@fluentui/react-context-selector', '@fluentui/global-context'],
},
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { createContext } from '@fluentui/react-context-selector';
import { createContext } from '@proj/react-context-selector';

export const MyContext = createContext({});
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"outDir": "dist",
"declaration": true,
"declarationDir": "dist/types",
"types": ["static-assets", "environment"]
"types": ["static-assets", "environment"],
"baseUrl": ".",
"paths": {
"@proj/react-context-selector": ["../react-context-selector-pkg/index.ts"]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import * as React from 'react';

export const MyContext = React.createContext({});
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import * as React from 'react';

export const MyContext = React.createContext({});
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"outDir": "dist",
"declaration": true,
"declarationDir": "dist/types",
"types": ["static-assets", "environment"]
"types": ["static-assets", "environment"],
"baseUrl": ".",
"paths": {
"@proj/react-context-selector": ["../react-context-selector-pkg/index.ts"]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { Context } from './types';

export const createContext = <T>(value: T): Context<T> => {
return {} as Context<T>;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { createContext } from './context';
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as React from 'react';

export type Context<Value> = React.Context<Value> & {
Provider: React.FC<React.ProviderProps<Value>>;
Consumer: never;
};
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ ruleTester.run('ban-context-export', rule, {
errors: [{ messageId: 'contextSelector' }],
parserOptions: getParserOptions('named-export'),
code: `
import { createContext } from '@fluentui/react-context-selector';
import { createContext } from '@proj/react-context-selector';
export const MyContext = createContext({});
`,
filename: 'src/index.ts',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,52 +10,52 @@ ruleTester.run('no-context-default-value', rule, {
{
code: `
import {createContext as createContext1} from 'react'
import {createContext as createContext2} from '@fluentui/react-context-selector'
import {createContext as createContext2} from '@proj/react-context-selector'
const context1 = createContext1();
const context2 = createContext2();
`,
options: [
{
imports: ['react', '@fluentui/react-context-selector'],
imports: ['react', '@proj/react-context-selector'],
},
],
},
{
code: `
import {createContext as createContext1} from 'react'
import {createContext as createContext2} from '@fluentui/react-context-selector'
import {createContext as createContext2} from '@proj/react-context-selector'
const context1 = createContext1(undefined);
const context2 = createContext2(undefined);
`,
options: [
{
imports: ['react', '@fluentui/react-context-selector'],
imports: ['react', '@proj/react-context-selector'],
},
],
},
{
code: `
import * as React from 'react'
import * as ContextSelector from '@fluentui/react-context-selector'
import * as ContextSelector from '@proj/react-context-selector'
const context1 = React.createContext(undefined);
const context2 = ContextSelector.createContext(undefined);
`,
options: [
{
imports: ['react', '@fluentui/react-context-selector'],
imports: ['react', '@proj/react-context-selector'],
},
],
},
{
code: `
import React from 'react'
import ContextSelector from '@fluentui/react-context-selector'
import ContextSelector from '@proj/react-context-selector'
const context1 = React.createContext(undefined);
const context2 = ContextSelector.createContext(undefined);
`,
options: [
{
imports: ['react', '@fluentui/react-context-selector'],
imports: ['react', '@proj/react-context-selector'],
},
],
},
Expand All @@ -64,69 +64,69 @@ ruleTester.run('no-context-default-value', rule, {
{
code: `
import {createContext as createContext1} from 'react'
import {createContext as createContext2} from '@fluentui/react-context-selector'
import {createContext as createContext2} from '@proj/react-context-selector'
const context1 = createContext1(null);
const context2 = createContext2(null);
`,
options: [
{
imports: ['react', '@fluentui/react-context-selector'],
imports: ['react', '@proj/react-context-selector'],
},
],
errors: [{ messageId: 'invalidDefaultValue' }, { messageId: 'invalidDefaultValue' }],
},
{
code: `
import {createContext as createContext1} from 'react'
import {createContext as createContext2} from '@fluentui/react-context-selector'
import {createContext as createContext2} from '@proj/react-context-selector'
const context1 = createContext1({});
const context2 = createContext2({});
`,
options: [
{
imports: ['react', '@fluentui/react-context-selector'],
imports: ['react', '@proj/react-context-selector'],
},
],
errors: [{ messageId: 'invalidDefaultValue' }, { messageId: 'invalidDefaultValue' }],
},
{
code: `
import {createContext as createContext1} from 'react'
import {createContext as createContext2} from '@fluentui/react-context-selector'
import {createContext as createContext2} from '@proj/react-context-selector'
const context1 = createContext1(defaultValue);
const context2 = createContext2(defaultValue);
`,
options: [
{
imports: ['react', '@fluentui/react-context-selector'],
imports: ['react', '@proj/react-context-selector'],
},
],
errors: [{ messageId: 'invalidDefaultValue' }, { messageId: 'invalidDefaultValue' }],
},
{
code: `
import * as React from 'react'
import * as ContextSelector from '@fluentui/react-context-selector'
import * as ContextSelector from '@proj/react-context-selector'
const context1 = React.createContext(defaultValue);
const context2 = ContextSelector.createContext(defaultValue);
`,
options: [
{
imports: ['react', '@fluentui/react-context-selector'],
imports: ['react', '@proj/react-context-selector'],
},
],
errors: [{ messageId: 'invalidDefaultValue' }, { messageId: 'invalidDefaultValue' }],
},
{
code: `
import React from 'react'
import ContextSelector from '@fluentui/react-context-selector'
import ContextSelector from '@proj/react-context-selector'
const context1 = React.createContext(defaultValue);
const context2 = ContextSelector.createContext(defaultValue);
`,
options: [
{
imports: ['react', '@fluentui/react-context-selector'],
imports: ['react', '@proj/react-context-selector'],
},
],
errors: [{ messageId: 'invalidDefaultValue' }, { messageId: 'invalidDefaultValue' }],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ import {
import { TestHelper } from './testHelper';
import { definitions } from './testDefinitions';

// @{link 'file://./../../../docs/src/behaviorMenu.json'}
// nx-ignore-next-line - following pragma ignores 'docs' project(application) being part of this package dependencies from nx - 🚨 NOTE: this is wrong as without docs project json files generated this test wont work.
const behaviorMenuItems = require('../../../docs/src/behaviorMenu');

const testHelper = new TestHelper();
Expand Down
1 change: 1 addition & 0 deletions packages/fluentui/perf-test-northstar/.digest/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Provider, teamsTheme } from '@fluentui/react-northstar';

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.
// nx-ignore-next-line - ignoring from nx dep graph because this is resolved via storybook behind the scenes without no build assets needed.
require.context('../../docs/src', 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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"build": "just-scripts build --module cjs",
"clean": "just-scripts clean",
"code-style": "just-scripts code-style",
"pree2e": "yarn build",
"e2e": "cypress run --component",
"e2e:local": "cypress open --component",
"just": "just-scripts",
Expand Down
3 changes: 2 additions & 1 deletion packages/react-components/react-aria/library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"@fluentui/eslint-plugin": "*",
"@fluentui/react-conformance": "*",
"@fluentui/scripts-api-extractor": "*",
"@fluentui/scripts-tasks": "*"
"@fluentui/scripts-tasks": "*",
"@fluentui/scripts-cypress": "*"
},
"dependencies": {
"@fluentui/keyboard-keys": "^9.0.7",
Expand Down
Loading

0 comments on commit 680bbaa

Please sign in to comment.