rollup initial config

This commit is contained in:
2023-07-12 14:51:32 -04:00
parent 7bf3e7c95e
commit 0b99519b60
5 changed files with 1172 additions and 10 deletions

1110
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -2,12 +2,12 @@
"name": "discreetly-server",
"version": "0.1.0",
"description": "",
"main": "src/server.ts",
"main": "dist/server.cjs",
"scripts": {
"build": "tsc",
"start": "node dist/server.js",
"watch": "tsc --watch ./src/server.ts --outDir ./dist/",
"serve": "nodemon -q dist/src/server.js",
"build": "rollup --config rollup.config.mjs",
"start": "node dist/server.cjs",
"watch": "rollup --config rollup.config.mjs --watch",
"serve": "nodemon -q dist/server.jcs",
"dev": "concurrently \"npm run watch\" \"npm run serve\""
},
"engines": {
@@ -32,10 +32,16 @@
"socket.io": "^4.6.2"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.2",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.1.0",
"@types/cors": "^2.8.13",
"@types/express": "^4.17.17",
"concurrently": "^8.2.0",
"nodemon": "^2.0.22",
"rollup": "^3.26.2",
"rollup-plugin-cleaner": "^1.0.0",
"rollup-plugin-typescript2": "^0.35.0",
"typescript": "^5.1.6"
}
}

53
rollup.config.mjs Normal file
View File

@@ -0,0 +1,53 @@
/* eslint-disable import/no-extraneous-dependencies */
import typescript from 'rollup-plugin-typescript2'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import cleaner from 'rollup-plugin-cleaner'
import * as fs from 'fs'
const input = 'src/server.ts'
const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf-8'))
const banner = `/**
* @module ${pkg.name}
* @version ${pkg.version}
* @file ${pkg.description}
* @copyright Privacy and Scaling Explorations 2023
* @license ${pkg.license}
* @see [Github]{@link ${pkg.homepage}}
*/`
const typescriptPlugin = typescript({
tsconfig: 'tsconfig.json',
useTsconfigDeclarationDir: true,
})
const nodePlugins = [
typescriptPlugin,
// `browser: false` is required for `fs` and other Node.js core modules to be resolved correctly
nodeResolve({ browser: false }),
// To accept commonjs modules and convert them to ES module, since rollup only bundle ES modules by default
commonjs(),
// Parse JSON files and make them ES modules. Required when bundling circomlib
json(),
]
export default [
// Node.js build
{
input,
output: { file: pkg.main, format: 'cjs', banner },
external: Object.keys(pkg.dependencies),
plugins: [
cleaner({
targets: [
'./dist/',
],
}),
...nodePlugins,
],
}
]

View File

@@ -200,7 +200,7 @@ app.post('/room/add', (req, res) => {
redisClient.set('rooms', JSON.stringify(loadedRooms));
res.status(201).json({ status: `Created room ${roomName}`, loadedRooms });
}
})
});
app.get('/logclaimcodes', (req, res) => {
pp('-----CLAIMCODES-----', 'debug');

View File

@@ -2,6 +2,7 @@
"compilerOptions": {
"moduleResolution": "node",
"outDir": "./dist",
"rootDir": "./src",
"target": "ES2022",
"module": "ES2022",
"esModuleInterop": true,