Skip to content

Commit

Permalink
feat: add commonjs output format (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Jun 8, 2023
1 parent ee32541 commit a883514
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 12 deletions.
30 changes: 30 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
"name": "@capacitor-community/camera-preview",
"version": "5.0.0-0",
"description": "Camera preview",
"main": "dist/esm/index.js",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"unpkg": "dist/plugin.js",
"scripts": {
"build": "npm run clean && tsc",
"build": "npm run clean && tsc && rollup -c rollup.config.js",
"clean": "rimraf './dist'",
"watch": "tsc --watch",
"lint": "concurrently -g \"npm:eslint\" \"npm:prettier -- --check\" \"npm run swiftlint -- lint ios\"",
Expand All @@ -32,6 +34,7 @@
"prettier-plugin-java": "^1.6.1",
"pretty-quick": "^3.1.3",
"rimraf": "^3.0.2",
"rollup": "^2.79.1",
"swiftlint": "^1.0.1",
"typescript": "^4.3.2"
},
Expand Down
30 changes: 20 additions & 10 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
import nodeResolve from 'rollup-plugin-node-resolve';

export default {
input: 'dist/esm/index.js',
output: {
file: 'dist/plugin.js',
format: 'iife',
name: 'capacitorPlugin',
sourcemap: true,
},
plugins: [nodeResolve()],
};
output: [
{
file: 'dist/plugin.js',
format: 'iife',
name: 'capacitorSplashScreen',
globals: {
'@capacitor/core': 'capacitorExports',
},
sourcemap: true,
inlineDynamicImports: true,
},
{
file: 'dist/plugin.cjs.js',
format: 'cjs',
sourcemap: true,
inlineDynamicImports: true,
},
],
external: ['@capacitor/core'],
};

0 comments on commit a883514

Please sign in to comment.