Skip to content

Commit a883514

Browse files
authored
feat: add commonjs output format (#287)
1 parent ee32541 commit a883514

File tree

3 files changed

+55
-12
lines changed

3 files changed

+55
-12
lines changed

package-lock.json

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
"name": "@capacitor-community/camera-preview",
33
"version": "5.0.0-0",
44
"description": "Camera preview",
5-
"main": "dist/esm/index.js",
5+
"main": "dist/plugin.cjs.js",
6+
"module": "dist/esm/index.js",
67
"types": "dist/esm/index.d.ts",
8+
"unpkg": "dist/plugin.js",
79
"scripts": {
8-
"build": "npm run clean && tsc",
10+
"build": "npm run clean && tsc && rollup -c rollup.config.js",
911
"clean": "rimraf './dist'",
1012
"watch": "tsc --watch",
1113
"lint": "concurrently -g \"npm:eslint\" \"npm:prettier -- --check\" \"npm run swiftlint -- lint ios\"",
@@ -32,6 +34,7 @@
3234
"prettier-plugin-java": "^1.6.1",
3335
"pretty-quick": "^3.1.3",
3436
"rimraf": "^3.0.2",
37+
"rollup": "^2.79.1",
3538
"swiftlint": "^1.0.1",
3639
"typescript": "^4.3.2"
3740
},

rollup.config.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1-
import nodeResolve from 'rollup-plugin-node-resolve';
2-
31
export default {
42
input: 'dist/esm/index.js',
5-
output: {
6-
file: 'dist/plugin.js',
7-
format: 'iife',
8-
name: 'capacitorPlugin',
9-
sourcemap: true,
10-
},
11-
plugins: [nodeResolve()],
12-
};
3+
output: [
4+
{
5+
file: 'dist/plugin.js',
6+
format: 'iife',
7+
name: 'capacitorSplashScreen',
8+
globals: {
9+
'@capacitor/core': 'capacitorExports',
10+
},
11+
sourcemap: true,
12+
inlineDynamicImports: true,
13+
},
14+
{
15+
file: 'dist/plugin.cjs.js',
16+
format: 'cjs',
17+
sourcemap: true,
18+
inlineDynamicImports: true,
19+
},
20+
],
21+
external: ['@capacitor/core'],
22+
};

0 commit comments

Comments
 (0)