Rollup Setup / Migration

This commit is contained in:
Felix Kaspar
2024-01-26 16:26:04 +01:00
parent c07e247a2a
commit bcb8ff5843
17 changed files with 1288 additions and 1820 deletions

View File

@@ -5,45 +5,53 @@
"type": "module",
"exports": "./dist/index.js",
"imports": {
"#pdfcpu": "../../shared-operations/src/wasm/pdfcpu/pdfcpu-wrapper.server.js"
"#pdfcpu": "@stirling-pdf/shared-operations/src/wasm/pdfcpu/pdfcpu-wrapper.server.js"
},
"optionalDependencies": {
"canvas": "^2.11.2"
"canvas": "^2.11.2"
},
"scripts": {
"dev": "npx tsx watch src/index.ts",
"build": "npm run prebuild && pkgroll && npm run postbuild",
"start": "node ./dist/index.js",
"prebuild": "rimraf ./dist",
"postbuild": "npm run copy-locales && npm run copy-pdfcpu",
"copy-locales": "copyfiles -u 3 ../shared-operations/src/locales/**/*.json dist",
"copy-pdfcpu": "copyfiles -u 5 ../shared-operations/src/wasm/pdfcpu/pdfcpu.wasm dist"
"dev-rollup": "rollup -c -w",
"dev": "npx tsx watch src/index.ts",
"build": "npm run prebuild && pkgroll && npm run postbuild",
"start": "node ./dist/index.js",
"prebuild": "rimraf ./dist",
"postbuild": "npm run copy-locales && npm run copy-pdfcpu",
"copy-locales": "copyfiles -u 3 ../shared-operations/src/locales/**/*.json dist",
"copy-pdfcpu": "copyfiles -u 5 ../shared-operations/src/wasm/pdfcpu/pdfcpu.wasm dist"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@esbuild/win32-x64": "^0.19.10",
"@types/archiver": "^6.0.1",
"@types/express": "^4.17.21",
"@types/multer": "^1.4.10",
"@wasmer/wasmfs": "^0.12.0",
"archiver": "^6.0.1",
"express": "^4.18.2",
"express-fileupload": "^1.4.2",
"joi": "^17.11.0",
"jsqr": "^1.4.0",
"multer": "^1.4.5-lts.1",
"pdf-lib": "^1.17.1",
"tsconfig-paths": "^4.2.0"
"@esbuild/win32-x64": "^0.19.10",
"@rollup/plugin-alias": "^5.1.0",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.1.0",
"@types/archiver": "^6.0.1",
"@types/express": "^4.17.21",
"@types/multer": "^1.4.10",
"@wasmer/wasmfs": "^0.12.0",
"archiver": "^6.0.1",
"express": "^4.18.2",
"express-fileupload": "^1.4.2",
"joi": "^17.11.0",
"jsqr": "^1.4.0",
"multer": "^1.4.5-lts.1",
"pdf-lib": "^1.17.1",
"rollup-plugin-copy": "^3.5.0",
"tsconfig-paths": "^4.2.0",
"vite-plugin-node-polyfills": "^0.19.0",
"vite-plugin-top-level-await": "^1.4.1"
},
"devDependencies": {
"copyfiles": "^2.4.1",
"pkgroll": "^2.0.1",
"rimraf": "^5.0.5",
"ts-node-dev": "^2.0.0",
"typescript": "^5.2.2"
"@rollup/plugin-run": "^3.0.2",
"@rollup/plugin-typescript": "^11.1.6",
"copyfiles": "^2.4.1",
"pkgroll": "^2.0.1",
"rimraf": "^5.0.5",
"rollup": "^4.9.6",
"ts-node-dev": "^2.0.0",
"typescript": "^5.2.2"
}
}
}

View File

@@ -0,0 +1,28 @@
import run from "@rollup/plugin-run";
import typescript from '@rollup/plugin-typescript';
import json from '@rollup/plugin-json';
import copy from 'rollup-plugin-copy'
const isDev = process.env.NODE_ENV !== "production";
export default {
input: "src/index.ts",
output: {
file: "dist/bundle.js",
format: "es",
},
watch: {
include: [ './src/**', '../shared-operations/src/**' ]
},
plugins: [
json(),
typescript(),
copy({
targets: [
{ src: '../shared-operations/public', dest: 'dist' },
]
}),
isDev && run()
],
};

View File

@@ -14,5 +14,5 @@ app.listen(PORT, () => {
});
process.on('unhandledRejection', (reason, promise) => {
console.error('Unhandled Rejection at:', promise, 'reason:', reason);
console.error('Unhandled Rejection at:', promise, 'reason:', reason);
});

View File

@@ -11,7 +11,7 @@
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
@@ -26,11 +26,12 @@
/* Modules */
"module": "ES2020", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
"rootDir": "../", /* Specify the root folder within your source files. */
"moduleResolution": "Node", /* Specify how TypeScript looks up a file from a given module specifier. */
"baseUrl": "./src", /* Specify the base directory to resolve non-relative module names. */
"paths": {
"#pdfcpu": ["../../shared-operations/src/wasm/pdfcpu/pdfcpu-wrapper.server"],
"#pdfcpu": ["@stirling-pdf/shared-operations/src/wasm/pdfcpu/pdfcpu-wrapper.server"],
"@stirling-pdf/*": [ "../../*" ]
}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
@@ -46,7 +47,7 @@
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
"allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
@@ -111,11 +112,12 @@
},
"include": [
"src",
"declarations/*.d.ts"
, "../shared-operations/src/wasm/pdfcpu/PdfcpuWrapper.d.ts" ],
"declarations/*.d.ts",
"../shared-operations/src/wasm/pdfcpu/PdfcpuWrapper.d.ts"
],
"ts-node": {
"experimentalSpecifierResolution": "node",
"transpileOnly": true,
"esm": true,
},
"esm": true
}
}