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

1st PR bootstraps package via generator - react-flex package #323

Open
wants to merge 2 commits into
base: main
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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ packages/react-keytips @microsoft/cxe-prg @mainframev
packages/react-interactive-tab @microsoft/cxe-prg @dmytrokirpa
packages/react-gamepad-navigation @microsoft/cxe-prg @hectorjjb
packages/teams-components @microsoft/teams-prg
packages/react-flex bubulux
# <%= NX-CODEOWNER-PLACEHOLDER %>

#### Build/Infra
Expand Down
5 changes: 5 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
"options": {
"packageRoot": "dist/packages/{projectName}"
}
},
"@nx/js:swc": {
"cache": true,
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
}
},
"namedInputs": {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
"react-window": "^1.8.10",
"scheduler": "0.23.0",
"semver": "^7.5.2",
"storybook": "7.6.17",
"stylelint": "^15.10.3",
"syncpack": "^9.8.6",
"ts-node": "10.9.1",
Expand Down
3 changes: 3 additions & 0 deletions packages/react-flex/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../babel.config.json"
}
24 changes: 24 additions & 0 deletions packages/react-flex/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*", "storybook-static"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
"files": ["stories/**/*.tsx", "stories/**/*.ts"],
"rules": {
"@nx/enforce-module-boundaries": "off"
}
}
]
}
11 changes: 11 additions & 0 deletions packages/react-flex/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { StorybookConfig } from '@storybook/react-webpack5';

// eslint-disable-next-line @nx/enforce-module-boundaries
import rootConfig from '../../../.storybook/main';

const config: StorybookConfig = {
...rootConfig,
stories: ['../stories/**/index.stories.@(js|jsx|ts|tsx|mdx)'],
};

export default config;
10 changes: 10 additions & 0 deletions packages/react-flex/.storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { Preview } from '@storybook/react';

// eslint-disable-next-line @nx/enforce-module-boundaries
import rootPreview from '../../../.storybook/preview';

const preview: Preview = {
...rootPreview,
};

export default preview;
27 changes: 27 additions & 0 deletions packages/react-flex/.storybook/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"emitDecoratorMetadata": true,
"outDir": ""
},
"files": [
"../../../node_modules/@nx/react/typings/styled-jsx.d.ts",
"../../../node_modules/@nx/react/typings/cssmodule.d.ts",
"../../../node_modules/@nx/react/typings/image.d.ts"
],
"exclude": [
"../**/*.spec.ts",
"../**/*.spec.js",
"../**/*.spec.tsx",
"../**/*.spec.jsx"
],
"include": [
"../stories/**/*.stories.ts",
"../stories/**/*.stories.js",
"../stories/**/*.stories.jsx",
"../stories/**/*.stories.tsx",
"../stories/**/*.stories.mdx",
"*.ts",
"*.js"
]
}
30 changes: 30 additions & 0 deletions packages/react-flex/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"jsc": {
"target": "es2019",
"parser": {
"syntax": "typescript",
"tsx": true,
"decorators": false,
"dynamicImport": false
},
"transform": {
"react": {
"runtime": "classic",
"useSpread": true
}
},
"keepClassNames": true,
"externalHelpers": true,
"loose": true
},
"sourceMaps": true,
"exclude": [
"jest.config.ts",
".*\\.spec.tsx?$",
".*\\.test.tsx?$",
"./src/jest-setup.ts$",
"./**/jest-setup.ts$",
".*.js$"
],
"$schema": "https://json.schemastore.org/swcrc"
}
11 changes: 11 additions & 0 deletions packages/react-flex/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# react-flex

