-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(clerk-react): ESM bundle with vite / rollup
- Loading branch information
Showing
4 changed files
with
30 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@clerk/clerk-react': minor | ||
--- | ||
|
||
Fix `@clerk/clerk-react` bundle output to resolve issues with vite / rollup ESM module imports. | ||
We have also used the `bundle` output to export a single index.ts and dropped the unnecessary | ||
published files / folders (eg `__tests__`). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,31 @@ | ||
import type { Options } from 'tsup'; | ||
import { defineConfig } from 'tsup'; | ||
|
||
import { runAfterLast } from '../../scripts/utils'; | ||
// @ts-expect-error for `import module with '.json' extension` | ||
import { version as clerkJsVersion } from '../clerk-js/package.json'; | ||
// @ts-expect-error for `import module with '.json' extension` | ||
import { name, version } from './package.json'; | ||
|
||
export default defineConfig(overrideOptions => { | ||
const isWatch = !!overrideOptions.watch; | ||
const shouldPublish = !!overrideOptions.env?.publish; | ||
|
||
const common: Options = { | ||
entry: ['./src/**/*.{ts,tsx,js,jsx}', '!./src/**/*.test.{ts,tsx}'], | ||
bundle: false, | ||
return { | ||
entry: { | ||
index: 'src/index.ts', | ||
}, | ||
onSuccess: shouldPublish ? 'npm run publish:local' : undefined, | ||
format: ['cjs', 'esm'], | ||
bundle: true, | ||
clean: true, | ||
minify: false, | ||
sourcemap: true, | ||
legacyOutput: true, | ||
dts: true, | ||
external: ['react', 'react-dom'], | ||
define: { | ||
PACKAGE_NAME: `"${name}"`, | ||
PACKAGE_VERSION: `"${version}"`, | ||
JS_PACKAGE_VERSION: `"${clerkJsVersion}"`, | ||
__DEV__: `${isWatch}`, | ||
}, | ||
}; | ||
|
||
const esm: Options = { | ||
...common, | ||
format: 'esm', | ||
}; | ||
|
||
const cjs: Options = { | ||
...common, | ||
format: 'cjs', | ||
outDir: './dist/cjs', | ||
}; | ||
|
||
return runAfterLast(['npm run build:declarations', shouldPublish && 'npm run publish:local'])(esm, cjs); | ||
}); |