Skip to content

Commit

Permalink
feat: add cjs support (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
RockiRider authored Nov 28, 2024
1 parent 779cc7e commit d31de58
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ jobs:
- name: Run Unit Tests
run: pnpm p:test

- name: Build Apps
run: pnpm build

- name: Install Playwright Browsers
run: npx playwright install --with-deps chromium

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/triage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ jobs:
run: pnpm p:build
- name: Run Unit Tests
run: pnpm p:test

- name: Build Apps
run: pnpm build

- name: Install Playwright Browsers
run: npx playwright install --with-deps chromium

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vite-csp",
"private": true,
"scripts": {
"build": "turbo build",
"build": "turbo build --filter=!docs --filter=!remix-spa --filter=!remix-app",
"p:build": "turbo build --filter=vite-plugin-csp-guard",
"p:test": "turbo test --filter=vite-plugin-csp-guard",
"dev": "turbo dev",
Expand Down
8 changes: 5 additions & 3 deletions packages/vite-plugin-csp-guard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
"url": "https://github.com/RockiRider/csp/issues"
},
"license": "GPL-3.0-only",
"main": "dist/index.js",
"module": "dist/index.js",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"exports": {
".": {
"import": "./dist/index.js"
"types": "./dist/index.d.ts",
"require": "./dist/index.cjs.js",
"import": "./dist/index.esm.js"
}
},
"types": "dist/index.d.ts",
Expand Down
19 changes: 13 additions & 6 deletions packages/vite-plugin-csp-guard/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@ import terser from "@rollup/plugin-terser";

export default defineConfig({
input: "src/index.ts", // Your plugin's entry point
output: {
file: "dist/index.js",
format: "esm", // Output as ES Module
sourcemap: false,
},
output: [
{
file: "dist/index.esm.js",
format: "esm", // Output as ES Module
sourcemap: false,
},
{
file: "dist/index.cjs.js",
format: "cjs", // Output as CommonJS
sourcemap: false,
},
],
external: ["lightningcss", "fsevents", "vite", "cheerio"],
plugins: [
typescript({
Expand All @@ -24,4 +31,4 @@ export default defineConfig({
commonjs(), // Converts commonjs to ES modules
terser(), // Minify
],
});
});

0 comments on commit d31de58

Please sign in to comment.