authhero 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # authhero
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Update the package to support both esm and cjs
8
+
3
9
  ## 0.1.0
4
10
 
5
11
  ### Minor Changes
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "authhero",
3
- "version": "0.1.0",
4
- "type": "module",
3
+ "version": "0.2.0",
5
4
  "main": "dist/index.js",
6
5
  "types": "dist/index.d.ts",
7
6
  "bin": {
package/vite.config.ts CHANGED
@@ -1,11 +1,41 @@
1
+ import path from "path";
1
2
  import { defineConfig } from "vite";
2
- import { resolve } from "path";
3
- import dts from "vite-plugin-dts";
4
3
 
5
- // https://vitejs.dev/config/
6
- export default defineConfig({
4
+ const getPackageName = () => {
5
+ return "authhero";
6
+ };
7
+
8
+ const getPackageNameCamelCase = () => {
9
+ try {
10
+ return getPackageName().replace(/-./g, (char) => char[1].toUpperCase());
11
+ } catch (err) {
12
+ throw new Error("Name property in package.json is missing.");
13
+ }
14
+ };
15
+
16
+ const fileName = {
17
+ es: `${getPackageName()}.mjs`,
18
+ cjs: `${getPackageName()}.cjs`,
19
+ iife: `${getPackageName()}.iife.js`,
20
+ };
21
+
22
+ const formats = Object.keys(fileName) as Array<keyof typeof fileName>;
23
+
24
+ module.exports = defineConfig({
25
+ base: "./",
7
26
  build: {
8
- lib: { entry: resolve(__dirname, "src/index.ts"), formats: ["es"] },
27
+ outDir: "./build/dist",
28
+ lib: {
29
+ entry: path.resolve(__dirname, "src/index.ts"),
30
+ name: getPackageNameCamelCase(),
31
+ formats,
32
+ fileName: (format) => fileName[format],
33
+ },
34
+ },
35
+ resolve: {
36
+ alias: [
37
+ { find: "@", replacement: path.resolve(__dirname, "src") },
38
+ { find: "@@", replacement: path.resolve(__dirname) },
39
+ ],
9
40
  },
10
- plugins: [dts()],
11
41
  });