From 83c67750381a367ecbcd68d3c6a904019292f85a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Fri, 17 Sep 2021 08:43:29 +0200 Subject: [PATCH 1/2] Support json modules This is need for builds on Node/NPM 16 --- Gruntfile.js | 12 ++++++------ package.json | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 224c9211..1a11546a 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -349,15 +349,15 @@ module.exports = function (grunt) { command: "git gc --prune=now --aggressive" }, sitemap: { - command: "node --experimental-modules --no-warnings --no-deprecation src/web/static/sitemap.mjs > build/prod/sitemap.xml", + command: "node --experimental-modules --experimental-json-modules --no-warnings --no-deprecation src/web/static/sitemap.mjs > build/prod/sitemap.xml", sync: true }, generateConfig: { command: chainCommands([ "echo '\n--- Regenerating config files. ---'", "echo [] > src/core/config/OperationConfig.json", - "node --experimental-modules --no-warnings --no-deprecation src/core/config/scripts/generateOpsIndex.mjs", - "node --experimental-modules --no-warnings --no-deprecation src/core/config/scripts/generateConfig.mjs", + "node --experimental-modules --experimental-json-modules --no-warnings --no-deprecation src/core/config/scripts/generateOpsIndex.mjs", + "node --experimental-modules --experimental-json-modules --no-warnings --no-deprecation src/core/config/scripts/generateConfig.mjs", "echo '--- Config scripts finished. ---\n'" ]), sync: true @@ -365,7 +365,7 @@ module.exports = function (grunt) { generateNodeIndex: { command: chainCommands([ "echo '\n--- Regenerating node index ---'", - "node --experimental-modules --no-warnings --no-deprecation src/node/config/scripts/generateNodeIndex.mjs", + "node --experimental-modules --experimental-json-modules --no-warnings --no-deprecation src/node/config/scripts/generateNodeIndex.mjs", "echo '--- Node index generated. ---\n'" ]), sync: true @@ -400,14 +400,14 @@ module.exports = function (grunt) { testESMNodeConsumer: { command: chainCommands([ `cd ${nodeConsumerTestPath}`, - "node --no-warnings --experimental-modules esm-consumer.mjs", + "node --no-warnings --experimental-modules --experimental-json-modules esm-consumer.mjs", ]), stdout: false, }, testESMDeepImportNodeConsumer: { command: chainCommands([ `cd ${nodeConsumerTestPath}`, - "node --no-warnings --experimental-modules esm-deep-import-consumer.mjs", + "node --no-warnings --experimental-modules --experimental-json-modules esm-deep-import-consumer.mjs", ]), stdout: false, }, diff --git a/package.json b/package.json index 78a8696b..7747b913 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "imports-loader": "^3.0.0", "mini-css-extract-plugin": "1.3.7", "nightwatch": "^1.7.8", - "node-sass": "^5.0.0", + "node-sass": "^6.0.0", "postcss": "^8.3.6", "postcss-css-variables": "^0.18.0", "postcss-import": "^14.0.2", @@ -169,13 +169,13 @@ "start": "npx grunt dev", "build": "npx grunt prod", "repl": "node src/node/repl.js", - "test": "npx grunt configTests && node --experimental-modules --no-warnings --no-deprecation tests/node/index.mjs && node --experimental-modules --no-warnings --no-deprecation tests/operations/index.mjs", + "test": "npx grunt configTests && node --experimental-modules --experimental-json-modules --no-warnings --no-deprecation tests/node/index.mjs && node --experimental-modules --experimental-json-modules --no-warnings --no-deprecation tests/operations/index.mjs", "test-node-consumer": "npx grunt testnodeconsumer", "testui": "npx grunt testui", "testuidev": "npx nightwatch --env=dev", "lint": "npx grunt lint", "postinstall": "npx grunt exec:fixCryptoApiImports", - "newop": "node --experimental-modules src/core/config/scripts/newOperation.mjs", + "newop": "node --experimental-modules --experimental-json-modules src/core/config/scripts/newOperation.mjs", "getheapsize": "node -e 'console.log(`node heap limit = ${require(\"v8\").getHeapStatistics().heap_size_limit / (1024 * 1024)} Mb`)'", "setheapsize": "export NODE_OPTIONS=--max_old_space_size=2048" } From cfc29ef8216beb2da74ef2d19faecbf7936face2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Fri, 17 Sep 2021 08:46:43 +0200 Subject: [PATCH 2/2] Always use mjs imports This is needed for Node/NPM 16 compat --- src/core/errors/index.mjs | 2 +- src/node/config/scripts/generateNodeIndex.mjs | 4 ++-- tests/node/tests/operations.mjs | 2 +- tests/operations/tests/AvroToJSON.mjs | 2 +- tests/operations/tests/BaconCipher.mjs | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/errors/index.mjs b/src/core/errors/index.mjs index b27affc2..6d96acb0 100644 --- a/src/core/errors/index.mjs +++ b/src/core/errors/index.mjs @@ -1,6 +1,6 @@ import OperationError from "./OperationError.mjs"; import DishError from "./DishError.mjs"; -import ExcludedOperationError from "./ExcludedOperationError"; +import ExcludedOperationError from "./ExcludedOperationError.mjs"; export { OperationError, diff --git a/src/node/config/scripts/generateNodeIndex.mjs b/src/node/config/scripts/generateNodeIndex.mjs index 13c9a842..4e16fbeb 100644 --- a/src/node/config/scripts/generateNodeIndex.mjs +++ b/src/node/config/scripts/generateNodeIndex.mjs @@ -41,7 +41,7 @@ let code = `/** import NodeDish from "./NodeDish.mjs"; import { _wrap, help, bake, _explainExcludedFunction } from "./api.mjs"; import File from "./File.mjs"; -import { OperationError, DishError, ExcludedOperationError } from "../core/errors/index"; +import { OperationError, DishError, ExcludedOperationError } from "../core/errors/index.mjs"; import { // import as core_ to avoid name clashes after wrap. `; @@ -52,7 +52,7 @@ includedOperations.forEach((op) => { }); code +=` -} from "../core/operations/index"; +} from "../core/operations/index.mjs"; global.File = File; diff --git a/tests/node/tests/operations.mjs b/tests/node/tests/operations.mjs index 52748167..d02de6e7 100644 --- a/tests/node/tests/operations.mjs +++ b/tests/node/tests/operations.mjs @@ -32,7 +32,7 @@ import { CSSMinify, toBase64, toHex -} from "../../../src/node/index"; +} from "../../../src/node/index.mjs"; import chef from "../../../src/node/index.mjs"; import TestRegister from "../../lib/TestRegister.mjs"; import File from "../../../src/node/File.mjs"; diff --git a/tests/operations/tests/AvroToJSON.mjs b/tests/operations/tests/AvroToJSON.mjs index 045abddb..b823cbfc 100644 --- a/tests/operations/tests/AvroToJSON.mjs +++ b/tests/operations/tests/AvroToJSON.mjs @@ -6,7 +6,7 @@ * @license Apache-2.0 */ -import TestRegister from "../../lib/TestRegister"; +import TestRegister from "../../lib/TestRegister.mjs"; TestRegister.addTests([ { diff --git a/tests/operations/tests/BaconCipher.mjs b/tests/operations/tests/BaconCipher.mjs index 8833b584..90e5ee64 100644 --- a/tests/operations/tests/BaconCipher.mjs +++ b/tests/operations/tests/BaconCipher.mjs @@ -5,8 +5,8 @@ * @copyright Karsten Silkenbäumer 2019 * @license Apache-2.0 */ -import TestRegister from "../../lib/TestRegister"; -import { BACON_ALPHABETS, BACON_TRANSLATIONS } from "../../../src/core/lib/Bacon"; +import TestRegister from "../../lib/TestRegister.mjs"; +import { BACON_ALPHABETS, BACON_TRANSLATIONS } from "../../../src/core/lib/Bacon.mjs"; const alphabets = Object.keys(BACON_ALPHABETS); const translations = BACON_TRANSLATIONS;