@donmahallem/rollup-config 0.7.0 → 0.8.2
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/dist/cjs/base-config.js +68 -0
- package/dist/cjs/base-config.js.map +1 -0
- package/dist/cjs/dts-config.js +22 -0
- package/dist/cjs/dts-config.js.map +1 -0
- package/dist/cjs/index.js +7 -64
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/partial-pkg.js +7 -0
- package/dist/cjs/partial-pkg.js.map +1 -0
- package/dist/cjs/replace-config.js +24 -0
- package/dist/cjs/replace-config.js.map +1 -0
- package/dist/esm/base-config.js +61 -0
- package/dist/esm/base-config.js.map +1 -0
- package/dist/esm/dts-config.js +15 -0
- package/dist/esm/dts-config.js.map +1 -0
- package/dist/esm/index.js +3 -61
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/partial-pkg.js +6 -0
- package/dist/esm/partial-pkg.js.map +1 -0
- package/dist/esm/replace-config.js +17 -0
- package/dist/esm/replace-config.js.map +1 -0
- package/dist/types/base-config.d.ts +24 -0
- package/dist/types/base-config.d.ts.map +1 -0
- package/dist/types/dts-config.d.ts +8 -0
- package/dist/types/dts-config.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -41
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/partial-pkg.d.ts +20 -0
- package/dist/types/partial-pkg.d.ts.map +1 -0
- package/dist/types/replace-config.d.ts +7 -0
- package/dist/types/replace-config.d.ts.map +1 -0
- package/package.json +6 -6
- package/src/base-config.spec.ts +24 -0
- package/src/base-config.ts +86 -0
- package/src/dts-config.ts +22 -0
- package/src/index.spec.ts +0 -8
- package/src/index.ts +3 -97
- package/src/partial-pkg.ts +16 -0
- package/src/replace-config.ts +20 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Package @donmahallem/rollup-config
|
|
4
|
+
* Source https://donmahallem.github.io/js-libs/
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.baseConfig = void 0;
|
|
11
|
+
const plugin_commonjs_1 = __importDefault(require("@rollup/plugin-commonjs"));
|
|
12
|
+
const plugin_json_1 = __importDefault(require("@rollup/plugin-json"));
|
|
13
|
+
const plugin_node_resolve_1 = __importDefault(require("@rollup/plugin-node-resolve"));
|
|
14
|
+
const plugin_typescript_1 = __importDefault(require("@rollup/plugin-typescript"));
|
|
15
|
+
const replace_config_1 = require("./replace-config");
|
|
16
|
+
const baseConfig = (pkg, cfg = {}) => {
|
|
17
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
18
|
+
const output = [];
|
|
19
|
+
if (pkg.main && ((_a = cfg === null || cfg === void 0 ? void 0 : cfg.output) === null || _a === void 0 ? void 0 : _a.cjs) !== false) {
|
|
20
|
+
output.push({
|
|
21
|
+
file: pkg.main,
|
|
22
|
+
footer: '// BUILD: __BUILD_DATE__\n\n',
|
|
23
|
+
format: 'cjs',
|
|
24
|
+
preferConst: true,
|
|
25
|
+
sourcemap: true,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
if (pkg.module && ((_b = cfg === null || cfg === void 0 ? void 0 : cfg.output) === null || _b === void 0 ? void 0 : _b.esm) !== false) {
|
|
29
|
+
output.push({
|
|
30
|
+
file: pkg.module,
|
|
31
|
+
footer: '// BUILD: __BUILD_DATE__\n\n',
|
|
32
|
+
format: 'esm',
|
|
33
|
+
preferConst: true,
|
|
34
|
+
sourcemap: true,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const plugins = [
|
|
38
|
+
(0, plugin_node_resolve_1.default)(((_c = cfg.plugins) === null || _c === void 0 ? void 0 : _c.nodeResolve) || {
|
|
39
|
+
preferBuiltins: true,
|
|
40
|
+
}),
|
|
41
|
+
(0, plugin_typescript_1.default)({
|
|
42
|
+
tsconfig: cfg.tsconfig || './tsconfig.json',
|
|
43
|
+
}),
|
|
44
|
+
];
|
|
45
|
+
if (((_d = cfg.plugins) === null || _d === void 0 ? void 0 : _d.commonjs) !== false) {
|
|
46
|
+
plugins.push((0, plugin_commonjs_1.default)((_e = cfg.plugins) === null || _e === void 0 ? void 0 : _e.commonjs));
|
|
47
|
+
}
|
|
48
|
+
if (((_f = cfg.plugins) === null || _f === void 0 ? void 0 : _f.json) !== false) {
|
|
49
|
+
plugins.push((0, plugin_json_1.default)(((_g = cfg.plugins) === null || _g === void 0 ? void 0 : _g.json) || {
|
|
50
|
+
compact: true,
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
plugins.push((0, replace_config_1.setupReplacePlugin)(pkg));
|
|
54
|
+
return {
|
|
55
|
+
external: [
|
|
56
|
+
...Object.keys(pkg.dependencies || {}),
|
|
57
|
+
...Object.keys(pkg.devDependencies || {}),
|
|
58
|
+
...Object.keys(pkg.peerDependencies || {}),
|
|
59
|
+
...Object.keys(pkg.optionalDependencies || {}),
|
|
60
|
+
],
|
|
61
|
+
input: 'src/index.ts',
|
|
62
|
+
output,
|
|
63
|
+
plugins,
|
|
64
|
+
preserveSymlinks: true,
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
exports.baseConfig = baseConfig;
|
|
68
|
+
//# sourceMappingURL=base-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-config.js","sourceRoot":"","sources":["../../src/base-config.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,8EAA0E;AAC1E,sEAA8D;AAC9D,sFAAoF;AACpF,kFAAmD;AAGnD,qDAAsD;AAmB/C,MAAM,UAAU,GAAG,CAAC,GAAoB,EAAE,MAAe,EAAE,EAAiB,EAAE;;IACjF,MAAM,MAAM,GAAoB,EAAE,CAAC;IACnC,IAAI,GAAG,CAAC,IAAI,IAAI,CAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,MAAM,0CAAE,GAAG,MAAK,KAAK,EAAE;QACxC,MAAM,CAAC,IAAI,CAAC;YACR,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,MAAM,EAAE,8BAA8B;YACtC,MAAM,EAAE,KAAK;YACb,WAAW,EAAE,IAAI;YACjB,SAAS,EAAE,IAAI;SAClB,CAAC,CAAC;KACN;IACD,IAAI,GAAG,CAAC,MAAM,IAAI,CAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,MAAM,0CAAE,GAAG,MAAK,KAAK,EAAE;QAC1C,MAAM,CAAC,IAAI,CAAC;YACR,IAAI,EAAE,GAAG,CAAC,MAAM;YAChB,MAAM,EAAE,8BAA8B;YACtC,MAAM,EAAE,KAAK;YACb,WAAW,EAAE,IAAI;YACjB,SAAS,EAAE,IAAI;SAClB,CAAC,CAAC;KACN;IACD,MAAM,OAAO,GAAmB;QAC5B,IAAA,6BAAW,EACP,CAAA,MAAA,GAAG,CAAC,OAAO,0CAAE,WAAW,KAAI;YACxB,cAAc,EAAE,IAAI;SACvB,CACJ;QACD,IAAA,2BAAU,EAAC;YACP,QAAQ,EAAE,GAAG,CAAC,QAAQ,IAAI,iBAAiB;SAC9C,CAAC;KACL,CAAC;IACF,IAAI,CAAA,MAAA,GAAG,CAAC,OAAO,0CAAE,QAAQ,MAAK,KAAK,EAAE;QACjC,OAAO,CAAC,IAAI,CAAC,IAAA,yBAAQ,EAAC,MAAA,GAAG,CAAC,OAAO,0CAAE,QAAQ,CAAC,CAAC,CAAC;KACjD;IACD,IAAI,CAAA,MAAA,GAAG,CAAC,OAAO,0CAAE,IAAI,MAAK,KAAK,EAAE;QAC7B,OAAO,CAAC,IAAI,CACR,IAAA,qBAAI,EACA,CAAA,MAAA,GAAG,CAAC,OAAO,0CAAE,IAAI,KAAI;YACjB,OAAO,EAAE,IAAI;SAChB,CACJ,CACJ,CAAC;KACL;IACD,OAAO,CAAC,IAAI,CAAC,IAAA,mCAAkB,EAAC,GAAG,CAAC,CAAC,CAAC;IACtC,OAAO;QACH,QAAQ,EAAE;YACN,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC;YACtC,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,IAAI,EAAE,CAAC;YACzC,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,IAAI,EAAE,CAAC;YAC1C,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,oBAAoB,IAAI,EAAE,CAAC;SACjD;QACD,KAAK,EAAE,cAAc;QACrB,MAAM;QACN,OAAO;QACP,gBAAgB,EAAE,IAAI;KACzB,CAAC;AACN,CAAC,CAAC;AAvDW,QAAA,UAAU,cAuDrB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Package @donmahallem/rollup-config
|
|
4
|
+
* Source https://donmahallem.github.io/js-libs/
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.baseDtsConfig = void 0;
|
|
11
|
+
const rollup_plugin_dts_1 = __importDefault(require("rollup-plugin-dts"));
|
|
12
|
+
const replace_config_1 = require("./replace-config");
|
|
13
|
+
const baseDtsConfig = (pkg, cfg) => {
|
|
14
|
+
const outputOpts = {
|
|
15
|
+
input: cfg.sourceTypings,
|
|
16
|
+
output: [{ file: cfg.typingsOutputPath || pkg.types, format: 'es' }],
|
|
17
|
+
plugins: [(0, replace_config_1.setupReplacePlugin)(pkg), (0, rollup_plugin_dts_1.default)(cfg)],
|
|
18
|
+
};
|
|
19
|
+
return outputOpts;
|
|
20
|
+
};
|
|
21
|
+
exports.baseDtsConfig = baseDtsConfig;
|
|
22
|
+
//# sourceMappingURL=dts-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dts-config.js","sourceRoot":"","sources":["../../src/dts-config.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,0EAAoC;AACpC,qDAAsD;AAK/C,MAAM,aAAa,GAAG,CACzB,GAAoB,EACpB,GAAuE,EAC1D,EAAE;IACf,MAAM,UAAU,GAAkB;QAC9B,KAAK,EAAE,GAAG,CAAC,aAAa;QACxB,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,iBAAiB,IAAI,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QACpE,OAAO,EAAE,CAAC,IAAA,mCAAkB,EAAC,GAAG,CAAC,EAAE,IAAA,2BAAG,EAAC,GAAG,CAAC,CAAC;KAC/C,CAAC;IACF,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC;AAVW,QAAA,aAAa,iBAUxB"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -3,69 +3,12 @@
|
|
|
3
3
|
* Package @donmahallem/rollup-config
|
|
4
4
|
* Source https://donmahallem.github.io/js-libs/
|
|
5
5
|
*/
|
|
6
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
-
};
|
|
9
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const output = [];
|
|
18
|
-
if (pkg.main && ((_a = cfg === null || cfg === void 0 ? void 0 : cfg.output) === null || _a === void 0 ? void 0 : _a.cjs) !== false) {
|
|
19
|
-
output.push({
|
|
20
|
-
file: pkg.main,
|
|
21
|
-
footer: '// BUILD: __BUILD_DATE__\n\n',
|
|
22
|
-
format: 'cjs',
|
|
23
|
-
preferConst: true,
|
|
24
|
-
sourcemap: true,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
if (pkg.module && ((_b = cfg === null || cfg === void 0 ? void 0 : cfg.output) === null || _b === void 0 ? void 0 : _b.esm) !== false) {
|
|
28
|
-
output.push({
|
|
29
|
-
file: pkg.module,
|
|
30
|
-
footer: '// BUILD: __BUILD_DATE__\n\n',
|
|
31
|
-
format: 'esm',
|
|
32
|
-
preferConst: true,
|
|
33
|
-
sourcemap: true,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
const plugins = [
|
|
37
|
-
(0, plugin_node_resolve_1.default)(((_c = cfg.plugins) === null || _c === void 0 ? void 0 : _c.nodeResolve) || {
|
|
38
|
-
preferBuiltins: true,
|
|
39
|
-
}),
|
|
40
|
-
(0, plugin_typescript_1.default)({
|
|
41
|
-
tsconfig: cfg.tsconfig || './tsconfig.json',
|
|
42
|
-
}),
|
|
43
|
-
];
|
|
44
|
-
if (((_d = cfg.plugins) === null || _d === void 0 ? void 0 : _d.commonjs) !== false) {
|
|
45
|
-
plugins.push((0, plugin_commonjs_1.default)((_e = cfg.plugins) === null || _e === void 0 ? void 0 : _e.commonjs));
|
|
46
|
-
}
|
|
47
|
-
if (((_f = cfg.plugins) === null || _f === void 0 ? void 0 : _f.json) !== false) {
|
|
48
|
-
plugins.push((0, plugin_json_1.default)(((_g = cfg.plugins) === null || _g === void 0 ? void 0 : _g.json) || {
|
|
49
|
-
compact: true,
|
|
50
|
-
}));
|
|
51
|
-
}
|
|
52
|
-
plugins.push((0, plugin_replace_1.default)({
|
|
53
|
-
__BUILD_DATE__: () => new Date().toString(),
|
|
54
|
-
__BUILD_PACKAGE_NAME__: pkg.name,
|
|
55
|
-
__BUILD_VERSION__: pkg.version,
|
|
56
|
-
preventAssignment: true,
|
|
57
|
-
}));
|
|
58
|
-
return {
|
|
59
|
-
external: [
|
|
60
|
-
...Object.keys(pkg.dependencies || {}),
|
|
61
|
-
...Object.keys(pkg.devDependencies || {}),
|
|
62
|
-
...Object.keys(pkg.peerDependencies || {}),
|
|
63
|
-
...Object.keys(pkg.optionalDependencies || {}),
|
|
64
|
-
],
|
|
65
|
-
input: 'src/index.ts',
|
|
66
|
-
output,
|
|
67
|
-
plugins,
|
|
68
|
-
preserveSymlinks: true,
|
|
69
|
-
};
|
|
70
|
-
};
|
|
7
|
+
exports.baseDtsConfig = exports.default = exports.baseConfig = void 0;
|
|
8
|
+
var base_config_1 = require("./base-config");
|
|
9
|
+
Object.defineProperty(exports, "baseConfig", { enumerable: true, get: function () { return base_config_1.baseConfig; } });
|
|
10
|
+
var base_config_2 = require("./base-config");
|
|
11
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return base_config_2.baseConfig; } });
|
|
12
|
+
var dts_config_1 = require("./dts-config");
|
|
13
|
+
Object.defineProperty(exports, "baseDtsConfig", { enumerable: true, get: function () { return dts_config_1.baseDtsConfig; } });
|
|
71
14
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,6CAAsD;AAA7C,sGAAA,UAAU,OAAW;AAC9B,2CAA6C;AAApC,2GAAA,aAAa,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"partial-pkg.js","sourceRoot":"","sources":["../../src/partial-pkg.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Package @donmahallem/rollup-config
|
|
4
|
+
* Source https://donmahallem.github.io/js-libs/
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.setupReplacePlugin = void 0;
|
|
11
|
+
const plugin_replace_1 = __importDefault(require("@rollup/plugin-replace"));
|
|
12
|
+
/**
|
|
13
|
+
* @param {IPartialConfig} pkg package.json to use
|
|
14
|
+
*/
|
|
15
|
+
function setupReplacePlugin(pkg) {
|
|
16
|
+
return (0, plugin_replace_1.default)({
|
|
17
|
+
__BUILD_DATE__: () => new Date().toString(),
|
|
18
|
+
__BUILD_PACKAGE_NAME__: pkg.name,
|
|
19
|
+
__BUILD_VERSION__: pkg.version,
|
|
20
|
+
preventAssignment: true,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
exports.setupReplacePlugin = setupReplacePlugin;
|
|
24
|
+
//# sourceMappingURL=replace-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replace-config.js","sourceRoot":"","sources":["../../src/replace-config.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,4EAA6C;AAI7C;;GAEG;AACH,SAAgB,kBAAkB,CAAC,GAAoB;IACnD,OAAO,IAAA,wBAAO,EAAC;QACX,cAAc,EAAE,GAAW,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,QAAQ,EAAE;QACnD,sBAAsB,EAAE,GAAG,CAAC,IAAI;QAChC,iBAAiB,EAAE,GAAG,CAAC,OAAO;QAC9B,iBAAiB,EAAE,IAAI;KAC1B,CAAC,CAAC;AACP,CAAC;AAPD,gDAOC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Package @donmahallem/rollup-config
|
|
3
|
+
* Source https://donmahallem.github.io/js-libs/
|
|
4
|
+
*/
|
|
5
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
6
|
+
import json from '@rollup/plugin-json';
|
|
7
|
+
import nodeResolve from '@rollup/plugin-node-resolve';
|
|
8
|
+
import typescript from '@rollup/plugin-typescript';
|
|
9
|
+
import { setupReplacePlugin } from './replace-config';
|
|
10
|
+
export const baseConfig = (pkg, cfg = {}) => {
|
|
11
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
12
|
+
const output = [];
|
|
13
|
+
if (pkg.main && ((_a = cfg === null || cfg === void 0 ? void 0 : cfg.output) === null || _a === void 0 ? void 0 : _a.cjs) !== false) {
|
|
14
|
+
output.push({
|
|
15
|
+
file: pkg.main,
|
|
16
|
+
footer: '// BUILD: __BUILD_DATE__\n\n',
|
|
17
|
+
format: 'cjs',
|
|
18
|
+
preferConst: true,
|
|
19
|
+
sourcemap: true,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (pkg.module && ((_b = cfg === null || cfg === void 0 ? void 0 : cfg.output) === null || _b === void 0 ? void 0 : _b.esm) !== false) {
|
|
23
|
+
output.push({
|
|
24
|
+
file: pkg.module,
|
|
25
|
+
footer: '// BUILD: __BUILD_DATE__\n\n',
|
|
26
|
+
format: 'esm',
|
|
27
|
+
preferConst: true,
|
|
28
|
+
sourcemap: true,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const plugins = [
|
|
32
|
+
nodeResolve(((_c = cfg.plugins) === null || _c === void 0 ? void 0 : _c.nodeResolve) || {
|
|
33
|
+
preferBuiltins: true,
|
|
34
|
+
}),
|
|
35
|
+
typescript({
|
|
36
|
+
tsconfig: cfg.tsconfig || './tsconfig.json',
|
|
37
|
+
}),
|
|
38
|
+
];
|
|
39
|
+
if (((_d = cfg.plugins) === null || _d === void 0 ? void 0 : _d.commonjs) !== false) {
|
|
40
|
+
plugins.push(commonjs((_e = cfg.plugins) === null || _e === void 0 ? void 0 : _e.commonjs));
|
|
41
|
+
}
|
|
42
|
+
if (((_f = cfg.plugins) === null || _f === void 0 ? void 0 : _f.json) !== false) {
|
|
43
|
+
plugins.push(json(((_g = cfg.plugins) === null || _g === void 0 ? void 0 : _g.json) || {
|
|
44
|
+
compact: true,
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
plugins.push(setupReplacePlugin(pkg));
|
|
48
|
+
return {
|
|
49
|
+
external: [
|
|
50
|
+
...Object.keys(pkg.dependencies || {}),
|
|
51
|
+
...Object.keys(pkg.devDependencies || {}),
|
|
52
|
+
...Object.keys(pkg.peerDependencies || {}),
|
|
53
|
+
...Object.keys(pkg.optionalDependencies || {}),
|
|
54
|
+
],
|
|
55
|
+
input: 'src/index.ts',
|
|
56
|
+
output,
|
|
57
|
+
plugins,
|
|
58
|
+
preserveSymlinks: true,
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=base-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-config.js","sourceRoot":"","sources":["../../src/base-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,QAAmC,MAAM,yBAAyB,CAAC;AAC1E,OAAO,IAA2B,MAAM,qBAAqB,CAAC;AAC9D,OAAO,WAAyC,MAAM,6BAA6B,CAAC;AACpF,OAAO,UAAU,MAAM,2BAA2B,CAAC;AAGnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAmBtD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAoB,EAAE,MAAe,EAAE,EAAiB,EAAE;;IACjF,MAAM,MAAM,GAAoB,EAAE,CAAC;IACnC,IAAI,GAAG,CAAC,IAAI,IAAI,CAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,MAAM,0CAAE,GAAG,MAAK,KAAK,EAAE;QACxC,MAAM,CAAC,IAAI,CAAC;YACR,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,MAAM,EAAE,8BAA8B;YACtC,MAAM,EAAE,KAAK;YACb,WAAW,EAAE,IAAI;YACjB,SAAS,EAAE,IAAI;SAClB,CAAC,CAAC;KACN;IACD,IAAI,GAAG,CAAC,MAAM,IAAI,CAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,MAAM,0CAAE,GAAG,MAAK,KAAK,EAAE;QAC1C,MAAM,CAAC,IAAI,CAAC;YACR,IAAI,EAAE,GAAG,CAAC,MAAM;YAChB,MAAM,EAAE,8BAA8B;YACtC,MAAM,EAAE,KAAK;YACb,WAAW,EAAE,IAAI;YACjB,SAAS,EAAE,IAAI;SAClB,CAAC,CAAC;KACN;IACD,MAAM,OAAO,GAAmB;QAC5B,WAAW,CACP,CAAA,MAAA,GAAG,CAAC,OAAO,0CAAE,WAAW,KAAI;YACxB,cAAc,EAAE,IAAI;SACvB,CACJ;QACD,UAAU,CAAC;YACP,QAAQ,EAAE,GAAG,CAAC,QAAQ,IAAI,iBAAiB;SAC9C,CAAC;KACL,CAAC;IACF,IAAI,CAAA,MAAA,GAAG,CAAC,OAAO,0CAAE,QAAQ,MAAK,KAAK,EAAE;QACjC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAA,GAAG,CAAC,OAAO,0CAAE,QAAQ,CAAC,CAAC,CAAC;KACjD;IACD,IAAI,CAAA,MAAA,GAAG,CAAC,OAAO,0CAAE,IAAI,MAAK,KAAK,EAAE;QAC7B,OAAO,CAAC,IAAI,CACR,IAAI,CACA,CAAA,MAAA,GAAG,CAAC,OAAO,0CAAE,IAAI,KAAI;YACjB,OAAO,EAAE,IAAI;SAChB,CACJ,CACJ,CAAC;KACL;IACD,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC;IACtC,OAAO;QACH,QAAQ,EAAE;YACN,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC;YACtC,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,IAAI,EAAE,CAAC;YACzC,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,IAAI,EAAE,CAAC;YAC1C,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,oBAAoB,IAAI,EAAE,CAAC;SACjD;QACD,KAAK,EAAE,cAAc;QACrB,MAAM;QACN,OAAO;QACP,gBAAgB,EAAE,IAAI;KACzB,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Package @donmahallem/rollup-config
|
|
3
|
+
* Source https://donmahallem.github.io/js-libs/
|
|
4
|
+
*/
|
|
5
|
+
import dts from 'rollup-plugin-dts';
|
|
6
|
+
import { setupReplacePlugin } from './replace-config';
|
|
7
|
+
export const baseDtsConfig = (pkg, cfg) => {
|
|
8
|
+
const outputOpts = {
|
|
9
|
+
input: cfg.sourceTypings,
|
|
10
|
+
output: [{ file: cfg.typingsOutputPath || pkg.types, format: 'es' }],
|
|
11
|
+
plugins: [setupReplacePlugin(pkg), dts(cfg)],
|
|
12
|
+
};
|
|
13
|
+
return outputOpts;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=dts-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dts-config.js","sourceRoot":"","sources":["../../src/dts-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,GAAG,MAAM,mBAAmB,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAKtD,MAAM,CAAC,MAAM,aAAa,GAAG,CACzB,GAAoB,EACpB,GAAuE,EAC1D,EAAE;IACf,MAAM,UAAU,GAAkB;QAC9B,KAAK,EAAE,GAAG,CAAC,aAAa;QACxB,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,iBAAiB,IAAI,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QACpE,OAAO,EAAE,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;KAC/C,CAAC;IACF,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -2,65 +2,7 @@
|
|
|
2
2
|
* Package @donmahallem/rollup-config
|
|
3
3
|
* Source https://donmahallem.github.io/js-libs/
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import replace from '@rollup/plugin-replace';
|
|
9
|
-
import typescript from '@rollup/plugin-typescript';
|
|
10
|
-
export default (pkg, cfg = {}) => {
|
|
11
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
12
|
-
const output = [];
|
|
13
|
-
if (pkg.main && ((_a = cfg === null || cfg === void 0 ? void 0 : cfg.output) === null || _a === void 0 ? void 0 : _a.cjs) !== false) {
|
|
14
|
-
output.push({
|
|
15
|
-
file: pkg.main,
|
|
16
|
-
footer: '// BUILD: __BUILD_DATE__\n\n',
|
|
17
|
-
format: 'cjs',
|
|
18
|
-
preferConst: true,
|
|
19
|
-
sourcemap: true,
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
if (pkg.module && ((_b = cfg === null || cfg === void 0 ? void 0 : cfg.output) === null || _b === void 0 ? void 0 : _b.esm) !== false) {
|
|
23
|
-
output.push({
|
|
24
|
-
file: pkg.module,
|
|
25
|
-
footer: '// BUILD: __BUILD_DATE__\n\n',
|
|
26
|
-
format: 'esm',
|
|
27
|
-
preferConst: true,
|
|
28
|
-
sourcemap: true,
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
const plugins = [
|
|
32
|
-
nodeResolve(((_c = cfg.plugins) === null || _c === void 0 ? void 0 : _c.nodeResolve) || {
|
|
33
|
-
preferBuiltins: true,
|
|
34
|
-
}),
|
|
35
|
-
typescript({
|
|
36
|
-
tsconfig: cfg.tsconfig || './tsconfig.json',
|
|
37
|
-
}),
|
|
38
|
-
];
|
|
39
|
-
if (((_d = cfg.plugins) === null || _d === void 0 ? void 0 : _d.commonjs) !== false) {
|
|
40
|
-
plugins.push(commonjs((_e = cfg.plugins) === null || _e === void 0 ? void 0 : _e.commonjs));
|
|
41
|
-
}
|
|
42
|
-
if (((_f = cfg.plugins) === null || _f === void 0 ? void 0 : _f.json) !== false) {
|
|
43
|
-
plugins.push(json(((_g = cfg.plugins) === null || _g === void 0 ? void 0 : _g.json) || {
|
|
44
|
-
compact: true,
|
|
45
|
-
}));
|
|
46
|
-
}
|
|
47
|
-
plugins.push(replace({
|
|
48
|
-
__BUILD_DATE__: () => new Date().toString(),
|
|
49
|
-
__BUILD_PACKAGE_NAME__: pkg.name,
|
|
50
|
-
__BUILD_VERSION__: pkg.version,
|
|
51
|
-
preventAssignment: true,
|
|
52
|
-
}));
|
|
53
|
-
return {
|
|
54
|
-
external: [
|
|
55
|
-
...Object.keys(pkg.dependencies || {}),
|
|
56
|
-
...Object.keys(pkg.devDependencies || {}),
|
|
57
|
-
...Object.keys(pkg.peerDependencies || {}),
|
|
58
|
-
...Object.keys(pkg.optionalDependencies || {}),
|
|
59
|
-
],
|
|
60
|
-
input: 'src/index.ts',
|
|
61
|
-
output,
|
|
62
|
-
plugins,
|
|
63
|
-
preserveSymlinks: true,
|
|
64
|
-
};
|
|
65
|
-
};
|
|
5
|
+
export { baseConfig } from './base-config';
|
|
6
|
+
export { baseConfig as default } from './base-config';
|
|
7
|
+
export { baseDtsConfig } from './dts-config';
|
|
66
8
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,UAAU,IAAI,OAAO,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"partial-pkg.js","sourceRoot":"","sources":["../../src/partial-pkg.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Package @donmahallem/rollup-config
|
|
3
|
+
* Source https://donmahallem.github.io/js-libs/
|
|
4
|
+
*/
|
|
5
|
+
import replace from '@rollup/plugin-replace';
|
|
6
|
+
/**
|
|
7
|
+
* @param {IPartialConfig} pkg package.json to use
|
|
8
|
+
*/
|
|
9
|
+
export function setupReplacePlugin(pkg) {
|
|
10
|
+
return replace({
|
|
11
|
+
__BUILD_DATE__: () => new Date().toString(),
|
|
12
|
+
__BUILD_PACKAGE_NAME__: pkg.name,
|
|
13
|
+
__BUILD_VERSION__: pkg.version,
|
|
14
|
+
preventAssignment: true,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=replace-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replace-config.js","sourceRoot":"","sources":["../../src/replace-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAI7C;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAoB;IACnD,OAAO,OAAO,CAAC;QACX,cAAc,EAAE,GAAW,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,QAAQ,EAAE;QACnD,sBAAsB,EAAE,GAAG,CAAC,IAAI;QAChC,iBAAiB,EAAE,GAAG,CAAC,OAAO;QAC9B,iBAAiB,EAAE,IAAI;KAC1B,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RollupCommonJSOptions } from '@rollup/plugin-commonjs';
|
|
2
|
+
import { RollupJsonOptions } from '@rollup/plugin-json';
|
|
3
|
+
import { RollupNodeResolveOptions } from '@rollup/plugin-node-resolve';
|
|
4
|
+
import { RollupOptions } from 'rollup';
|
|
5
|
+
import { IPartialPackage } from './partial-pkg';
|
|
6
|
+
export interface IConfig {
|
|
7
|
+
output?: {
|
|
8
|
+
cjs?: boolean;
|
|
9
|
+
esm?: boolean;
|
|
10
|
+
};
|
|
11
|
+
plugins?: {
|
|
12
|
+
commonjs?: false | RollupCommonJSOptions;
|
|
13
|
+
nodeResolve?: RollupNodeResolveOptions;
|
|
14
|
+
json?: false | RollupJsonOptions;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Path to the tsconfig path to use
|
|
18
|
+
*
|
|
19
|
+
* @default './tsconfig.json'
|
|
20
|
+
*/
|
|
21
|
+
tsconfig?: string;
|
|
22
|
+
}
|
|
23
|
+
export declare const baseConfig: (pkg: IPartialPackage, cfg?: IConfig) => RollupOptions;
|
|
24
|
+
//# sourceMappingURL=base-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-config.d.ts","sourceRoot":"","sources":["../../src/base-config.ts"],"names":[],"mappings":"AAKA,OAAiB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAa,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAoB,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAEpF,OAAO,EAAE,aAAa,EAA+B,MAAM,QAAQ,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGhD,MAAM,WAAW,OAAO;IACpB,MAAM,CAAC,EAAE;QACL,GAAG,CAAC,EAAE,OAAO,CAAC;QACd,GAAG,CAAC,EAAE,OAAO,CAAC;KACjB,CAAC;IACF,OAAO,CAAC,EAAE;QACN,QAAQ,CAAC,EAAE,KAAK,GAAG,qBAAqB,CAAC;QACzC,WAAW,CAAC,EAAE,wBAAwB,CAAC;QACvC,IAAI,CAAC,EAAE,KAAK,GAAG,iBAAiB,CAAC;KACpC,CAAC;IACF;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AACD,eAAO,MAAM,UAAU,QAAS,eAAe,QAAO,OAAO,KAAQ,aAuDpE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IPartialPackage } from './partial-pkg';
|
|
2
|
+
import type { RollupOptions } from 'rollup';
|
|
3
|
+
import type { Options as DtsOptions } from 'rollup-plugin-dts';
|
|
4
|
+
export declare const baseDtsConfig: (pkg: IPartialPackage, cfg: DtsOptions & {
|
|
5
|
+
typingsOutputPath?: string;
|
|
6
|
+
sourceTypings: string;
|
|
7
|
+
}) => RollupOptions;
|
|
8
|
+
//# sourceMappingURL=dts-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dts-config.d.ts","sourceRoot":"","sources":["../../src/dts-config.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/D,eAAO,MAAM,aAAa,QACjB,eAAe,OACf,UAAU,GAAG;IAAE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,KACxE,aAOF,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,42 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { RollupOptions } from 'rollup';
|
|
5
|
-
export interface IConfig {
|
|
6
|
-
output?: {
|
|
7
|
-
cjs?: boolean;
|
|
8
|
-
esm?: boolean;
|
|
9
|
-
};
|
|
10
|
-
plugins?: {
|
|
11
|
-
commonjs?: false | RollupCommonJSOptions;
|
|
12
|
-
nodeResolve?: RollupNodeResolveOptions;
|
|
13
|
-
json?: false | RollupJsonOptions;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Path to the tsconfig path to use
|
|
17
|
-
*
|
|
18
|
-
* @default './tsconfig.json'
|
|
19
|
-
*/
|
|
20
|
-
tsconfig?: string;
|
|
21
|
-
}
|
|
22
|
-
export interface IPartialPackage {
|
|
23
|
-
dependencies?: {
|
|
24
|
-
[key: string]: string;
|
|
25
|
-
};
|
|
26
|
-
devDependencies?: {
|
|
27
|
-
[key: string]: string;
|
|
28
|
-
};
|
|
29
|
-
main?: string;
|
|
30
|
-
module?: string;
|
|
31
|
-
name?: string;
|
|
32
|
-
optionalDependencies?: {
|
|
33
|
-
[key: string]: string;
|
|
34
|
-
};
|
|
35
|
-
peerDependencies?: {
|
|
36
|
-
[key: string]: string;
|
|
37
|
-
};
|
|
38
|
-
version?: string;
|
|
39
|
-
}
|
|
40
|
-
declare const _default: (pkg: IPartialPackage, cfg?: IConfig) => RollupOptions;
|
|
41
|
-
export default _default;
|
|
1
|
+
export { baseConfig } from './base-config';
|
|
2
|
+
export { baseConfig as default } from './base-config';
|
|
3
|
+
export { baseDtsConfig } from './dts-config';
|
|
42
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAKA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,UAAU,IAAI,OAAO,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface IPartialPackage {
|
|
2
|
+
dependencies?: {
|
|
3
|
+
[key: string]: string;
|
|
4
|
+
};
|
|
5
|
+
devDependencies?: {
|
|
6
|
+
[key: string]: string;
|
|
7
|
+
};
|
|
8
|
+
main?: string;
|
|
9
|
+
module?: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
optionalDependencies?: {
|
|
12
|
+
[key: string]: string;
|
|
13
|
+
};
|
|
14
|
+
peerDependencies?: {
|
|
15
|
+
[key: string]: string;
|
|
16
|
+
};
|
|
17
|
+
types?: string;
|
|
18
|
+
version?: string;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=partial-pkg.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"partial-pkg.d.ts","sourceRoot":"","sources":["../../src/partial-pkg.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,eAAe;IAC5B,YAAY,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACzC,eAAe,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oBAAoB,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACjD,gBAAgB,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Plugin } from 'rollup';
|
|
2
|
+
import { IPartialPackage } from './partial-pkg';
|
|
3
|
+
/**
|
|
4
|
+
* @param {IPartialConfig} pkg package.json to use
|
|
5
|
+
*/
|
|
6
|
+
export declare function setupReplacePlugin(pkg: IPartialPackage): Plugin;
|
|
7
|
+
//# sourceMappingURL=replace-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replace-config.d.ts","sourceRoot":"","sources":["../../src/replace-config.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CAO/D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@donmahallem/rollup-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "My Rollup config. Do not use!",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@rollup/plugin-json": "4.1.0",
|
|
53
|
-
"@rollup/plugin-node-resolve": "13.
|
|
54
|
-
"@rollup/plugin-replace": "3.0.
|
|
53
|
+
"@rollup/plugin-node-resolve": "13.1.3",
|
|
54
|
+
"@rollup/plugin-replace": "3.0.1",
|
|
55
55
|
"@rollup/plugin-typescript": "8.3.0",
|
|
56
|
-
"rollup": "2.
|
|
57
|
-
"rollup-plugin-dts": "4.0
|
|
56
|
+
"rollup": "2.63.0",
|
|
57
|
+
"rollup-plugin-dts": "4.1.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@rollup/plugin-json": "^4.1.0",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"rollup": "^2.39.0",
|
|
65
65
|
"rollup-plugin-dts": "^4.0.0"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "e2af192e734e8d884a8cde9537b152721ca53cee"
|
|
68
68
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Package @donmahallem/rollup-config
|
|
3
|
+
* Source https://donmahallem.github.io/js-libs/
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { expect } from 'chai';
|
|
7
|
+
import 'mocha';
|
|
8
|
+
import { RollupOptions } from 'rollup';
|
|
9
|
+
import { baseConfig } from './base-config';
|
|
10
|
+
|
|
11
|
+
describe('index', (): void => {
|
|
12
|
+
it('should set all plugins with default config', (): void => {
|
|
13
|
+
const result: RollupOptions = baseConfig({ name: 'testname', version: '1.2.3' });
|
|
14
|
+
expect(result.plugins).to.have.lengthOf(5);
|
|
15
|
+
});
|
|
16
|
+
it('should exclude commonjs with false as config', (): void => {
|
|
17
|
+
const result: RollupOptions = baseConfig({ name: 'testname', version: '1.2.3' }, { plugins: { commonjs: false } });
|
|
18
|
+
expect(result.plugins).to.have.lengthOf(4);
|
|
19
|
+
});
|
|
20
|
+
it('should exclude commonjs with false as config', (): void => {
|
|
21
|
+
const result: RollupOptions = baseConfig({ name: 'testname', version: '1.2.3' }, { plugins: { json: false } });
|
|
22
|
+
expect(result.plugins).to.have.lengthOf(4);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Package @donmahallem/rollup-config
|
|
3
|
+
* Source https://donmahallem.github.io/js-libs/
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import commonjs, { RollupCommonJSOptions } from '@rollup/plugin-commonjs';
|
|
7
|
+
import json, { RollupJsonOptions } from '@rollup/plugin-json';
|
|
8
|
+
import nodeResolve, { RollupNodeResolveOptions } from '@rollup/plugin-node-resolve';
|
|
9
|
+
import typescript from '@rollup/plugin-typescript';
|
|
10
|
+
import { RollupOptions, OutputOptions, OutputPlugin } from 'rollup';
|
|
11
|
+
import { IPartialPackage } from './partial-pkg';
|
|
12
|
+
import { setupReplacePlugin } from './replace-config';
|
|
13
|
+
|
|
14
|
+
export interface IConfig {
|
|
15
|
+
output?: {
|
|
16
|
+
cjs?: boolean;
|
|
17
|
+
esm?: boolean;
|
|
18
|
+
};
|
|
19
|
+
plugins?: {
|
|
20
|
+
commonjs?: false | RollupCommonJSOptions;
|
|
21
|
+
nodeResolve?: RollupNodeResolveOptions;
|
|
22
|
+
json?: false | RollupJsonOptions;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Path to the tsconfig path to use
|
|
26
|
+
*
|
|
27
|
+
* @default './tsconfig.json'
|
|
28
|
+
*/
|
|
29
|
+
tsconfig?: string;
|
|
30
|
+
}
|
|
31
|
+
export const baseConfig = (pkg: IPartialPackage, cfg: IConfig = {}): RollupOptions => {
|
|
32
|
+
const output: OutputOptions[] = [];
|
|
33
|
+
if (pkg.main && cfg?.output?.cjs !== false) {
|
|
34
|
+
output.push({
|
|
35
|
+
file: pkg.main,
|
|
36
|
+
footer: '// BUILD: __BUILD_DATE__\n\n',
|
|
37
|
+
format: 'cjs',
|
|
38
|
+
preferConst: true,
|
|
39
|
+
sourcemap: true,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
if (pkg.module && cfg?.output?.esm !== false) {
|
|
43
|
+
output.push({
|
|
44
|
+
file: pkg.module,
|
|
45
|
+
footer: '// BUILD: __BUILD_DATE__\n\n',
|
|
46
|
+
format: 'esm',
|
|
47
|
+
preferConst: true,
|
|
48
|
+
sourcemap: true,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
const plugins: OutputPlugin[] = [
|
|
52
|
+
nodeResolve(
|
|
53
|
+
cfg.plugins?.nodeResolve || {
|
|
54
|
+
preferBuiltins: true,
|
|
55
|
+
}
|
|
56
|
+
),
|
|
57
|
+
typescript({
|
|
58
|
+
tsconfig: cfg.tsconfig || './tsconfig.json',
|
|
59
|
+
}),
|
|
60
|
+
];
|
|
61
|
+
if (cfg.plugins?.commonjs !== false) {
|
|
62
|
+
plugins.push(commonjs(cfg.plugins?.commonjs));
|
|
63
|
+
}
|
|
64
|
+
if (cfg.plugins?.json !== false) {
|
|
65
|
+
plugins.push(
|
|
66
|
+
json(
|
|
67
|
+
cfg.plugins?.json || {
|
|
68
|
+
compact: true,
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
plugins.push(setupReplacePlugin(pkg));
|
|
74
|
+
return {
|
|
75
|
+
external: [
|
|
76
|
+
...Object.keys(pkg.dependencies || {}),
|
|
77
|
+
...Object.keys(pkg.devDependencies || {}),
|
|
78
|
+
...Object.keys(pkg.peerDependencies || {}),
|
|
79
|
+
...Object.keys(pkg.optionalDependencies || {}),
|
|
80
|
+
],
|
|
81
|
+
input: 'src/index.ts',
|
|
82
|
+
output,
|
|
83
|
+
plugins,
|
|
84
|
+
preserveSymlinks: true,
|
|
85
|
+
};
|
|
86
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Package @donmahallem/rollup-config
|
|
3
|
+
* Source https://donmahallem.github.io/js-libs/
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import dts from 'rollup-plugin-dts';
|
|
7
|
+
import { setupReplacePlugin } from './replace-config';
|
|
8
|
+
import type { IPartialPackage } from './partial-pkg';
|
|
9
|
+
import type { RollupOptions } from 'rollup';
|
|
10
|
+
import type { Options as DtsOptions } from 'rollup-plugin-dts';
|
|
11
|
+
|
|
12
|
+
export const baseDtsConfig = (
|
|
13
|
+
pkg: IPartialPackage,
|
|
14
|
+
cfg: DtsOptions & { typingsOutputPath?: string; sourceTypings: string }
|
|
15
|
+
): RollupOptions => {
|
|
16
|
+
const outputOpts: RollupOptions = {
|
|
17
|
+
input: cfg.sourceTypings,
|
|
18
|
+
output: [{ file: cfg.typingsOutputPath || pkg.types, format: 'es' }],
|
|
19
|
+
plugins: [setupReplacePlugin(pkg), dts(cfg)],
|
|
20
|
+
};
|
|
21
|
+
return outputOpts;
|
|
22
|
+
};
|
package/src/index.spec.ts
CHANGED
|
@@ -13,12 +13,4 @@ describe('index', (): void => {
|
|
|
13
13
|
const result: RollupOptions = defaultConfig({ name: 'testname', version: '1.2.3' });
|
|
14
14
|
expect(result.plugins).to.have.lengthOf(5);
|
|
15
15
|
});
|
|
16
|
-
it('should exclude commonjs with false as config', (): void => {
|
|
17
|
-
const result: RollupOptions = defaultConfig({ name: 'testname', version: '1.2.3' }, { plugins: { commonjs: false } });
|
|
18
|
-
expect(result.plugins).to.have.lengthOf(4);
|
|
19
|
-
});
|
|
20
|
-
it('should exclude commonjs with false as config', (): void => {
|
|
21
|
-
const result: RollupOptions = defaultConfig({ name: 'testname', version: '1.2.3' }, { plugins: { json: false } });
|
|
22
|
-
expect(result.plugins).to.have.lengthOf(4);
|
|
23
|
-
});
|
|
24
16
|
});
|
package/src/index.ts
CHANGED
|
@@ -3,100 +3,6 @@
|
|
|
3
3
|
* Source https://donmahallem.github.io/js-libs/
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import replace from '@rollup/plugin-replace';
|
|
10
|
-
import typescript from '@rollup/plugin-typescript';
|
|
11
|
-
import { RollupOptions, OutputOptions, OutputPlugin } from 'rollup';
|
|
12
|
-
|
|
13
|
-
export interface IConfig {
|
|
14
|
-
output?: {
|
|
15
|
-
cjs?: boolean;
|
|
16
|
-
esm?: boolean;
|
|
17
|
-
};
|
|
18
|
-
plugins?: {
|
|
19
|
-
commonjs?: false | RollupCommonJSOptions;
|
|
20
|
-
nodeResolve?: RollupNodeResolveOptions;
|
|
21
|
-
json?: false | RollupJsonOptions;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Path to the tsconfig path to use
|
|
25
|
-
*
|
|
26
|
-
* @default './tsconfig.json'
|
|
27
|
-
*/
|
|
28
|
-
tsconfig?: string;
|
|
29
|
-
}
|
|
30
|
-
export interface IPartialPackage {
|
|
31
|
-
dependencies?: { [key: string]: string };
|
|
32
|
-
devDependencies?: { [key: string]: string };
|
|
33
|
-
main?: string;
|
|
34
|
-
module?: string;
|
|
35
|
-
name?: string;
|
|
36
|
-
optionalDependencies?: { [key: string]: string };
|
|
37
|
-
peerDependencies?: { [key: string]: string };
|
|
38
|
-
version?: string;
|
|
39
|
-
}
|
|
40
|
-
export default (pkg: IPartialPackage, cfg: IConfig = {}): RollupOptions => {
|
|
41
|
-
const output: OutputOptions[] = [];
|
|
42
|
-
if (pkg.main && cfg?.output?.cjs !== false) {
|
|
43
|
-
output.push({
|
|
44
|
-
file: pkg.main,
|
|
45
|
-
footer: '// BUILD: __BUILD_DATE__\n\n',
|
|
46
|
-
format: 'cjs',
|
|
47
|
-
preferConst: true,
|
|
48
|
-
sourcemap: true,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
if (pkg.module && cfg?.output?.esm !== false) {
|
|
52
|
-
output.push({
|
|
53
|
-
file: pkg.module,
|
|
54
|
-
footer: '// BUILD: __BUILD_DATE__\n\n',
|
|
55
|
-
format: 'esm',
|
|
56
|
-
preferConst: true,
|
|
57
|
-
sourcemap: true,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
const plugins: OutputPlugin[] = [
|
|
61
|
-
nodeResolve(
|
|
62
|
-
cfg.plugins?.nodeResolve || {
|
|
63
|
-
preferBuiltins: true,
|
|
64
|
-
}
|
|
65
|
-
),
|
|
66
|
-
typescript({
|
|
67
|
-
tsconfig: cfg.tsconfig || './tsconfig.json',
|
|
68
|
-
}),
|
|
69
|
-
];
|
|
70
|
-
if (cfg.plugins?.commonjs !== false) {
|
|
71
|
-
plugins.push(commonjs(cfg.plugins?.commonjs));
|
|
72
|
-
}
|
|
73
|
-
if (cfg.plugins?.json !== false) {
|
|
74
|
-
plugins.push(
|
|
75
|
-
json(
|
|
76
|
-
cfg.plugins?.json || {
|
|
77
|
-
compact: true,
|
|
78
|
-
}
|
|
79
|
-
)
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
plugins.push(
|
|
83
|
-
replace({
|
|
84
|
-
__BUILD_DATE__: (): string => new Date().toString(),
|
|
85
|
-
__BUILD_PACKAGE_NAME__: pkg.name,
|
|
86
|
-
__BUILD_VERSION__: pkg.version,
|
|
87
|
-
preventAssignment: true,
|
|
88
|
-
})
|
|
89
|
-
);
|
|
90
|
-
return {
|
|
91
|
-
external: [
|
|
92
|
-
...Object.keys(pkg.dependencies || {}),
|
|
93
|
-
...Object.keys(pkg.devDependencies || {}),
|
|
94
|
-
...Object.keys(pkg.peerDependencies || {}),
|
|
95
|
-
...Object.keys(pkg.optionalDependencies || {}),
|
|
96
|
-
],
|
|
97
|
-
input: 'src/index.ts',
|
|
98
|
-
output,
|
|
99
|
-
plugins,
|
|
100
|
-
preserveSymlinks: true,
|
|
101
|
-
};
|
|
102
|
-
};
|
|
6
|
+
export { baseConfig } from './base-config';
|
|
7
|
+
export { baseConfig as default } from './base-config';
|
|
8
|
+
export { baseDtsConfig } from './dts-config';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Package @donmahallem/rollup-config
|
|
3
|
+
* Source https://donmahallem.github.io/js-libs/
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export interface IPartialPackage {
|
|
7
|
+
dependencies?: { [key: string]: string };
|
|
8
|
+
devDependencies?: { [key: string]: string };
|
|
9
|
+
main?: string;
|
|
10
|
+
module?: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
optionalDependencies?: { [key: string]: string };
|
|
13
|
+
peerDependencies?: { [key: string]: string };
|
|
14
|
+
types?: string;
|
|
15
|
+
version?: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Package @donmahallem/rollup-config
|
|
3
|
+
* Source https://donmahallem.github.io/js-libs/
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import replace from '@rollup/plugin-replace';
|
|
7
|
+
import { Plugin } from 'rollup';
|
|
8
|
+
import { IPartialPackage } from './partial-pkg';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @param {IPartialConfig} pkg package.json to use
|
|
12
|
+
*/
|
|
13
|
+
export function setupReplacePlugin(pkg: IPartialPackage): Plugin {
|
|
14
|
+
return replace({
|
|
15
|
+
__BUILD_DATE__: (): string => new Date().toString(),
|
|
16
|
+
__BUILD_PACKAGE_NAME__: pkg.name,
|
|
17
|
+
__BUILD_VERSION__: pkg.version,
|
|
18
|
+
preventAssignment: true,
|
|
19
|
+
});
|
|
20
|
+
}
|