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

setup repository structure, path, env configs and convention #57

Open
debuggingfuture opened this issue Dec 19, 2024 — with Huly for GitHub · 0 comments
Open

Comments

Copy link
Member

debuggingfuture commented Dec 19, 2024

This issue is to keep track of various considerations, will be closed once concluded with documentations

(WIP)

Background

  • current development (storybook, vitest) make use of vite config, which default to use import.meta.env and expect env variables prefixed e.g. VITE_

Our take

ESM

  • we do not intend to publish most components as library, we do not bundle and transpile to cjs
  • we prefer to structure components as just in time package as we have no intention to export, so as to benefit perf by avoiding intermediate build step
  • We should support the end-application to decide given their own bundler, which for now we don't support application that do not support import / esm

path alias

	"imports": {
		"#*": ["./src/*", "./src/*.tsx"]
	},

IDE config

This is expected for auto import to work.

  • includePackageJsonAutoImports is to trade off performance for full search on paths for all internal packages, so as to support wildcard import

  • importModuleSpecifierEnding is to avoid automatically adding .js extension, , although in practice we find it a bit fuzzy

	"typescript.preferences.includePackageJsonAutoImports": "on",
	"typescript.preferences.importModuleSpecifierEnding": "minimal",

Env config

  • As we try to be agnostic and align common convention

  • we support .env

  • avoid the vite convention of import.meta.env and stick with process.env

  • to achieve this, we have

    1. explicit define process.env https://vite.dev/config/
    2. use loadEnv at vite to load env onto storybook and tests
  • we prefer to name space env variables, and for now we use canonical util config at packages/domain/src/config.ts

  • avoid loading environment directly at components / libs (e.g. process.env) and always prefer injecting config

Huly®: DAPPK-58

Vite config

  • support project root config
    https://vite.dev/config/#configuring-vite

  • vite config need to be customize for dom based testing at storybook / ui-react packages

    • for now we install related dependencies at root
This was referenced Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant