diff --git a/e2e/load-save-session.e2e-spec.ts b/e2e/load-save-session.e2e-spec.ts index 29c1cc67a55630e5e206bdc31245a59f78cd8630..1e2576170aa8ce10b6d8338bcf5f6eba05b6f88f 100644 --- a/e2e/load-save-session.e2e-spec.ts +++ b/e2e/load-save-session.e2e-spec.ts @@ -7,9 +7,9 @@ import { PreferencesPage } from "./preferences.po"; import { changeSelectValue, expectNumber, loadSession, openCalculator } from "./util.po"; import { browser, $, $$, expect } from '@wdio/globals' -const fs = require("fs"); -const path = require("path"); -const os = require("os"); +import * as fs from 'fs'; +import * as path from 'path'; +import * as os from 'os'; let startPage: AppPage; let listPage: ListPage; diff --git a/e2e/tsconfig.e2e.json b/e2e/tsconfig.e2e.json index 6841529a944cda65f089319bb412599d6b13e946..b79ae71f3bf42c018ff422127407a62dcf7378ab 100644 --- a/e2e/tsconfig.e2e.json +++ b/e2e/tsconfig.e2e.json @@ -3,7 +3,7 @@ "compilerOptions": { "outDir": "../out-tsc/e2e", "baseUrl": "./", - "module": "commonjs", + "module": "es2015", "downlevelIteration": true, "types": [ "jasmine", diff --git a/main.js b/main.js index bdd10ff5aaea012500fce4a4c791f9a826b47406..675fd2b94507975c598f3e0ae26222f18a90361f 100644 --- a/main.js +++ b/main.js @@ -1,4 +1,13 @@ -const { app, dialog, shell, net, BrowserWindow, Notification, nativeImage } = require('electron'); +import { + app, + dialog, + shell, + net, + BrowserWindow, + Notification, + nativeImage + } from 'electron'; + let win; diff --git a/package.json b/package.json index b978f2097778fb180a74c75d4805ef6599edcbeb..01702506afbc00384ee0aabbffc5a401cec972ef 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "main": "main.js", "homepage": "https://cassiopee.g-eau.fr", "license": "MIT", + "type": "module", "scripts": { "ng": "cd . && \"node_modules/.bin/ng\"", "postinstall": "./node_modules/.bin/webdriver-manager update --gecko=false --versions.chrome=107.0.5304.110", diff --git a/scripts/check-translations.js b/scripts/check-translations.js index 99b0058dcb219f58c6dab5bee6b74be3300e202a..7584685566819007d1f47bc6bfc5e182d277a2aa 100644 --- a/scripts/check-translations.js +++ b/scripts/check-translations.js @@ -9,7 +9,7 @@ * in all language files */ -const fs = require('fs'); +import * as fs from 'fs'; /* IMPORTANT: during step 2, will look for those languages codes only */ const expectedLanguages = [ "fr", "en" ]; diff --git a/scripts/clean_release.js b/scripts/clean_release.js index d95e7fda158fbd753ae9dc8bd92e711dd5b82ce0..83d5f9cba34a06c3653b8073c47bac7385499e6c 100644 --- a/scripts/clean_release.js +++ b/scripts/clean_release.js @@ -1,7 +1,7 @@ 'use strict'; -const fs = require('fs'); -const rimraf = require('rimraf'); +import * as fs from 'fs'; +import * as rimraf from 'rimraf'; const path = './release'; diff --git a/scripts/extract-nghyd-version.js b/scripts/extract-nghyd-version.js index aff3a3dd01a1b015880534983b5f0bdac5895b12..3f303a7e8d969842428df75885f39ccdd8aeeff8 100644 --- a/scripts/extract-nghyd-version.js +++ b/scripts/extract-nghyd-version.js @@ -6,8 +6,8 @@ 'use strict'; -const fs = require('fs'); -const path = require('path'); +import * as fs from 'fs'; +import * as path from 'path'; if (process.argv.length < 3) { console.error("ERROR : missing output file path(s)\n"); diff --git a/scripts/mkdocs-postprocess.js b/scripts/mkdocs-postprocess.js index 11b259033998cde6bf5014e9a83616bb164a7e5a..97defa3d580010b854fcec1aedf0b54286afac56 100644 --- a/scripts/mkdocs-postprocess.js +++ b/scripts/mkdocs-postprocess.js @@ -4,7 +4,8 @@ * copies extra javascripts (MathJax, matomo-tracking) to src/assets/docs/javascripts after doc was built by MkDocs */ -const fs = require('fs-extra'); +import * as fs from 'fs-extra'; + const destPath_JS = "src/assets/docs/javascripts"; const destPath_CSS = "src/assets/docs/stylesheets"; @@ -44,7 +45,7 @@ de niveau de répertoire. La solution est donc de modifier les fichiers HTML générés pour ajouter ../ dans href="...". */ -const cp = require('child_process'); +import * as cp from 'child_process'; function execBashCmd(cmd) { // console.log(cmd); diff --git a/scripts/mkdocs2pdf-postprocess.js b/scripts/mkdocs2pdf-postprocess.js index 0752898f8f37391cbaced681ebda9bea5bcd3261..130d739c4177bcd0cd7f12262eee5520c0318e12 100644 --- a/scripts/mkdocs2pdf-postprocess.js +++ b/scripts/mkdocs2pdf-postprocess.js @@ -5,7 +5,7 @@ * - copy illustrated guide (not related to MkDocs, but still a part of the doc) to dist/assets/docs/pdf */ -const fs = require('fs-extra'); +import * as fs from 'fs-extra'; const destPath_PDF = "dist/assets/docs/pdf"; // pour la doc illustrée diff --git a/scripts/preprocessors.js b/scripts/preprocessors.js index e95d481c3afaace51f8262ce13a5bed8f8e7e28d..da5bbfc914bb96a0e95962521d259f5f59d3b958 100644 --- a/scripts/preprocessors.js +++ b/scripts/preprocessors.js @@ -3,11 +3,13 @@ * */ -var fs = require('fs'); -date_last_commit = require('child_process') +import * as fs from 'fs'; +import * as cp from 'child_process'; + +date_last_commit = cp .execSync('git log -1 --format=%cd --date=short') .toString().trim() -version = require('child_process') +version = cp .execSync('git describe') .toString().trim() diff --git a/scripts/sessionDeflate.js b/scripts/sessionDeflate.js index 212360a62c3d7fbca05b91c1d0c7951e03f90960..1e794f6fcae6b6ef98b07fd563aa52d2938c48ef 100644 --- a/scripts/sessionDeflate.js +++ b/scripts/sessionDeflate.js @@ -7,8 +7,9 @@ 'use strict'; -const pako = require("pako"); -global.atob = require("atob"); +import * as pako from 'pako'; +import * as atob from 'atob'; +global.atob = atob; const stdin = process.openStdin(); diff --git a/scripts/update-dist-index-mimetypes.js b/scripts/update-dist-index-mimetypes.js index 7e35416d725df3d8677a8f3028b20b5bf59a284b..bc3e681eb9b37a8d3fbf349300141a4c9f24e462 100644 --- a/scripts/update-dist-index-mimetypes.js +++ b/scripts/update-dist-index-mimetypes.js @@ -1,6 +1,6 @@ 'use strict'; -const fs = require('fs'); +import * as fs from 'fs'; const path = "./dist/index.html"; const contents = fs.readFileSync(path, "utf-8"); diff --git a/src/polyfills.ts b/src/polyfills.ts index c9ef31b81964e5fef96ac831f85f3de176be18fb..aac924fcef760fa5f7a9dbf3c194ba6edca62ae9 100644 --- a/src/polyfills.ts +++ b/src/polyfills.ts @@ -66,7 +66,8 @@ import "zone.js"; // Included with Angular CLI. // Requis pour Buffer dans jalhyd (!?) (window as any).global = window; -global.Buffer = global.Buffer || require("buffer").Buffer; +import * as buffer from 'buffer'; +global.Buffer = global.Buffer || buffer.Buffer; // Edge polyfill for canvas.toBlob method if (!HTMLCanvasElement.prototype.toBlob) {