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

chore: Set packages' "main" to src/index locally to help type resolution #2253

Open
wants to merge 3 commits into
base: master
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
8 changes: 3 additions & 5 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->


- [Getting started](#getting-started)
- [Useful Commands](#useful-commands)
- [Workflow](#workflow)
Expand Down Expand Up @@ -153,10 +152,7 @@ These changes are required to setup internal tooling and package publishing.
- "files": [
- "lib"
- ],
+ "jsnext:main": "dist/es/index.js",
+ "main": "dist/commonjs/index.js",
+ "module": "dist/es/index.js",
+ "types": "dist/es/index.d.ts",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These entries are cruft?

+ "main": "src/index.ts",
+ "sideEffects": false,
+ "files": [
+ "dist"
Expand All @@ -174,6 +170,8 @@ These changes are required to setup internal tooling and package publishing.

You can also use `gulp bundle:package` to bundle your package with UMD.

The `main` field is locally set to point to the source to help project references work. It will be updated before publish to point to `dist/commonjs/index.js`. `module` and `jsnext:main` (`dist/es/index.js`) and `types` (`dist/es/index.d.ts`) will also be added. See `scripts/tasks/publishPrepareTask.ts` for details. (Having `types` present earlier with its final value causes problems resolving project references.)

#### Create `tsconfig.json`

If your package uses TypeScript, please also create a new `tsconfig.json` and place it in `packages/__DIRECTORY_NAME__`. An example config:
Expand Down
8 changes: 0 additions & 8 deletions build/tsconfig.common.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@
"module": "commonjs",
"target": "es5",
"lib": ["es2015", "dom"],
"baseUrl": "../",
"paths": {
"@fluentui/docs": ["docs"],
"@fluentui/e2e": ["e2e"],
"@fluentui/internal-tooling": ["build"],
"@fluentui/perf": ["perf"],
"@fluentui/*": ["packages/*/src"]
},
"types": ["node", "jest"],
"typeRoots": ["../types", "../node_modules/@types"],
"jsx": "react",
Expand Down
15 changes: 13 additions & 2 deletions build/tsconfig.docs.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
{
"extends": "./tsconfig.common.json",
"compilerOptions": {
// "composite": true,
"module": "esnext",
"baseUrl": "../",
"paths": {
"@fluentui/*": ["packages/*/src"],
"docs/*": ["docs/*"],
"src/*": ["packages/react/src/*"],
"test/*": ["packages/react/test/*"]
}
},
"include": ["../docs/src", "../packages/react/src", "../types"]
"include": ["../docs/src", "../types"]
// "references": [
// { "path": "../packages/ability-attributes" },
// { "path": "../packages/accessibility" },
// { "path": "../packages/code-sandbox" },
// { "path": "../packages/docs-components" },
// { "path": "../packages/react" },
// { "path": "../packages/react-component-event-listener" },
// { "path": "../packages/react-component-ref" },
// { "path": "../packages/styles" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments there are cruft?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, I'll remove or uncomment this before checkin. I was curious if docs could build with project references but I'm not done testing yet.

// ]
}
5 changes: 3 additions & 2 deletions build/tsconfig.e2e.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "./tsconfig.common.json",
"compilerOptions": {
"module": "esnext"
"module": "esnext",
"allowSyntheticDefaultImports": true
},
"include": ["../packages/react/src", "../e2e", "../types"]
"include": ["../e2e", "../types"]
}
7 changes: 0 additions & 7 deletions build/tsconfig.test.json

This file was deleted.

8 changes: 8 additions & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
"private": true,
"license": "MIT",
"dependencies": {
"@fluentui/ability-attributes": "^0.43.0",
"@fluentui/accessibility": "^0.43.0",
"@fluentui/code-sandbox": "^0.43.0",
"@fluentui/docs-components": "^0.43.0",
"@fluentui/react": "^0.43.0",
"@fluentui/react-component-event-listener": "^0.43.0",
"@fluentui/react-component-ref": "^0.43.0",
"@fluentui/styles": "^0.43.0",
"color": "^3.1.0",
"copy-to-clipboard": "^3.2.0",
"faker": "^4.1.0",
Expand Down
7 changes: 1 addition & 6 deletions e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
{
"extends": "../build/tsconfig.common.json",
"compilerOptions": {
"module": "esnext",
"allowSyntheticDefaultImports": true
},
"include": ["../packages/react/src", "../e2e", "../types"]
"extends": "../build/tsconfig.e2e.json"
}
4 changes: 4 additions & 0 deletions just.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { task } from 'just-scripts'
import { publishPrepareTask } from './scripts/tasks/publishPrepareTask'

task('publish:prepare', publishPrepareTask)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"prettier:fix": "prettier --write \"**/*.{ts,tsx}\"",
"precommit": "lint-staged",
"postcommit": "git update-index --again",
"prerelease": "yarn ci && cross-env NODE_ENV=production yarn build",
"prerelease": "yarn ci && cross-env NODE_ENV=production yarn build && just-scripts publish:prepare",
"postrelease": "yarn deploy:docs",
"release:major": "yarn prerelease && lerna publish major && yarn postrelease",
"release:minor": "yarn prerelease && lerna publish minor && yarn postrelease",
Expand Down
7 changes: 2 additions & 5 deletions packages/ability-attributes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
"dist"
],
"homepage": "https://github.com/microsoft/fluent-ui-react/tree/master/packages/ability-attributes",
"jsnext:main": "dist/es/index.js",
"license": "MIT",
"main": "dist/commonjs/index.js",
"module": "dist/es/index.js",
"main": "src/index.ts",
"publishConfig": {
"access": "public"
},
Expand All @@ -27,6 +25,5 @@
"clean": "gulp bundle:package:clean",
"schema": "allyschema -c \"process.env.NODE_ENV !== 'production'\" schema.json > ./src/schema.ts"
},
"sideEffects": false,
"types": "dist/es/index.d.ts"
"sideEffects": false
}
7 changes: 2 additions & 5 deletions packages/accessibility/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
"dist"
],
"homepage": "https://github.com/microsoft/fluent-ui-react/tree/master/packages/accessibility",
"jsnext:main": "dist/es/index.js",
"license": "MIT",
"main": "dist/commonjs/index.js",
"module": "dist/es/index.js",
"main": "src/index.ts",
"publishConfig": {
"access": "public"
},
Expand All @@ -31,6 +29,5 @@
"test": "gulp test",
"test:watch": "gulp test:watch"
},
"sideEffects": false,
"types": "dist/es/index.d.ts"
"sideEffects": false
}
7 changes: 2 additions & 5 deletions packages/code-sandbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
"dist"
],
"homepage": "https://github.com/microsoft/fluent-ui-react/tree/master/packages/code-sandbox",
"jsnext:main": "dist/es/index.js",
"license": "MIT",
"main": "dist/commonjs/index.js",
"module": "dist/es/index.js",
"main": "src/index.ts",
"peerDependencies": {
"@fluentui/react": "*",
"react": "^16.8.0",
Expand All @@ -31,6 +29,5 @@
"build": "gulp bundle:package:no-umd",
"clean": "gulp bundle:package:clean"
},
"sideEffects": false,
"types": "dist/es/index.d.ts"
"sideEffects": false
}
2 changes: 1 addition & 1 deletion packages/digest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@fluentui/digest",
"version": "0.43.0",
"private": true,
"main": "lib/digest.js",
"main": "src/digest.ts",
"module": "lib/digest.js",
"license": "MIT",
"bin": {
Expand Down
3 changes: 2 additions & 1 deletion packages/digest/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"compilerOptions": {
"composite": true,
"outDir": "lib",
"lib": ["es2015", "dom"],
"jsx": "react",
"moduleResolution": "node",
"declaration": true,
"skipLibCheck": true,
"types": ["node", "react"],
"types": ["node"],
"baseUrl": ".",
"allowSyntheticDefaultImports": true,
"paths": {
Expand Down
7 changes: 2 additions & 5 deletions packages/docs-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
"dist"
],
"homepage": "https://github.com/microsoft/fluent-ui-react/tree/master/packages/docs-components",
"jsnext:main": "dist/es/index.js",
"license": "MIT",
"main": "dist/commonjs/index.js",
"module": "dist/es/index.js",
"main": "src/index.ts",
"peerDependencies": {
"prettier": "^1.19.1",
"react": "^16.8.0",
Expand All @@ -32,6 +30,5 @@
"build": "gulp bundle:package:no-umd",
"clean": "gulp bundle:package:clean"
},
"sideEffects": false,
"types": "dist/es/index.d.ts"
"sideEffects": false
}
3 changes: 2 additions & 1 deletion packages/perf-test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"extends": "../../build/tsconfig.docs.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "lib",
"types": ["node", "jest", "expect-puppeteer", "jest-environment-puppeteer"]
},
"include": ["src"],
"references": []
"references": [{ "path": "../digest" }]
}
7 changes: 2 additions & 5 deletions packages/react-bindings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
"dist"
],
"homepage": "https://github.com/microsoft/fluent-ui-react/tree/master/packages/react-bindings",
"jsnext:main": "dist/es/index.js",
"license": "MIT",
"main": "dist/commonjs/index.js",
"module": "dist/es/index.js",
"main": "src/index.ts",
"peerDependencies": {
"react": "^16.8.0",
"react-dom": "^16.8.0"
Expand All @@ -39,6 +37,5 @@
"test": "gulp test",
"test:watch": "gulp test:watch"
},
"sideEffects": false,
"types": "dist/es/index.d.ts"
"sideEffects": false
}
8 changes: 1 addition & 7 deletions packages/react-bindings/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,5 @@
"strictNullChecks": true
},
"include": ["src", "test"],
"references": [
{ "path": "../accessibility" },
{ "path": "../state" },
{ "path": "../styles" },
{ "path": "../react-component-event-listener" },
{ "path": "../react-component-ref" }
]
"references": [{ "path": "../accessibility" }, { "path": "../state" }, { "path": "../styles" }]
}
7 changes: 2 additions & 5 deletions packages/react-component-event-listener/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
"dist"
],
"homepage": "https://github.com/microsoft/fluent-ui-react/tree/master/packages/react-component-event-listener",
"jsnext:main": "dist/es/index.js",
"license": "MIT",
"main": "dist/commonjs/index.js",
"module": "dist/es/index.js",
"main": "src/index.ts",
"peerDependencies": {
"react": "^16.8.0",
"react-dom": "^16.8.0"
Expand All @@ -34,6 +32,5 @@
"test": "gulp test",
"test:watch": "gulp test:watch"
},
"sideEffects": false,
"types": "dist/es/index.d.ts"
"sideEffects": false
}
7 changes: 2 additions & 5 deletions packages/react-component-nesting-registry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
"dist"
],
"homepage": "https://github.com/microsoft/fluent-ui-react/tree/master/packages/react-component-nesting-registry",
"jsnext:main": "dist/es/index.js",
"license": "MIT",
"main": "dist/commonjs/index.js",
"module": "dist/es/index.js",
"main": "src/index.ts",
"peerDependencies": {
"react": "^16.8.0",
"react-dom": "^16.8.0"
Expand All @@ -34,6 +32,5 @@
"test": "gulp test",
"test:watch": "gulp test:watch"
},
"sideEffects": false,
"types": "dist/es/index.d.ts"
"sideEffects": false
}
7 changes: 2 additions & 5 deletions packages/react-component-ref/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
"dist"
],
"homepage": "https://github.com/microsoft/fluent-ui-react/tree/master/packages/react-component-ref",
"jsnext:main": "dist/es/index.js",
"license": "MIT",
"main": "dist/commonjs/index.js",
"module": "dist/es/index.js",
"main": "src/index.ts",
"peerDependencies": {
"react": "^16.8.0",
"react-dom": "^16.8.0"
Expand All @@ -36,6 +34,5 @@
"test": "gulp test",
"test:watch": "gulp test:watch"
},
"sideEffects": false,
"types": "dist/es/index.d.ts"
"sideEffects": false
}
7 changes: 2 additions & 5 deletions packages/react-proptypes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
"dist"
],
"homepage": "https://github.com/microsoft/fluent-ui-react/tree/master/packages/react-proptypes",
"jsnext:main": "dist/es/index.js",
"license": "MIT",
"main": "dist/commonjs/index.js",
"module": "dist/es/index.js",
"main": "src/index.ts",
"publishConfig": {
"access": "public"
},
Expand All @@ -31,6 +29,5 @@
"test": "gulp test",
"test:watch": "gulp test:watch"
},
"sideEffects": false,
"types": "dist/es/index.d.ts"
"sideEffects": false
}
7 changes: 2 additions & 5 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@
"dist"
],
"homepage": "https://github.com/microsoft/fluent-ui-react#readme",
"jsnext:main": "dist/es/index.js",
"license": "MIT",
"main": "dist/commonjs/index.js",
"module": "dist/es/index.js",
"main": "src/index.ts",
"peerDependencies": {
"react": "^16.8.0",
"react-dom": "^16.8.0"
Expand All @@ -57,6 +55,5 @@
"test": "gulp test",
"test:watch": "gulp test:watch"
},
"sideEffects": false,
"types": "dist/es/index.d.ts"
"sideEffects": false
}
Loading