Skip to content

Commit 8d84440

Browse files
authored
revert: do not use node: protocol for imports (#3651)
It requires node 14.18.0 or greater, which is way more recent than the earliest node engine we claim to support. --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
1 parent afada33 commit 8d84440

File tree

109 files changed

+189
-254
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+189
-254
lines changed

eslint-config.yaml

-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ plugins:
88
- '@typescript-eslint'
99
- import
1010
- prettier
11-
- unicorn
1211

1312
parser: '@typescript-eslint/parser'
1413
parserOptions:
@@ -44,9 +43,6 @@ rules:
4443
'prettier/prettier':
4544
- error
4645

47-
'unicorn/prefer-node-protocol':
48-
- error
49-
5046
'@typescript-eslint/array-type':
5147
- error
5248
- default: array-simple

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"eslint-import-resolver-typescript": "^3.2.4",
2828
"eslint-plugin-import": "^2.26.0",
2929
"eslint-plugin-prettier": "^4.2.1",
30-
"eslint-plugin-unicorn": "^43.0.0",
3130
"jest": "^28.1.2",
3231
"jest-circus": "^28.1.2",
3332
"jest-config": "^28.1.2",

packages/@jsii/benchmarks/bin/benchmark.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as fs from 'fs-extra';
2-
import * as path from 'node:path';
2+
import * as path from 'path';
33
import * as yargs from 'yargs';
44

55
import { benchmarks } from '../lib';

packages/@jsii/benchmarks/lib/benchmark.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
import { Profiler, Session } from 'node:inspector';
2-
import {
3-
performance,
4-
PerformanceObserver,
5-
PerformanceEntry,
6-
} from 'node:perf_hooks';
1+
import { Profiler, Session } from 'inspector';
2+
import { performance, PerformanceObserver, PerformanceEntry } from 'perf_hooks';
73

84
/**
95
* Result of a single run of the subject

packages/@jsii/benchmarks/lib/constants.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as path from 'node:path';
1+
import * as path from 'path';
22

33
export const fixturesDir = path.resolve(__dirname, '..', 'fixtures');
44

packages/@jsii/benchmarks/lib/suite/aws-cdk-lib/build-with-jsii.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Compiler } from 'jsii/lib/compiler';
22
import { loadProjectInfo } from 'jsii/lib/project-info';
3-
import * as path from 'node:path';
4-
import * as process from 'node:process';
3+
import * as path from 'path';
4+
import * as process from 'process';
55
import * as ts from 'typescript';
66

77
import type { Context } from '.';

packages/@jsii/benchmarks/lib/suite/aws-cdk-lib/build-with-tsc.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as fs from 'fs-extra';
2-
import * as path from 'node:path';
3-
import * as process from 'node:process';
2+
import * as path from 'path';
3+
import * as process from 'process';
44
import * as ts from 'typescript';
55

66
import type { Context } from '.';

packages/@jsii/benchmarks/lib/suite/aws-cdk-lib/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import * as cp from 'child_process';
12
import * as fs from 'fs-extra';
2-
import * as cp from 'node:child_process';
3-
import * as os from 'node:os';
4-
import * as path from 'node:path';
3+
import * as os from 'os';
4+
import * as path from 'path';
55

66
import { cdkTag, cdk } from '../../constants';
77
import { inDirectory, streamUntar } from '../../util';

packages/@jsii/benchmarks/scripts/snapshot-package.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import * as cp from 'child_process';
12
import * as fs from 'fs-extra';
23
import * as glob from 'glob';
3-
import * as cp from 'node:child_process';
4-
import * as os from 'node:os';
5-
import * as path from 'node:path';
4+
import * as os from 'os';
5+
import * as path from 'path';
66
import * as tar from 'tar';
77
import * as ts from 'typescript';
88

packages/@jsii/check-node/src/constants.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as process from 'node:process';
1+
import * as process from 'process';
22
import { Range, SemVer } from 'semver';
33

44
const ONE_DAY_IN_MILLISECONDS = 86_400_000;

packages/@jsii/check-node/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Chalk, bgYellow, bgYellowBright, bgRed } from 'chalk';
2-
import { error } from 'node:console';
3-
import { version } from 'node:process';
2+
import { error } from 'console';
3+
import { version } from 'process';
44

55
import { NodeRelease } from './constants';
66

packages/@jsii/integ-test/test/build-cdk.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Octokit } from '@octokit/rest';
22
import * as dotenv from 'dotenv';
33
import { mkdtemp, readdir, remove } from 'fs-extra';
4-
import { tmpdir } from 'node:os';
5-
import * as path from 'node:path';
4+
import { tmpdir } from 'os';
5+
import * as path from 'path';
66

77
import {
88
downloadReleaseAsset,

packages/@jsii/integ-test/utils/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import * as cp from 'node:child_process';
2-
import { IncomingMessage } from 'node:http';
3-
import * as https from 'node:https';
4-
import { Readable } from 'node:stream';
1+
import * as cp from 'child_process';
2+
import { IncomingMessage } from 'http';
3+
import * as https from 'https';
4+
import { Readable } from 'stream';
55
import { extract } from 'tar';
66

77
/**

packages/@jsii/kernel/src/kernel.test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import * as childProcess from 'child_process';
12
import * as fs from 'fs-extra';
2-
import * as childProcess from 'node:child_process';
3-
import * as os from 'node:os';
4-
import { join } from 'node:path';
5-
import * as path from 'node:path';
6-
import * as vm from 'node:vm';
3+
import * as os from 'os';
4+
import { join } from 'path';
5+
import * as path from 'path';
6+
import * as vm from 'vm';
77

88
import * as api from './api';
99
import {

packages/@jsii/kernel/src/kernel.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import * as spec from '@jsii/spec';
22
import { loadAssemblyFromPath } from '@jsii/spec';
3+
import * as cp from 'child_process';
34
import * as fs from 'fs-extra';
4-
import * as cp from 'node:child_process';
5-
import * as os from 'node:os';
6-
import * as path from 'node:path';
7-
import * as vm from 'node:vm';
5+
import * as os from 'os';
6+
import * as path from 'path';
87
import * as tar from 'tar';
8+
import * as vm from 'vm';
99

1010
import * as api from './api';
1111
import { TOKEN_REF } from './api';
@@ -49,7 +49,7 @@ export class Kernel {
4949
// I wonder if webpack has some pragma that allows opting-out at certain points
5050
// in the code.
5151
// eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires
52-
const moduleLoad = require('node:module').Module._load;
52+
const moduleLoad = require('module').Module._load;
5353
const nodeRequire = (p: string) => moduleLoad(p, module, false);
5454

5555
this.sandbox = vm.createContext({

packages/@jsii/kernel/src/on-exit.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as fs from 'fs-extra';
2-
import * as process from 'node:process';
2+
import * as process from 'process';
33

44
const removeSyncPaths = new Array<string>();
55

packages/@jsii/kernel/src/serialization.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
*/
2828

2929
import * as spec from '@jsii/spec';
30-
import * as assert from 'node:assert';
31-
import { inspect } from 'node:util';
30+
import * as assert from 'assert';
31+
import { inspect } from 'util';
3232

3333
import {
3434
isObjRef,

packages/@jsii/runtime/bin/jsii-runtime.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import '@jsii/check-node/run';
22

3-
import { spawn } from 'node:child_process';
4-
import { error } from 'node:console';
5-
import { constants as os } from 'node:os';
6-
import { resolve } from 'node:path';
7-
import { Duplex } from 'node:stream';
3+
import { spawn } from 'child_process';
4+
import { error } from 'console';
5+
import { constants as os } from 'os';
6+
import { resolve } from 'path';
7+
import { Duplex } from 'stream';
88

99
// Spawn another node process, with the following file descriptor setup:
1010
// - No STDIN will be provided

packages/@jsii/runtime/lib/host.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { api, Kernel } from '@jsii/kernel';
2-
import { EventEmitter } from 'node:events';
2+
import { EventEmitter } from 'events';
33

44
import { Input, IInputOutput } from './in-out';
55

packages/@jsii/runtime/lib/sync-stdio.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as fs from 'node:fs';
1+
import * as fs from 'fs';
22

33
const INPUT_BUFFER_SIZE = 1_048_576; // 1MiB (aka: 1024 * 1024), not related to max line length
44

packages/@jsii/runtime/test/kernel-host.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { api } from '@jsii/kernel';
22
import * as spec from '@jsii/spec';
33
import { loadAssemblyFromPath } from '@jsii/spec';
4-
import * as child from 'node:child_process';
5-
import * as fs from 'node:fs';
6-
import * as path from 'node:path';
4+
import * as child from 'child_process';
5+
import * as fs from 'fs';
6+
import * as path from 'path';
77

88
import { KernelHost, IInputOutput, Input, Output } from '../lib';
99

packages/@jsii/runtime/test/playback.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import * as child from 'node:child_process';
2-
import * as fs from 'node:fs';
3-
import * as os from 'node:os';
4-
import * as path from 'node:path';
1+
import * as child from 'child_process';
2+
import * as fs from 'fs';
3+
import * as os from 'os';
4+
import * as path from 'path';
55

66
import { IInputOutput, Input, KernelHost, Output } from '../lib';
77

packages/@jsii/spec/src/assembly-utils.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as fs from 'fs-extra';
2-
import * as os from 'node:os';
3-
import * as path from 'node:path';
4-
import * as zlib from 'node:zlib';
2+
import * as os from 'os';
3+
import * as path from 'path';
4+
import * as zlib from 'zlib';
55

66
import {
77
SPEC_FILE_NAME,

packages/@jsii/spec/src/assembly-utils.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import * as fs from 'node:fs';
2-
import * as path from 'node:path';
3-
import * as zlib from 'node:zlib';
1+
import * as fs from 'fs';
2+
import * as path from 'path';
3+
import * as zlib from 'zlib';
44

55
import {
66
Assembly,

packages/@jsii/spec/src/validate-assembly.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { readFileSync, readdirSync } from 'node:fs';
2-
import { resolve } from 'node:path';
1+
import { readFileSync, readdirSync } from 'fs';
2+
import { resolve } from 'path';
33

44
import { validateAssembly } from './validate-assembly';
55

packages/codemaker/src/codemaker.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as fs from 'fs-extra';
2-
import * as os from 'node:os';
3-
import * as path from 'node:path';
2+
import * as os from 'os';
3+
import * as path from 'path';
44

55
import { CodeMaker } from './codemaker';
66

packages/codemaker/src/codemaker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as util from 'node:util';
1+
import * as util from 'util';
22

33
import * as caseutils from './case-utils';
44
import FileBuffer from './filebuff';

packages/codemaker/src/filebuff.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as fs from 'fs-extra';
2-
import * as os from 'node:os';
3-
import * as path from 'node:path';
2+
import * as os from 'os';
3+
import * as path from 'path';
44

55
import FileBuffer from './filebuff';
66

packages/codemaker/src/filebuff.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as path from 'node:path';
1+
import * as path from 'path';
22

33
/**
44
* Buffers the text of a file for later saving.

packages/jsii-calc/lib/cdk16625/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as assert from 'node:assert';
1+
import * as assert from 'assert';
22

33
import { IRandomNumberGenerator } from '../calculator';
44
import { UnimportedSubmoduleType } from './donotimport';

packages/jsii-calc/lib/compliance.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import {
88
StructWithOnlyOptionals,
99
NumericValue,
1010
} from '@scope/jsii-calc-lib';
11-
import * as crypto from 'node:crypto';
12-
import * as fs from 'node:fs';
13-
import * as os from 'node:os';
14-
import * as path from 'node:path';
15-
import { promisify } from 'node:util';
11+
import * as crypto from 'crypto';
12+
import * as fs from 'fs';
13+
import * as os from 'os';
14+
import * as path from 'path';
15+
import { promisify } from 'util';
1616

1717
import {
1818
IFriendlyRandomGenerator,

packages/jsii-calc/test/test.calc.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as calcLib from '@scope/jsii-calc-lib';
2-
import * as assert from 'node:assert';
2+
import * as assert from 'assert';
33

44
import {
55
Add,

packages/jsii-calc/test/test.transitive.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// take a direct dependency on @scope/jsii-calc-base-of-base, which is intended
33
// to only be used as a transitive dependency through @scope/jsii-calc-base.
44

5-
import * as assert from 'node:assert';
6-
import { readFileSync } from 'node:fs';
7-
import { join } from 'node:path';
5+
import * as assert from 'assert';
6+
import { readFileSync } from 'fs';
7+
import { join } from 'path';
88

99
const pkgjsonPath = join(__dirname, '..', 'package.json');
1010
const pkgjson = JSON.parse(readFileSync(pkgjsonPath, 'utf-8'));

packages/jsii-config/bin/jsii-config.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import '@jsii/check-node/run';
22

3-
import { writeFile } from 'node:fs';
4-
import { promisify } from 'node:util';
3+
import { writeFile } from 'fs';
4+
import { promisify } from 'util';
55
import * as yargs from 'yargs';
66

77
import jsiiConfig from '../lib';

packages/jsii-config/lib/util.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { readFile } from 'node:fs';
1+
import { readFile } from 'fs';
22

33
/*
44
* Look for existing nested values in config, return undefined if not found

packages/jsii-config/test/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import * as fs from 'fs';
12
import * as inquirer from 'inquirer';
2-
import * as fs from 'node:fs';
33

44
import jsiiConfig from '../lib';
55
import { packageJsonObject, findQuestions, findQuestion } from './util';

packages/jsii-diff/lib/util.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import * as childProcess from 'child_process';
12
import * as fs from 'fs-extra';
23
import * as log4js from 'log4js';
3-
import * as childProcess from 'node:child_process';
4-
import * as os from 'node:os';
5-
import * as path from 'node:path';
6-
import * as util from 'node:util';
4+
import * as os from 'os';
5+
import * as path from 'path';
6+
import * as util from 'util';
77

88
const LOG = log4js.getLogger('jsii-diff');
99

packages/jsii-pacmak/lib/builder.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Rosetta } from 'jsii-rosetta';
2-
import * as path from 'node:path';
2+
import * as path from 'path';
33

44
import * as logging from './logging';
55
import { JsiiModule } from './packaging';

packages/jsii-pacmak/lib/dependency-graph.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as fs from 'fs-extra';
2-
import { join } from 'node:path';
2+
import { join } from 'path';
33

44
import * as util from './util';
55

0 commit comments

Comments
 (0)