Skip to content

Commit 81229ac

Browse files
author
Nir Maoz
authored
fix: build fails on node 12 (#531)
1 parent cd691c8 commit 81229ac

File tree

7 files changed

+19
-19
lines changed

7 files changed

+19
-19
lines changed

__TESTS_BUNDLE_SIZE__/bundleSizeTestRunner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async function bundleSizeTestRunner():Promise<void> {
4444
const ACTUAL_SIZE_IN_KB = Math.round(bundleInfo.size / 1024);
4545

4646

47-
if (ACTUAL_SIZE_IN_KB <= EXPECTED_SIZE_IN_KB && ACTUAL_SIZE_IN_KB > ALLOWED_MIN_SIZE_IN_KB) {
47+
if (ACTUAL_SIZE_IN_KB <= EXPECTED_SIZE_IN_KB && ACTUAL_SIZE_IN_KB >= ALLOWED_MIN_SIZE_IN_KB) {
4848
handleTestSuccess(testCases[i], ACTUAL_SIZE_IN_KB);
4949
} else {
5050
handleTestError(TEST_NAME, EXPECTED_SIZE_IN_KB, ACTUAL_SIZE_IN_KB, ALLOWED_MIN_SIZE_IN_KB);
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const TEST_FILE_STRUCTURE = {
1+
export const TEST_FILE_STRUCTURE = {
22
'package.json': '{"fieldA":"foobar"}',
33
dist: {
44
bundles: {
@@ -8,5 +8,3 @@ const TEST_FILE_STRUCTURE = {
88
}
99
}
1010
};
11-
12-
export default TEST_FILE_STRUCTURE;

__TESTS__/unit/scripts/createEntryPoints.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
/* eslint @typescript-eslint/no-var-requires: 0 */
22

3-
import TEST_FILE_STRUCTURE from "../../TestUtils/createEntryMockedFS";
3+
const { TEST_FILE_STRUCTURE } = require('../../TestUtils/createEntryMockedFS');
44

55
const createEntryPoints = require('../../../scripts/lib/entryPointsLib');
6-
const mock = require('mock-fs');
6+
const mockFs = require('mock-fs');
77
const fs = require('fs');
88

9-
109
describe('Tests for createEntryPoints', () => {
1110
beforeEach(() => {
12-
mock.restore();
13-
mock(TEST_FILE_STRUCTURE);
11+
mockFs.restore();
12+
mockFs(TEST_FILE_STRUCTURE);
1413
});
1514

1615
it ('Creates the main entrypoint to the project', () => {
@@ -38,7 +37,7 @@ describe('Tests for createEntryPoints', () => {
3837
});
3938

4039
afterAll(() => {
41-
mock.restore();
40+
mockFs.restore();
4241
});
4342
});
4443

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"test": "npm run test:types && npm run build && jest --coverage --reporters default && npm run test:size",
77
"test:size": "ts-node -O '{\"module\":\"CommonJS\"}' __TESTS_BUNDLE_SIZE__/bin/bin.ts",
88
"test:comp": "node ./scripts/updateCompliationTests.js && jest __TESTS__/compilationsOutput.test.ts --coverage",
9-
"test:comp:service": "ts-node devTools/sanity/index.ts && jest __TESTS__/compilation.test.ts",
9+
"test:comp:service": "ts-node -O '{\"module\":\"CommonJS\"}' devTools/sanity/index.ts && jest __TESTS__/compilation.test.ts",
1010
"test:unit": "jest --reporters default",
1111
"test:unit:watch": "jest --watch --reporters default",
1212
"test:types": "tsc --project tsconfig.test.json",
@@ -16,9 +16,9 @@
1616
"build:ESM": "tsc --project tsconfig.json --outDir dist --declaration true",
1717
"build:rollup": "rollup -c",
1818
"build:docs": "bash ./scripts/buildDocs.sh",
19-
"build:entryPoints": "ts-node ./scripts/createEntrypoints.ts",
20-
"build:injectPackageVersion": "ts-node ./scripts/injectPackageVersionToDistFiles.ts",
21-
"build:updatePackageExports": "ts-node scripts/updatePackageJsonExports.ts",
19+
"build:entryPoints": "ts-node -O '{\"module\":\"CommonJS\"}' ./scripts/createEntrypoints.ts",
20+
"build:injectPackageVersion": "ts-node -O '{\"module\":\"CommonJS\"}' ./scripts/injectPackageVersionToDistFiles.ts",
21+
"build:updatePackageExports": "ts-node -O '{\"module\":\"CommonJS\"}' scripts/updatePackageJsonExports.ts",
2222
"lint": "npm run lint:src && npm run lint:test",
2323
"lint:src": "eslint src --color --ext .ts",
2424
"lint:test": "eslint __TESTS__ __TESTS_BUNDLE_SIZE__ --rule 'import/extensions: [0, \"never\"]' --color --ext .ts",
@@ -87,7 +87,7 @@
8787
"ts-node": "^8.10.2",
8888
"tslib": "^2.0.0",
8989
"typedoc": "^0.17.8",
90-
"typescript": "^3.9.3",
90+
"typescript": "^4.2.0",
9191
"webpack": "^4.44.1"
9292
},
9393
"exports": {

rollup.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default [
2121
resolve(),
2222
replace({
2323
'PACKAGE_VERSION_INJECTED_DURING_BUILD': version,
24+
preventAssignment: true
2425
}),
2526
typescript({ target: 'es5' }),
2627
commonjs(),
@@ -41,6 +42,7 @@ export default [
4142
resolve(),
4243
replace({
4344
'PACKAGE_VERSION_INJECTED_DURING_BUILD': version,
45+
preventAssignment: true
4446
}),
4547
typescript({ target: "es5" }),
4648
commonjs()

rollup.dev.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ export default {
2222
}),
2323
resolve(),
2424
replace({
25-
'PACKAGE_VERSION_INJECTED_DURING_BUILD': version
25+
'PACKAGE_VERSION_INJECTED_DURING_BUILD': version,
26+
preventAssignment: true
2627
}),
2728
babel({
2829
exclude: 'node_modules/**' // only transpile our source code

tsconfig.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
"compilerOptions": {
33
"noImplicitAny": true,
44
"target": "ES2015",
5-
"module": "ES2015",
5+
"module": "ES2022",
66
"moduleResolution": "node",
77
"baseUrl": "src",
88
"esModuleInterop": true,
99
"resolveJsonModule": true,
10-
"allowJs": true
10+
"allowJs": true,
1111
},
1212
"include": [
1313
"src"
1414
]
15-
}
15+
}

0 commit comments

Comments
 (0)