From a15dd7444b013bd177ea495d47f3be6931c38a1e Mon Sep 17 00:00:00 2001 From: nir maoz Date: Mon, 8 Aug 2022 08:16:10 +0300 Subject: [PATCH 1/5] fix: update typescript version to fix error on node 12 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4c06ec85..d103be4c 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,7 @@ "ts-node": "^8.10.2", "tslib": "^2.0.0", "typedoc": "^0.17.8", - "typescript": "^3.9.3", + "typescript": "^4.2.0", "webpack": "^4.44.1" }, "exports": { @@ -151,4 +151,4 @@ "dependencies": { "@cloudinary/transformation-builder-sdk": "^1.0.0" } -} \ No newline at end of file +} From 7b2302867ca2412e27e5ea76076e79123bf05ab8 Mon Sep 17 00:00:00 2001 From: nir maoz Date: Mon, 8 Aug 2022 08:39:41 +0300 Subject: [PATCH 2/5] fix: ts-node missing parameter --- __TESTS__/unit/scripts/createEntryPoints.test.ts | 11 +++++------ package.json | 10 +++++----- rollup.config.js | 2 ++ rollup.dev.config.js | 3 ++- tsconfig.json | 6 +++--- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/__TESTS__/unit/scripts/createEntryPoints.test.ts b/__TESTS__/unit/scripts/createEntryPoints.test.ts index 0ffc158f..e98e96fc 100644 --- a/__TESTS__/unit/scripts/createEntryPoints.test.ts +++ b/__TESTS__/unit/scripts/createEntryPoints.test.ts @@ -1,16 +1,15 @@ /* eslint @typescript-eslint/no-var-requires: 0 */ -import TEST_FILE_STRUCTURE from "../../TestUtils/createEntryMockedFS"; +const { TEST_FILE_STRUCTURE } = require('../../TestUtils/createEntryMockedFS'); const createEntryPoints = require('../../../scripts/lib/entryPointsLib'); -const mock = require('mock-fs'); +const mockFs = require('mock-fs'); const fs = require('fs'); - describe('Tests for createEntryPoints', () => { beforeEach(() => { - mock.restore(); - mock(TEST_FILE_STRUCTURE); + mockFs.restore(); + mockFs(TEST_FILE_STRUCTURE); }); it ('Creates the main entrypoint to the project', () => { @@ -38,7 +37,7 @@ describe('Tests for createEntryPoints', () => { }); afterAll(() => { - mock.restore(); + mockFs.restore(); }); }); diff --git a/package.json b/package.json index d103be4c..8d8757f2 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "test": "npm run test:types && npm run build && jest --coverage --reporters default && npm run test:size", "test:size": "ts-node -O '{\"module\":\"CommonJS\"}' __TESTS_BUNDLE_SIZE__/bin/bin.ts", "test:comp": "node ./scripts/updateCompliationTests.js && jest __TESTS__/compilationsOutput.test.ts --coverage", - "test:comp:service": "ts-node devTools/sanity/index.ts && jest __TESTS__/compilation.test.ts", + "test:comp:service": "ts-node -O '{\"module\":\"CommonJS\"}' devTools/sanity/index.ts && jest __TESTS__/compilation.test.ts", "test:unit": "jest --reporters default", "test:unit:watch": "jest --watch --reporters default", "test:types": "tsc --project tsconfig.test.json", @@ -16,9 +16,9 @@ "build:ESM": "tsc --project tsconfig.json --outDir dist --declaration true", "build:rollup": "rollup -c", "build:docs": "bash ./scripts/buildDocs.sh", - "build:entryPoints": "ts-node ./scripts/createEntrypoints.ts", - "build:injectPackageVersion": "ts-node ./scripts/injectPackageVersionToDistFiles.ts", - "build:updatePackageExports": "ts-node scripts/updatePackageJsonExports.ts", + "build:entryPoints": "ts-node -O '{\"module\":\"CommonJS\"}' ./scripts/createEntrypoints.ts", + "build:injectPackageVersion": "ts-node -O '{\"module\":\"CommonJS\"}' ./scripts/injectPackageVersionToDistFiles.ts", + "build:updatePackageExports": "ts-node -O '{\"module\":\"CommonJS\"}' scripts/updatePackageJsonExports.ts", "lint": "npm run lint:src && npm run lint:test", "lint:src": "eslint src --color --ext .ts", "lint:test": "eslint __TESTS__ __TESTS_BUNDLE_SIZE__ --rule 'import/extensions: [0, \"never\"]' --color --ext .ts", @@ -151,4 +151,4 @@ "dependencies": { "@cloudinary/transformation-builder-sdk": "^1.0.0" } -} +} \ No newline at end of file diff --git a/rollup.config.js b/rollup.config.js index 4bcc5d5d..5011686d 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -21,6 +21,7 @@ export default [ resolve(), replace({ 'PACKAGE_VERSION_INJECTED_DURING_BUILD': version, + preventAssignment: true }), typescript({ target: 'es5' }), commonjs(), @@ -41,6 +42,7 @@ export default [ resolve(), replace({ 'PACKAGE_VERSION_INJECTED_DURING_BUILD': version, + preventAssignment: true }), typescript({ target: "es5" }), commonjs() diff --git a/rollup.dev.config.js b/rollup.dev.config.js index ba0104de..21cc3244 100644 --- a/rollup.dev.config.js +++ b/rollup.dev.config.js @@ -22,7 +22,8 @@ export default { }), resolve(), replace({ - 'PACKAGE_VERSION_INJECTED_DURING_BUILD': version + 'PACKAGE_VERSION_INJECTED_DURING_BUILD': version, + preventAssignment: true }), babel({ exclude: 'node_modules/**' // only transpile our source code diff --git a/tsconfig.json b/tsconfig.json index cd1e61b0..b59eddd7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,14 +2,14 @@ "compilerOptions": { "noImplicitAny": true, "target": "ES2015", - "module": "ES2015", + "module": "ES2022", "moduleResolution": "node", "baseUrl": "src", "esModuleInterop": true, "resolveJsonModule": true, - "allowJs": true + "allowJs": true, }, "include": [ "src" ] -} \ No newline at end of file +} From 1df61760b3d2456c1b2bc82c9cd77f655bbf7cb6 Mon Sep 17 00:00:00 2001 From: nir maoz Date: Mon, 8 Aug 2022 20:54:19 +0300 Subject: [PATCH 3/5] fix: correct export of TEST_FILE_STRUCTURE and bundle size min --- __TESTS_BUNDLE_SIZE__/bundleSizeTestRunner.ts | 4 ++-- __TESTS__/TestUtils/createEntryMockedFS.ts | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/__TESTS_BUNDLE_SIZE__/bundleSizeTestRunner.ts b/__TESTS_BUNDLE_SIZE__/bundleSizeTestRunner.ts index fcdb9332..38486bb9 100644 --- a/__TESTS_BUNDLE_SIZE__/bundleSizeTestRunner.ts +++ b/__TESTS_BUNDLE_SIZE__/bundleSizeTestRunner.ts @@ -28,7 +28,7 @@ async function bundleSizeTestRunner():Promise { const OUTPUT_FILE = `bundle${i}`; const TEST_NAME = testCases[i].name; const EXPECTED_SIZE_IN_KB = testCases[i].sizeLimitInKB; - const ALLOWED_MIN_SIZE_IN_KB = testCases[i].minAllowedSize || 2; + const ALLOWED_MIN_SIZE_IN_KB = testCases[i].minAllowedSize || 1; // Create the entry file for Webpack log.debug('Starting to build webpack loop'); @@ -44,7 +44,7 @@ async function bundleSizeTestRunner():Promise { const ACTUAL_SIZE_IN_KB = Math.round(bundleInfo.size / 1024); - if (ACTUAL_SIZE_IN_KB <= EXPECTED_SIZE_IN_KB && ACTUAL_SIZE_IN_KB > ALLOWED_MIN_SIZE_IN_KB) { + if (ACTUAL_SIZE_IN_KB <= EXPECTED_SIZE_IN_KB && ACTUAL_SIZE_IN_KB >= ALLOWED_MIN_SIZE_IN_KB) { handleTestSuccess(testCases[i], ACTUAL_SIZE_IN_KB); } else { handleTestError(TEST_NAME, EXPECTED_SIZE_IN_KB, ACTUAL_SIZE_IN_KB, ALLOWED_MIN_SIZE_IN_KB); diff --git a/__TESTS__/TestUtils/createEntryMockedFS.ts b/__TESTS__/TestUtils/createEntryMockedFS.ts index 62ae64c9..f49a2578 100644 --- a/__TESTS__/TestUtils/createEntryMockedFS.ts +++ b/__TESTS__/TestUtils/createEntryMockedFS.ts @@ -1,4 +1,4 @@ -const TEST_FILE_STRUCTURE = { +export const TEST_FILE_STRUCTURE = { 'package.json': '{"fieldA":"foobar"}', dist: { bundles: { @@ -8,5 +8,3 @@ const TEST_FILE_STRUCTURE = { } } }; - -export default TEST_FILE_STRUCTURE; From 12f118ecd941a74509db4dd7c7c12f521a8a7ded Mon Sep 17 00:00:00 2001 From: nir maoz Date: Mon, 8 Aug 2022 20:57:58 +0300 Subject: [PATCH 4/5] fix: exports of actions and qualifiers --- __TESTS_BUNDLE_SIZE__/bundleSizeTestRunner.ts | 2 +- src/index.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/__TESTS_BUNDLE_SIZE__/bundleSizeTestRunner.ts b/__TESTS_BUNDLE_SIZE__/bundleSizeTestRunner.ts index 38486bb9..dc662c71 100644 --- a/__TESTS_BUNDLE_SIZE__/bundleSizeTestRunner.ts +++ b/__TESTS_BUNDLE_SIZE__/bundleSizeTestRunner.ts @@ -28,7 +28,7 @@ async function bundleSizeTestRunner():Promise { const OUTPUT_FILE = `bundle${i}`; const TEST_NAME = testCases[i].name; const EXPECTED_SIZE_IN_KB = testCases[i].sizeLimitInKB; - const ALLOWED_MIN_SIZE_IN_KB = testCases[i].minAllowedSize || 1; + const ALLOWED_MIN_SIZE_IN_KB = testCases[i].minAllowedSize || 2; // Create the entry file for Webpack log.debug('Starting to build webpack loop'); diff --git a/src/index.ts b/src/index.ts index bb5c01a8..c9f1f91f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,8 @@ import URLConfig from "./config/URLConfig.js"; import CloudConfig from "./config/CloudConfig.js"; import CloudinaryConfig from "./config/CloudinaryConfig.js"; +import * as Actions from './actions.js'; +import * as Qualifiers from './qualifiers.js'; export {Transformation} from "./transformation/Transformation.js"; export {ImageTransformation} from "./transformation/ImageTransformation.js"; @@ -11,7 +13,5 @@ export {CloudinaryFile} from "./assets/CloudinaryFile.js"; export {CloudinaryMedia} from "./assets/CloudinaryMedia.js"; export {Cloudinary} from "./instance/Cloudinary.js"; export {createCloudinaryLegacyURL} from "./backwards/createCloudinaryLegacyURL.js"; -export * as Actions from './actions.js'; -export * as Qualifiers from './qualifiers.js'; -export {URLConfig, CloudConfig, CloudinaryConfig}; +export {Actions, Qualifiers, URLConfig, CloudConfig, CloudinaryConfig}; From 1e753382d39490bb9e60f12c0bdfd8d6c7fbb3a0 Mon Sep 17 00:00:00 2001 From: nir maoz Date: Mon, 8 Aug 2022 21:35:21 +0300 Subject: [PATCH 5/5] revert index.ts changes --- src/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index c9f1f91f..bb5c01a8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,6 @@ import URLConfig from "./config/URLConfig.js"; import CloudConfig from "./config/CloudConfig.js"; import CloudinaryConfig from "./config/CloudinaryConfig.js"; -import * as Actions from './actions.js'; -import * as Qualifiers from './qualifiers.js'; export {Transformation} from "./transformation/Transformation.js"; export {ImageTransformation} from "./transformation/ImageTransformation.js"; @@ -13,5 +11,7 @@ export {CloudinaryFile} from "./assets/CloudinaryFile.js"; export {CloudinaryMedia} from "./assets/CloudinaryMedia.js"; export {Cloudinary} from "./instance/Cloudinary.js"; export {createCloudinaryLegacyURL} from "./backwards/createCloudinaryLegacyURL.js"; +export * as Actions from './actions.js'; +export * as Qualifiers from './qualifiers.js'; -export {Actions, Qualifiers, URLConfig, CloudConfig, CloudinaryConfig}; +export {URLConfig, CloudConfig, CloudinaryConfig};