This library was generated with [Nx](https://nx.dev).

## Building

Run `nx build react-flex` to build the library.

## Running unit tests

Run `nx test react-flex` to execute the unit tests via [Jest](https://jestjs.io).
30 changes: 30 additions & 0 deletions packages/react-flex/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* eslint-disable */
import { readFileSync } from 'fs';

// Reading the SWC compilation config and remove the "exclude"
// for the test files to be compiled by SWC
const { exclude: _, ...swcJestConfig } = JSON.parse(
readFileSync(`${__dirname}/.swcrc`, 'utf-8')
);

// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves.
// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude"
if (swcJestConfig.swcrc === undefined) {
swcJestConfig.swcrc = false;
}

// Uncomment if using global setup/teardown files being transformed via swc
// https://nx.dev/nx-api/jest/documents/overview#global-setupteardown-with-nx-libraries
// jest needs EsModule Interop to find the default exported setup/teardown functions
// swcJestConfig.module.noInterop = false;

export default {
displayName: 'react-flex',
preset: '../../jest.preset.js',
transform: {
'^.+\\.[tj]s$': ['@swc/jest', swcJestConfig],
},
moduleFileExtensions: ['ts', 'js', 'html'],
testEnvironment: 'jsdom',
coverageDirectory: '../../coverage/packages/react-flex',
};
17 changes: 17 additions & 0 deletions packages/react-flex/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "@fluentui-contrib/react-flex",
"version": "0.0.1",
"dependencies": {
"@swc/helpers": "~0.5.11"
},
"main": "./src/index.js",
"typings": "./src/index.d.ts",
"private": true,
"peerDependencies": {
"@fluentui/react-components": ">=9.54.13 <10.0.0",
"@types/react": ">=16.8.0 <19.0.0",
"@types/react-dom": ">=16.8.0 <19.0.0",
"react": ">=16.8.0 <19.0.0",
"react-dom": ">=16.8.0 <19.0.0"
}
}
57 changes: 57 additions & 0 deletions packages/react-flex/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"name": "react-flex",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/react-flex/src",
"projectType": "library",
"tags": [],
"targets": {
"build": {
"executor": "@fluentui-contrib/nx-plugin:build"
},
"lint": {
"executor": "@nx/eslint:lint",
"options": {
"lintFilePatterns": [
"packages/react-flex/**/*.ts",
"packages/react-flex/**/*.tsx"
]
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "packages/react-flex/jest.config.ts",
"passWithNoTests": true
}
},
"type-check": {
"executor": "@fluentui-contrib/nx-plugin:type-check"
},
"storybook": {
"executor": "@nx/storybook:storybook",
"options": {
"port": 4400,
"configDir": "packages/react-flex/.storybook"
},
"configurations": {
"ci": {
"quiet": true
}
}
},
"build-storybook": {
"executor": "@nx/storybook:build",
"outputs": ["{options.outputDir}"],
"options": {
"outputDir": "dist/storybook/react-flex",
"configDir": "packages/react-flex/.storybook"
},
"configurations": {
"ci": {
"quiet": true
}
}
}
}
}
1 change: 1 addition & 0 deletions packages/react-flex/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
Empty file.
19 changes: 19 additions & 0 deletions packages/react-flex/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "../../tsconfig.base.json",
"files": [],
"compilerOptions": {
"jsx": "react"
},
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
},
{
"path": "./.storybook/tsconfig.json"
}
]
}
18 changes: 18 additions & 0 deletions packages/react-flex/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"declaration": true
},
"include": ["src/**/*.ts"],
"exclude": [
"jest.config.ts",
"src/**/*.test.ts",
"src/**/*.test.tsx",
"files/**",
"**/*.stories.ts",
"**/*.stories.js",
"**/*.stories.jsx",
"**/*.stories.tsx"
]
}
14 changes: 14 additions & 0 deletions packages/react-flex/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": [
"jest.config.ts",
"src/**/*.test.ts",
"src/**/*.test.tsx",
"src/**/*.d.ts"
]
}
1 change: 1 addition & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@fluentui-contrib/react-draggable-dialog": [
"packages/react-draggable-dialog/src/index.ts"
],
"@fluentui-contrib/react-flex": ["packages/react-flex/src/index.ts"],
"@fluentui-contrib/react-gamepad-navigation": [
"packages/react-gamepad-navigation/src/index.ts"
],
Expand Down