Do not distribute backend source, export everything to commonjs

This commit is contained in:
Alice Gaudon 2021-11-20 15:30:02 +01:00
parent 5869ba3ee3
commit a753122290
8 changed files with 17 additions and 18 deletions

View File

@ -1,4 +1,4 @@
export default { module.exports = {
globals: { globals: {
'ts-jest': { 'ts-jest': {
tsconfig: 'tsconfig.test.json', tsconfig: 'tsconfig.test.json',

View File

@ -11,7 +11,6 @@
"access": "public" "access": "public"
}, },
"main": "dist/main.js", "main": "dist/main.js",
"type": "module",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
"scripts": { "scripts": {
"test": "jest --verbose --runInBand", "test": "jest --verbose --runInBand",

View File

@ -1,7 +1,7 @@
import fs from "fs"; const fs = require('fs');
import path from "path"; const path = require('path');
export function copyRecursively(file, destination) { function copyRecursively(file, destination) {
const target = path.join(destination, path.basename(file)); const target = path.join(destination, path.basename(file));
if (fs.statSync(file).isDirectory()) { if (fs.statSync(file).isDirectory()) {
console.log('mkdir', target); console.log('mkdir', target);
@ -16,3 +16,7 @@ export function copyRecursively(file, destination) {
fs.copyFileSync(file, target); fs.copyFileSync(file, target);
} }
} }
module.exports = {
copyRecursively,
};

View File

@ -1,4 +1,4 @@
import fs from "fs"; const fs = require('fs');
[ [
'intermediates', 'intermediates',

View File

@ -1,6 +1,6 @@
import fs from "fs"; const fs = require('fs');
import path from "path"; const path = require('path');
import {copyRecursively} from "./_functions.js"; const {copyRecursively} = require('./_functions.js');
[ [

View File

@ -1,6 +1,5 @@
import fs from "fs"; const fs = require('fs');
import path from "path"; const path = require('path');
import {copyRecursively} from "./_functions.js";
// These folders must exist for nodemon not to loop indefinitely. // These folders must exist for nodemon not to loop indefinitely.
[ [
@ -18,10 +17,5 @@ if (!fs.existsSync(symlink)) {
fs.symlinkSync(path.resolve('dist/common'), symlink); fs.symlinkSync(path.resolve('dist/common'), symlink);
} }
// Copy all source files
fs.readdirSync('src').forEach(file => {
copyRecursively(path.join('src', file), 'dist');
});
// Copy package.json // Copy package.json
fs.copyFileSync('package.json', 'dist/package.json'); fs.copyFileSync('package.json', 'dist/package.json');

View File

@ -20,7 +20,7 @@
}); });
setRoutes(%routes%); setRoutes(%routes%);
setPublicUrl(%publicUrl%); setPublicUrl(`%publicUrl%`);
new View({ new View({
hydrate: true, hydrate: true,

View File

@ -3,6 +3,8 @@
"compilerOptions": { "compilerOptions": {
"composite": true, "composite": true,
"module": "CommonJS",
"baseUrl": "../dist", "baseUrl": "../dist",
"rootDir": "./", "rootDir": "./",
"sourceRoot": "./", "sourceRoot": "./",