Skip to content

Commit 59c23d5

Browse files
committed
fix(bazel): handle *.mts / *.cts extensions in strict deps test
1 parent 75b0023 commit 59c23d5

File tree

6 files changed

+30
-1
lines changed

6 files changed

+30
-1
lines changed

bazel/ts_project/strict_deps/index.mts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const manifest: StrictDepsManifest = JSON.parse(await fs.readFile(manifestExecPa
1414
* Regex matcher to extract a npm package name, potentially with scope from a subpackage import path.
1515
*/
1616
const moduleSpeciferMatcher = /^(@[\w\d-_]+\/)?([\w\d-_]+)/;
17-
const extensionRemoveRegex = /\.[mc]?(js|(d\.)?ts)$/;
17+
const extensionRemoveRegex = /\.[mc]?(js|(d\.)?[mc]?ts)$/;
1818
const allowedModuleNames = new Set<string>(manifest.allowedModuleNames);
1919
const allowedSources = new Set<string>(
2020
manifest.allowedSources.map((s) => s.replace(extensionRemoveRegex, '')),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
2+
load("//bazel/ts_project/strict_deps:index.bzl", "strict_deps_test")
3+
4+
strict_deps_test(
5+
name = "import_from_mts_cts_extensions",
6+
srcs = ["index.ts"],
7+
deps = [":mts_cts_extensions"],
8+
)
9+
10+
ts_project(
11+
name = "mts_cts_extensions",
12+
srcs = [
13+
"common_extension.cts",
14+
"module_extension.mts",
15+
],
16+
declaration = True,
17+
deps = ["//bazel:node_modules/@types/node"],
18+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports.commonValue = 42;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export {moduleValue} from './module_extension.mjs';
2+
export {commonValue} from './common_extension.cjs';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const moduleValue = 42;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"compilerOptions": {
3+
"strict": true,
4+
"lib": ["esnext", "DOM"],
5+
"declaration": true
6+
}
7+
}

0 commit comments

Comments
 (0)