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:
-
Install the dependencies:
pnpm install
-
Build
@ttoss/config
package:pnpm build:config
-
Build i18n languages (for more information, see @ttoss/i18n-cli:
pnpm turbo run i18n
-
Run the Storybook:
pnpm storybook
If everything goes well, you should see the Storybook running in your browser.
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.
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"
}
}
}
}
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.
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
.