2020-08-03 09:30:48 +02:00
|
|
|
// rollup.config.js
|
|
|
|
import commonjs from "@rollup/plugin-commonjs";
|
|
|
|
import nodeResolve from "@rollup/plugin-node-resolve";
|
|
|
|
import json from "@rollup/plugin-json";
|
|
|
|
import builtins from "builtin-modules";
|
|
|
|
import pkg from "./package.json";
|
2022-01-05 20:29:55 +01:00
|
|
|
import sourcemaps from "rollup-plugin-sourcemaps";
|
|
|
|
import path from "path";
|
2022-01-24 14:57:20 +01:00
|
|
|
import replace from "@rollup/plugin-replace";
|
|
|
|
import child_process from 'child_process';
|
|
|
|
|
|
|
|
const printedVersion = `${pkg.version}-${getGitRevision()}`
|
2020-08-03 09:30:48 +02:00
|
|
|
|
|
|
|
export default {
|
|
|
|
input: "lib/index.js",
|
|
|
|
output: {
|
|
|
|
file: pkg.main,
|
|
|
|
format: "cjs",
|
2020-08-27 10:52:47 +02:00
|
|
|
sourcemap: true,
|
2022-01-05 20:29:55 +01:00
|
|
|
sourcemapPathTransform: (relativeSourcePath, sourcemapPath) => {
|
|
|
|
// Transform to source map paths to virtual path. Otherwise,
|
|
|
|
// error messages would contain paths that look like they should exist (relative to
|
|
|
|
// the bundle) but don't.
|
|
|
|
const res = path.normalize(
|
|
|
|
path.join("/_walletsrc/packages/taler-wallet-cli/src/", relativeSourcePath),
|
|
|
|
);
|
|
|
|
return res;
|
|
|
|
},
|
2020-08-03 09:30:48 +02:00
|
|
|
},
|
|
|
|
external: builtins,
|
|
|
|
plugins: [
|
2022-01-24 14:57:20 +01:00
|
|
|
replace({
|
2022-09-05 16:06:50 +02:00
|
|
|
__VERSION__: `"${printedVersion}"`,
|
2022-01-24 14:57:20 +01:00
|
|
|
}),
|
|
|
|
|
2020-08-03 09:30:48 +02:00
|
|
|
nodeResolve({
|
|
|
|
preferBuiltins: true,
|
2022-01-05 18:40:43 +01:00
|
|
|
exportConditions: ["node"],
|
2020-08-03 09:30:48 +02:00
|
|
|
}),
|
|
|
|
|
2020-08-27 10:52:47 +02:00
|
|
|
sourcemaps(),
|
2020-08-06 17:36:56 +02:00
|
|
|
|
2020-08-03 09:30:48 +02:00
|
|
|
commonjs({
|
2020-08-27 10:52:47 +02:00
|
|
|
sourceMap: true,
|
2020-08-06 17:36:56 +02:00
|
|
|
transformMixedEsModules: true,
|
2020-08-03 09:30:48 +02:00
|
|
|
}),
|
2020-08-27 10:52:47 +02:00
|
|
|
|
|
|
|
json(),
|
2020-08-03 09:30:48 +02:00
|
|
|
],
|
2022-01-05 20:29:55 +01:00
|
|
|
};
|
2022-01-24 14:57:20 +01:00
|
|
|
|
|
|
|
function getGitRevision() {
|
2022-01-24 14:58:41 +01:00
|
|
|
return child_process.execSync(`git rev-parse --short HEAD`, {
|
2022-01-24 14:57:20 +01:00
|
|
|
encoding: 'utf-8',
|
|
|
|
windowsHide: true,
|
|
|
|
}).trim();
|
|
|
|
}
|