From a753122290ff070f4b992be421c8a369afbccedd Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Sat, 20 Nov 2021 15:30:02 +0100 Subject: [PATCH] Do not distribute backend source, export everything to commonjs --- jest.config.js | 2 +- package.json | 1 - scripts/_functions.js | 10 +++++++--- scripts/clean.js | 2 +- scripts/dist.js | 6 +++--- scripts/prepare-sources.js | 10 ++-------- src/assets/views/layouts/svelte_layout.html | 2 +- src/tsconfig.json | 2 ++ 8 files changed, 17 insertions(+), 18 deletions(-) diff --git a/jest.config.js b/jest.config.js index e0a3f5c..3502ddc 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,4 +1,4 @@ -export default { +module.exports = { globals: { 'ts-jest': { tsconfig: 'tsconfig.test.json', diff --git a/package.json b/package.json index 97f8b0f..6ba19e6 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,6 @@ "access": "public" }, "main": "dist/main.js", - "type": "module", "types": "dist/index.d.ts", "scripts": { "test": "jest --verbose --runInBand", diff --git a/scripts/_functions.js b/scripts/_functions.js index f58cda8..0fea1c4 100644 --- a/scripts/_functions.js +++ b/scripts/_functions.js @@ -1,7 +1,7 @@ -import fs from "fs"; -import path from "path"; +const fs = require('fs'); +const path = require('path'); -export function copyRecursively(file, destination) { +function copyRecursively(file, destination) { const target = path.join(destination, path.basename(file)); if (fs.statSync(file).isDirectory()) { console.log('mkdir', target); @@ -16,3 +16,7 @@ export function copyRecursively(file, destination) { fs.copyFileSync(file, target); } } + +module.exports = { + copyRecursively, +}; \ No newline at end of file diff --git a/scripts/clean.js b/scripts/clean.js index 427e651..32ebb24 100644 --- a/scripts/clean.js +++ b/scripts/clean.js @@ -1,4 +1,4 @@ -import fs from "fs"; +const fs = require('fs'); [ 'intermediates', diff --git a/scripts/dist.js b/scripts/dist.js index 52722e8..bfbf891 100644 --- a/scripts/dist.js +++ b/scripts/dist.js @@ -1,6 +1,6 @@ -import fs from "fs"; -import path from "path"; -import {copyRecursively} from "./_functions.js"; +const fs = require('fs'); +const path = require('path'); +const {copyRecursively} = require('./_functions.js'); [ diff --git a/scripts/prepare-sources.js b/scripts/prepare-sources.js index 3aec692..4f7982d 100644 --- a/scripts/prepare-sources.js +++ b/scripts/prepare-sources.js @@ -1,6 +1,5 @@ -import fs from "fs"; -import path from "path"; -import {copyRecursively} from "./_functions.js"; +const fs = require('fs'); +const path = require('path'); // 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); } -// Copy all source files -fs.readdirSync('src').forEach(file => { - copyRecursively(path.join('src', file), 'dist'); -}); - // Copy package.json fs.copyFileSync('package.json', 'dist/package.json'); diff --git a/src/assets/views/layouts/svelte_layout.html b/src/assets/views/layouts/svelte_layout.html index 99ffe87..9ded83c 100644 --- a/src/assets/views/layouts/svelte_layout.html +++ b/src/assets/views/layouts/svelte_layout.html @@ -20,7 +20,7 @@ }); setRoutes(%routes%); - setPublicUrl(%publicUrl%); + setPublicUrl(`%publicUrl%`); new View({ hydrate: true, diff --git a/src/tsconfig.json b/src/tsconfig.json index 851ef5f..071bf77 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -3,6 +3,8 @@ "compilerOptions": { "composite": true, + "module": "CommonJS", + "baseUrl": "../dist", "rootDir": "./", "sourceRoot": "./",