Skip to content

Commit e1b0ae7

Browse files
authored
fix: resolve imports manually (#23)
* fix: resolve imports manually * ci: add E2E tests * ci: fix build * chore: remove comments * chore: remove debug * ci: add typings tests * chore: standardize typings style
1 parent becb048 commit e1b0ae7

11 files changed

+95
-9
lines changed

.github/workflows/ci-linux.yml

-3
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,5 @@ jobs:
3333
- name: Installing Dependencies
3434
run: npm ci
3535

36-
- name: Building the Lib
37-
run: npm run build -- --noEmit
38-
3936
- name: Running Tests
4037
run: npm run test

.prettierrc

+10-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,14 @@
1313
"htmlWhitespaceSensitivity": "css",
1414
"endOfLine": "auto",
1515
"embeddedLanguageFormatting": "auto",
16-
"singleAttributePerLine": false
16+
"singleAttributePerLine": false,
17+
"overrides": [
18+
{
19+
"files": ["src/**/*.d.ts"],
20+
"options": {
21+
"singleQuote": false,
22+
"tabWidth": 4
23+
}
24+
}
25+
]
1726
}

biome.json

+14-1
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,32 @@
4848
"rules": {
4949
"nursery": {
5050
"useTopLevelRegex": "off"
51+
},
52+
"correctness": {
53+
"noNodejsModules": "off"
5154
}
5255
}
5356
}
5457
},
5558
{
56-
"include": ["src/index.ts"],
59+
"include": ["src/index.ts", "src/index.d.ts"],
5760
"linter": {
5861
"rules": {
5962
"style": {
6063
"noDefaultExport": "off"
6164
}
6265
}
6366
}
67+
},
68+
{
69+
"include": ["**/**/*.cjs"],
70+
"linter": {
71+
"rules": {
72+
"suspicious": {
73+
"noRedundantUseStrict": "off"
74+
}
75+
}
76+
}
6477
}
6578
]
6679
}

package-lock.json

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
},
1515
"devDependencies": {
1616
"@biomejs/biome": "^1.8.3",
17+
"@types/node": "^20.14.10",
1718
"@types/x509.js": "^1.0.3",
1819
"poku": "^2.0.0",
1920
"prettier": "^3.3.3",
@@ -41,9 +42,11 @@
4142
],
4243
"scripts": {
4344
"build": "npx tsc",
45+
"postbuild": "cp src/index.d.ts lib/index.d.ts",
4446
"lint": "npx @biomejs/biome lint && prettier --check .",
4547
"lint:fix": "npx @biomejs/biome lint --write . && prettier --write .",
48+
"pretest": "npm run build",
4649
"test": "poku --parallel ./test",
47-
"test:ci": "npm run lint && npm run build -- --noEmit && npm run test"
50+
"test:ci": "npm run lint && npm run test"
4851
}
4952
}

src/index.d.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import type { Profiles } from "./@types/profiles.js";
2+
export declare const proxyBundle: Profiles;
3+
declare const profiles: Profiles;
4+
declare module "aws-ssl-profiles" {
5+
const profiles: Profiles & { proxyBundle: Profiles };
6+
export = profiles;
7+
}
8+
export default profiles;

src/index.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ import type { Profiles } from './@types/profiles.js';
22
import { defaults } from './profiles/ca/defaults.js';
33
import { proxies } from './profiles/ca/proxies.js';
44

5-
export const proxyBundle: Profiles = {
5+
const proxyBundle: Profiles = {
66
ca: proxies,
77
};
88

99
const profiles: Profiles = {
1010
ca: [...defaults, ...proxies],
1111
};
1212

13-
export default profiles;
13+
exports.default = profiles;
14+
15+
module.exports = profiles;
16+
module.exports.proxyBundle = proxyBundle;

test/e2e/import.test.mjs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { test, strict } from 'poku';
2+
import awsCaBundle, { proxyBundle } from '../../lib/index.js';
3+
4+
test('Testing import (ESM)', () => {
5+
strict(typeof awsCaBundle?.ca?.length === 'number', 'Default import');
6+
strict(typeof proxyBundle?.ca?.length === 'number', '"proxyBundle" import');
7+
strict(
8+
typeof awsCaBundle.proxyBundle?.ca?.length === 'number',
9+
'"proxyBundle" from default import'
10+
);
11+
});

test/e2e/require.test.cjs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
3+
const { test, strict } = require('poku');
4+
const awsCaBundle = require('../../lib/index.js');
5+
const { proxyBundle } = require('../../lib/index.js');
6+
7+
test('Testing require (CJS)', () => {
8+
strict(typeof awsCaBundle?.ca?.length === 'number', 'Default require');
9+
strict(typeof proxyBundle?.ca?.length === 'number', '"proxyBundle" require');
10+
strict(
11+
typeof awsCaBundle.proxyBundle?.ca?.length === 'number',
12+
'"proxyBundle" from default require'
13+
);
14+
});

test/e2e/typings.test.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { test, strict } from 'poku';
2+
import { readFile } from 'node:fs/promises';
3+
4+
test('Ensure index.d.ts Typings', async () => {
5+
const src = await readFile('./src/index.d.ts', 'utf-8');
6+
const lib = await readFile('./lib/index.d.ts', 'utf-8');
7+
8+
strict.strictEqual(src, lib, '"src" and "lib" should be the same the same');
9+
});

tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"forceConsistentCasingInFileNames": true,
1616
"declaration": true,
1717
"declarationDir": "lib",
18-
"outDir": "lib"
18+
"outDir": "lib",
19+
"allowSyntheticDefaultImports": true
1920
}
2021
}

0 commit comments

Comments
 (0)