Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Take a different approach to exporting modules #199

Merged
merged 9 commits into from May 21, 2022
Merged

Take a different approach to exporting modules #199

merged 9 commits into from May 21, 2022

Conversation

pepicrft
Copy link
Owner

What?

This is the first PR of some to follow to shift our approach to how we export modules with the aim to improve the developer ergonomics contributing to this project. In a nutshell, we are moving from imports like:

import { path } from "@gestaltjs/core/cli"

To

import { relativizePath } from "@gestaltjs/core/node/cli"

Why?

Until now, we exported all the public modules through an index.ts module. While that works, it makes mocking inconvenient because a mocking of @gestaltjs/core through Vitest mocks all the modules that are exported through it.

How?

  • Adjusted the Rollup configuration file of @gestaltjs/core to output the files suffixed as .public.ts under src/node
  • Adjusted the Typescript paths to resolve imports in development.
  • Added a new entry to the exports section of core's package.json.

Testing?

A passing CI should make us feel confidence this change hasn't broken anything. Alternatively, you can run pnpm run build in the core directory.

Anything Else? (optional)

Once this PR is merged, I'll continue with the other modules. I'll take the opportunity to revisit the APIs and document modules that lack documentation.

@pepicrft pepicrft self-assigned this May 20, 2022
@netlify
Copy link

netlify bot commented May 20, 2022

Deploy Preview for gestaltjs ready!

Name Link
🔨 Latest commit 7e56d6a
🔍 Latest deploy log https://app.netlify.com/sites/gestaltjs/deploys/628914dc5804600008da4cf6
😎 Deploy Preview https://deploy-preview-199--gestaltjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@pepicrft pepicrft merged commit 035fb5d into main May 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant