Skip to content

refactor: Add webawesome and lit as external dependencies#157

Merged
spwoodcock merged 3 commits intomainfrom
151-its-still-not-exactly-clear-to-me-how-we-use-the-lib-alongside-web
Oct 29, 2025
Merged

refactor: Add webawesome and lit as external dependencies#157
spwoodcock merged 3 commits intomainfrom
151-its-still-not-exactly-clear-to-me-how-we-use-the-lib-alongside-web

Conversation

@tbssnch
Copy link
Copy Markdown
Collaborator

@tbssnch tbssnch commented Oct 28, 2025

Add external peer dependencies to build configuration

Adds @awesome.me/webawesome and lit as external dependencies in the esbuild configuration to prevent bundling them into the library output. This ensures peer dependencies are resolved from the consuming application's node_modules rather than being bundled.

Testing Steps

1. Run a clean build:

rm -rf dist node_modules
pnpm install
pnpm build
  • Verify that build completes without errors
  • Check that @awesome.me/webawesome and lit are not included in the bundle. (Imports should be preserved)

2. Local consumption test

In the consumer package.json add:

  {
    "dependencies": {
      "@awesome.me/webawesome": "3.0.0-beta.1",
      "@hotosm/ui": "link:../ui",
      "lit": "3.3.1"
    }
  }

Install:

pnpm install

In vite.config.ts add:

  resolve: {
    dedupe: ['@awesome.me/webawesome', 'lit'],
  },

This should only be necessary when testing linking the library locally. This is one of the reasons I think that we should do a staging deploy for additional testing before merging into main.

Start the consumer and verify that the library is working as expected. Open the console and check that errors are no longer showing as before.

Notes: The main changes to the code are the ones in build.js and the package.json. There is a lot of noise after running a build with the changes made.

I did notice some changes included to some of the chunks from the refactor in the last PR that was merged. That is my fault for not running another build after making those changes in the last PR so I went ahead and kept those in there.

…ndling peer dependencies into the library output
Copy link
Copy Markdown
Member

@spwoodcock spwoodcock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this suggestion & implementing it!

Sounds like a great way forward to me 😁

Just checking, does lit need to be a peerDep, or can that be a devDep here?

If the consuming app uses the built js, then Lit won't be needed. But I guess if it imports the ts components then it will need Lit installed - is this right? (not ideal, but I guess it can work)

@spwoodcock spwoodcock merged commit 3d4a2fa into main Oct 29, 2025
1 of 2 checks passed
@spwoodcock spwoodcock deleted the 151-its-still-not-exactly-clear-to-me-how-we-use-the-lib-alongside-web branch October 29, 2025 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants