fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

tools: migrate-converged-pkg generator issues

Open Hotell opened this issue 3 years ago • 0 comments

While migrating all packages to use start-storybook I ran into various issues how things are setup. this issues is aggregate of tracking those

1. compat packages tsconfig.lib.json

  • compat packages are v9 packages that are used in v0 and v8, thus needs to compile to same ECMA target and generate AMD when necessary

incorrectly set to:

"compilerOptions": {
    "target": "ES2019",
    ...
}

should be:

 "target": "ES5",
    "lib": ["es5", "dom"],

2. *.mock file glob support

  • some packages use *.mock. file suffix to be used within tests for mocking purposes (react-dialog)

incorrectly set to :

tsconfig.lib.json

  "exclude": [
    "./src/common/**",
    "**/*.spec.ts",
    "**/*.spec.tsx",
-    "**/*.mock.ts",
-    "**/*.mock.tsx",

tsconfig.spec.json

  "include": [
    "**/*.spec.ts",
-    "**/*.mock.ts",
-   "**/*.mock.tsx",
    "**/*.spec.tsx",
    "**/*.test.ts",
    "**/*.test.tsx",
    "**/*.d.ts"
  ]

should be:

tsconfig.lib.json

  "exclude": [
    "./src/common/**",
    "**/*.spec.ts",
    "**/*.spec.tsx",
    "**/*.mock.ts",
    "**/*.mock.tsx",

tsconfig.spec.json

  "include": [
    "**/*.spec.ts",
    "**/*.mock.ts",
   "**/*.mock.tsx",
    "**/*.spec.tsx",
    "**/*.test.ts",
    "**/*.test.tsx",
    "**/*.d.ts"
  ]

3. .babelrc.json setup

  • if custom preset setup is present it is being overridden

incorrectly set to:

{
-  "presets": [["@griffel", { "modules": [{ "moduleSource": "@griffel/core", "importName": "makeStyles" }] }]],
+  "presets": ["@griffel"],
  "plugins": ["annotate-pure-calls", "@babel/transform-react-pure-annotations"]
}

should be:

{
  "presets": [["@griffel", { "modules": [{ "moduleSource": "@griffel/core", "importName": "makeStyles" }] }]],
  "plugins": ["annotate-pure-calls", "@babel/transform-react-pure-annotations"]
}

4. scope platform:web types setup

  • packages tagged as platform:web should not use node global types within tsconfig.lib.json

@fluentui/global-context us set as platform:web but uses internally global reference - thus needs to have node within types which doesn't adhere to our rules.

current logic:

"compilerOptions": {
-    "types": ["static-assets", "environment", "node"]
+   "types": ["static-assets", "environment"]
  },

topic to discuss: Should we mark these packages rather via platform:any and preserve custom types config ?

Hotell avatar Aug 09 '22 14:08 Hotell