Skip to content

Latest commit

 

History

History
85 lines (59 loc) · 3.32 KB

README.md

File metadata and controls

85 lines (59 loc) · 3.32 KB

ttoss - Terezinha Tech Operations

Getting Started

The "hello world" of this repository is running ttoss Storybook in your local machine. To do so, clone the repository and run the following commands on the root folder:

  1. Install the dependencies:

    pnpm install
  2. Build @ttoss/config package:

    pnpm build:config
  3. Build i18n languages (for more information, see @ttoss/i18n-cli:

    pnpm turbo run i18n
  4. Run the Storybook:

    pnpm storybook

If everything goes well, you should see the Storybook running in your browser.

FAQ

Why doesn't packages/config have a build script?

It doesn't have a build script because its build cannot be done at the same time as the other packages. The other packages use @ttoss/config package on their configuration files. As the build command on turbo.json is executed in parallel, it may happen that the other packages are built before @ttoss/config package, which would cause an error because the other packages would try to use @ttoss/config package before it was built.

Do I need to build packages before importing them?

No. We use the exports field to specify the package entry points of the packages and point them to the src folder. For example,

{
  "exports": {
    ".": "./src/index.ts"
  }
}

Furthermore, we configure publishConfig to point to the dist folder, so when we publish the package, it will be published pointing to the dist folder, which contains the built files.

{
  "publishConfig": {
    "exports": {
      ".": {
        "import": "./dist/esm/index.js",
        "require": "./dist/index.js",
        "types": "./dist/index.d.ts"
      }
    }
  }
}

Why does i18n command on turbo.json depend on ^build?

The i18n command depends on ^build because it uses the @ttoss/i18n-cli package to extract the translations from the source code and generate the translation files, so it needs to be built before running the i18n command. You can't add @ttoss/i18n-cli#build as a dependency of i18n because it would create a circular dependency.

Why doesn't TypeScript find components from ttoss libs?

With the introduction of the new --moduleResolution bundler, TypeScript 4.7+ supports resolution features that can be interpreted natively by TypeScript, allowing exports and imports to be enabled and disabled in package.json. Because ttoss libraries use exports as package entry points, you need to set moduleResolution as bundler in your project tsconfig.json if it uses webpack, rollup, or other bundlers:

{
    "compilerOptions": {
        "target": "esnext",
        "moduleResolution": "bundler"
    }
}

If your application uses Node.js without a bundler, set moduleResolution to NodeNext.