popeindustries / lit

Fast server-rendering and client-hydration of lit-html templates and web components
MIT License
33 stars 4 forks source link

Fix types for vendored files #11

Closed popeindustries closed 1 year ago

popeindustries commented 2 years ago

It seems that TypeScript 4.8 isn't yet able to resolve aliased package.json#exports entries (Node/dvlp/esbuild are able to). This fix autogenerates alias files to ensure that TypeScript is able to resolve the modules correctly.

Fixes #10

changeset-bot[bot] commented 2 years ago

🦋 Changeset detected

Latest commit: d2b2144ceaa21ad5718d9d58b9e53583bf1f232a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages | Name | Type | | --------------------------- | ----- | | @popeindustries/lit-element | Patch | | @popeindustries/lit-html | Patch | | @popeindustries/lit | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

knuthaug commented 1 year ago

I really don't understand why, but 1.0.5 (lit-html@5.0.3, lit-html-server@5.0.3) gives the exact same errors as 1.0.4, event though it worked when linking this branch. When bundling I get:

 {
      detail: undefined,
      id: '',
      location: {
        column: 14,
        file: 'node_modules/.pnpm/@popeindustries+lit@1.0.5/node_modules/@popeindustries/lit/directives/unsafe-html.js',
        length: 52,
        line: 1,
        lineText: "export * from '@popeindustries/lit-html/directives/unsafe-html.js';",
        namespace: '',
        suggestion: ''
      },
      notes: [
        {
          location: {
            column: 17,
            file: 'node_modules/.pnpm/@popeindustries+lit@1.0.5/node_modules/@popeindustries/lit-html/package.json',
            length: 16,
            line: 54,
            lineText: '      "default": "./directives/*"',
            namespace: '',
            suggestion: ''
          },
          text: 'The module "./directives/unsafe-html.js" was not found on the file system:'
        }

Which leads me to suspect that it is the wildcard export in lit-html that needs splitting into individual exports? Or is there a release of lit-html and lit-html-server planned also?

popeindustries commented 1 year ago

@knuthaug so TypeScript is happy, but Rollup (or esbuild?) isn't?

knuthaug commented 1 year ago

no, typescript isn't happy either.

import { unsafeHTML } from '@popeindustries/lit/directives/unsafe-html.js';

gives

Module '"@popeindustries/lit/directives/unsafe-html"' has no exported member 'unsafeHTML'.ts(2305)

typescript@4.8.3