Skip to content

Commit ca2a6fe

Browse files
committed
Allow ts_project to see package.json (for esmodule resolution).
vercel/next.js#46078
1 parent 4ca85d8 commit ca2a6fe

File tree

14 files changed

+43
-105
lines changed

14 files changed

+43
-105
lines changed

MODULE.bazel.lock

Lines changed: 29 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ci/BUILD.bazel

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,10 @@ js_binary(
4545
"//project/ck3/recursive-vassals:patch",
4646
"//ts/cmd/svgshot:npm_pkg.publish",
4747
"//ts/cmd/svgshot:npm_pkg.tgz",
48-
"//ts/cmd/svgshot:package.json",
4948
"//ts/do-sync:npm_pkg.publish",
5049
"//ts/do-sync:npm_pkg.tgz",
51-
"//ts/do-sync:package.json",
5250
"//ts/knowitwhenyouseeit:npm_pkg.publish",
5351
"//ts/knowitwhenyouseeit:npm_pkg.tgz",
54-
"//ts/knowitwhenyouseeit:package.json",
5552
],
5653
entry_point = "postsubmit.js",
5754
)

js/npm/package_json/rules.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def package_json(name, targets, template, version, depSpec):
2424
],
2525
args = [
2626
"--out",
27-
"../../../$(execpath package.json)",
27+
"../../../$(execpath package_new.json)",
2828
"--base",
2929
"../../../$(location //:package_json)",
3030
"--query",
@@ -38,5 +38,5 @@ def package_json(name, targets, template, version, depSpec):
3838
"--depOnlyOut",
3939
"../../../$(execpath " + depSpec + ")",
4040
],
41-
outs = ["package.json", depSpec],
41+
outs = ["package_new.json", depSpec],
4242
)

ts/cmd/svgshot/BUILD.bazel

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
load("//bzl:rules.bzl", "bazel_lint")
2-
load("//js/npm:rules.bzl", "npm_pkg")
32
load("//ts:rules.bzl", "ts_project")
43

54
package(default_visibility = [
@@ -53,18 +52,4 @@ filegroup(
5352
srcs = glob(["examples/**/*"]) + ["README.md"],
5453
)
5554

56-
npm_pkg(
57-
name = "npm_pkg",
58-
srcs = [":project"],
59-
api_lock = ".api.lock",
60-
entry_point = "index.ts",
61-
major_version = "version/MAJOR",
62-
minor_version = "version/MINOR",
63-
patch_version = "version/PATCH",
64-
pkg_json_base = "package.template.json",
65-
readme = "README.md",
66-
version_lock = ".version.lock",
67-
visibility = ["//ci:__subpackages__"],
68-
)
69-
7055
bazel_lint(name = "bazel_lint")

ts/cmd/svgshot/testing/BUILD.bazel

Lines changed: 0 additions & 31 deletions
This file was deleted.

ts/cmd/svgshot/testing/do_not_depend_on_typescript_test.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

ts/do-sync/BUILD.bazel

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
load("//bzl:rules.bzl", "bazel_lint")
2-
load("//js:rules.bzl", "js_library")
3-
load("//js/npm:rules.bzl", "npm_pkg")
42
load("//ts:rules.bzl", "ts_project")
53

64
package(default_visibility = [
@@ -20,24 +18,4 @@ ts_project(
2018
deps = DEPS,
2119
)
2220

23-
npm_pkg(
24-
name = "npm_pkg",
25-
srcs = [":do-sync"],
26-
api_lock = ".api.lock",
27-
entry_point = "index.d.ts",
28-
major_version = "version/MAJOR",
29-
minor_version = "version/MINOR",
30-
patch_version = "version/PATCH",
31-
pkg_json_base = "package.template.json",
32-
readme = "README.md",
33-
version_lock = ".version.lock",
34-
)
35-
36-
js_library(
37-
name = "lib",
38-
srcs = ["//ts/do-sync:npm_pkg"],
39-
visibility = ["//:__subpackages__"],
40-
deps = DEPS,
41-
)
42-
4321
bazel_lint(name = "bazel_lint")

ts/do-sync/testing/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ts_project(
1414
"//:node_modules/@types/node",
1515
"//:node_modules/@types/sharp",
1616
"//:node_modules/sharp",
17-
"//ts/do-sync:lib",
17+
"//ts/do-sync",
1818
],
1919
)
2020

ts/do-sync/testing/doSync_test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import sharpT from 'sharp';
22

3-
import {
4-
doSync,
5-
JSONObject,
6-
} from '#root/ts/do-sync/npm_pkg/npm_pkg_dir/index.js';
3+
import { doSync, JSONObject } from '#root/ts/do-sync/index.js';
74

85
const pixel =
96
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==';

ts/math/conv_test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import * as cartesian from '#root/ts/math/cartesian.js';
2+
import {
3+
Cartestian as C,
4+
Euler as E,
5+
Quaternion as Q,
6+
} from '#root/ts/math/conv.js';
27
import * as euler_angle from '#root/ts/math/euler_angle.js';
38
import * as quaternion from '#root/ts/math/quaternion.js';
49

5-
import { Cartestian as C, Euler as E, Quaternion as Q } from './conv';
6-
710
describe('Conversions', () => {
811
test('Quaternion from EulerAngles', () => {
912
const eulerAngles = new euler_angle.EulerAngle(

ts/next.js/component/Redirect/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* app router.
55
*/
66

7-
import Head from 'next/head';
7+
import Head from 'next/head.js';
88
import { useRouter } from 'next/navigation';
99
import { useEffect } from 'react';
1010

ts/next.js/component/Redirect/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Head from 'next/head';
2-
import { useRouter } from 'next/router';
2+
import { useRouter } from 'next/router.js';
33
import { useEffect } from 'react';
44

55
export interface Props {

ts/rules.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def ts_project(name, visibility = None, deps = [], ignores_lint = [], resolve_js
3939

4040
_ts_project(
4141
name = name,
42-
srcs = srcs,
42+
srcs = srcs + [ "//:package_json" ],
4343
tsconfig = tsconfig,
4444
# swc injects this
4545
deps = deps + ["//:node_modules/regenerator-runtime"],

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"$schema": "https://json.schemastore.org/tsconfig",
33
"compilerOptions": {
4-
"module": "node16",
4+
"module": "esnext",
5+
"moduleResolution": "bundler",
56
"target": "es2020",
67
"strictFunctionTypes": true,
78
"esModuleInterop": true,
8-
"moduleResolution": "node16",
99
"strict": true,
1010
"jsx": "react-jsx",
1111
"resolveJsonModule": true,

0 commit comments

Comments
 (0)