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

feat: adds support for non-default exported import remapping #115

Merged
merged 1 commit into from
Sep 17, 2024

Conversation

SimeonC
Copy link
Contributor

@SimeonC SimeonC commented Sep 17, 2024

This to support fixing our TableKit exports.

new ImportMassagerPlugin([
          {
            packageName: '@tablecheck/tablekit-react',
            importTransform: (importName) => {
              const importPath = tablekitEsmMap.get(importName);
              if (importPath) return importPath;
              const defaultImportPath = tablekitEsmMap.get('default');

              const startsWithKey = tablekitEsmMapKeys.find(
                (k) =>
                  importName.toLowerCase().startsWith(k.toLowerCase()) ||
                  `Variant${k}` === importName,
              );
              if (startsWithKey)
                return (
                  tablekitEsmMap.get(startsWithKey) ??
                  defaultImportPath ??
                  importName
                );
              return defaultImportPath ?? `/${importName}`;
            },
            exportTransform: (exportName, alias) =>
              alias ? `{${exportName} as ${alias}}` : `{ ${exportName} }`,
          },
          {
            transformPackages: ['@tablecheck'],
            packageName: '@tablecheck/tablekit-core',
            importTransform: getTkCoreImportPath,
            exportTransform: (exportName, alias) => {
              const importPath = getTkCoreImportPath(exportName);
              if (importPath.includes('/components/'))
                return `* as ${alias || exportName}`;
              return alias
                ? `{${exportName} as ${alias}}`
                : `{ ${exportName} }`;
            },
          },
        ])
📦 Published PR as canary version: Canary Versions

✨ Test out this PR locally via:

npm install @tablecheck/[email protected]
# or 
yarn add @tablecheck/[email protected]

@SimeonC SimeonC added the minor Increment the minor version when merged label Sep 17, 2024
Copy link

Unit Test Results

19 tests   19 ✔️  0s ⏱️
  1 suites    0 💤
  1 files      0

Results for commit c3dce47.

@SimeonC SimeonC enabled auto-merge (rebase) September 17, 2024 06:35
@SimeonC SimeonC merged commit b153dbf into main Sep 17, 2024
5 of 6 checks passed
@SimeonC SimeonC deleted the vite-plugin-support-transforming-non-default-exports branch September 17, 2024 06:57
@tablecheck-public-automation

🚀 PR was released in @tablecheck/[email protected] 🚀

@tablecheck-public-automation tablecheck-public-automation added the released This issue/pull request has been released. label Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor Increment the minor version when merged released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants