Skip to content

Commit

Permalink
Add nodeResolve plugin, adjust input and output paths, and add snakeC…
Browse files Browse the repository at this point in the history
…ase function.

Detailed description:
- Added the nodeResolve plugin to resolve dependencies
- Adjusted input and output paths in the Rollup configuration
- Implemented a snakeCase function for converting names
  • Loading branch information
Mearman committed Mar 7, 2024
1 parent 3961b90 commit 007c6fd
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 22 deletions.
12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,16 @@
"exports": {
".": {
"types": "./dist/index.d.ts",
"node": "./dist/index.cjs.js",
"browser": "./dist/index.iife.js",
"import": "./dist/index.esm.js",
"require": "./dist/index.cjs.js",
"default": "./dist/index.cjs.js",
"default": "./dist/index.umd.js",
"umd": "./dist/index.umd.js"
},
"./cjs": "./dist/index.cjs.js",
"./esm": "./dist/index.esm.js",
"./umd": "./dist/index.umd.js",
"./amd": "./dist/index.amd.js",
"./system": "./dist/index.system.js",
"./iife": "./dist/index.iife.js",
"./types": "./dist/index.d.ts",
"./umd": "./dist/index.umd.js"
"./cjs": "./dist/index.cjs.js"
},
"files": [
"dist"
Expand Down
44 changes: 29 additions & 15 deletions rollup.config.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,55 @@
import nodeResolve from "@rollup/plugin-node-resolve";
import typescript from "@rollup/plugin-typescript";
import { resolve } from "node:path";
import { defineConfig, Plugin, PluginContext } from "rollup";
import dts from "rollup-plugin-dts";
import pkg from "./package.json" assert { type: "json" };
import tsConfig from "./tsconfig.json" assert { type: "json" };

const production = !process.env.ROLLUP_WATCH;
const extensions = [".js", ".ts"];

export default defineConfig({
plugins: [
clean(),
dts({
compilerOptions: {
baseUrl: tsConfig.compilerOptions.baseUrl,
paths: tsConfig.compilerOptions.paths,
},
}),
nodeResolve({ preferBuiltins: true, extensions }),
typescript({
...tsConfig,
exclude: ["rollup.config.ts", "__tests__/**"],
sourceMap: !production,
inlineSources: !production,
}),
],
input: resolve("src", "index.ts"),
input: "src/index.ts",
output: [
{
file: resolve("dist", "index.cjs.js"),
format: "cjs",
file: "dist/index.cjs.js",
sourcemap: true,
},
{
file: resolve("dist", "index.esm.js"),
format: "es",
format: "esm",
file: "dist/index.esm.js",
sourcemap: true,
},
{
file: resolve("dist", "index.umd.js"),
format: "umd",
file: "dist/index.umd.js",
name: "unicode-tex-character-converter",
sourcemap: true,
},
{
format: "amd",
file: "dist/index.amd.js",
sourcemap: true,
},
{
format: "system",
file: "dist/index.system.js",
sourcemap: true,
},
{
file: resolve("dist", "index.iife.js"),
format: "iife",
file: "dist/index.iife.js",
name: snakeCase(pkg.name),
sourcemap: true,
},
],

Expand Down Expand Up @@ -83,3 +94,6 @@ export function clean(
},
};
}
function snakeCase(name: string): string {
return name.replace(/-/g, "_");
}

0 comments on commit 007c6fd

Please sign in to comment.