Skip to content

Commit

Permalink
Allow ts_project to see package.json (for esmodule resolution).
Browse files Browse the repository at this point in the history
  • Loading branch information
Zemnmez committed Mar 1, 2024
1 parent 772e6d9 commit fb775a6
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 120 deletions.
36 changes: 29 additions & 7 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 0 additions & 18 deletions ci/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,6 @@ js_binary(
"//VERSION",
"//project/ck3/recursive-vassals:mod_zip",
"//project/ck3/recursive-vassals:patch",
"//ts/cmd/svgshot:npm_pkg.publish",
"//ts/cmd/svgshot:npm_pkg.tgz",
"//ts/cmd/svgshot:package.json",
"//ts/do-sync:npm_pkg.publish",
"//ts/do-sync:npm_pkg.tgz",
"//ts/do-sync:package.json",
"//ts/knowitwhenyouseeit:npm_pkg.publish",
"//ts/knowitwhenyouseeit:npm_pkg.tgz",
"//ts/knowitwhenyouseeit:package.json",
],
entry_point = "postsubmit.js",
)
Expand All @@ -63,15 +54,6 @@ js_binary(
"//VERSION",
"//project/ck3/recursive-vassals:mod_zip",
"//project/ck3/recursive-vassals:patch",
"//ts/cmd/svgshot:npm_pkg.publish",
"//ts/cmd/svgshot:npm_pkg.tgz",
"//ts/cmd/svgshot:package.json",
"//ts/do-sync:npm_pkg.publish",
"//ts/do-sync:npm_pkg.tgz",
"//ts/do-sync:package.json",
"//ts/knowitwhenyouseeit:npm_pkg.publish",
"//ts/knowitwhenyouseeit:npm_pkg.tgz",
"//ts/knowitwhenyouseeit:package.json",
],
entry_point = "submit.js",
)
Expand Down
4 changes: 2 additions & 2 deletions js/npm/package_json/rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def package_json(name, targets, template, version, depSpec):
],
args = [
"--out",
"../../../$(execpath package.json)",
"../../../$(execpath package_new.json)",
"--base",
"../../../$(location //:package_json)",
"--query",
Expand All @@ -38,5 +38,5 @@ def package_json(name, targets, template, version, depSpec):
"--depOnlyOut",
"../../../$(execpath " + depSpec + ")",
],
outs = ["package.json", depSpec],
outs = ["package_new.json", depSpec],
)
15 changes: 0 additions & 15 deletions ts/cmd/svgshot/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
load("//bzl:rules.bzl", "bazel_lint")
load("//js/npm:rules.bzl", "npm_pkg")
load("//ts:rules.bzl", "ts_project")

package(default_visibility = [
Expand Down Expand Up @@ -53,18 +52,4 @@ filegroup(
srcs = glob(["examples/**/*"]) + ["README.md"],
)

npm_pkg(
name = "npm_pkg",
srcs = [":project"],
api_lock = ".api.lock",
entry_point = "index.ts",
major_version = "version/MAJOR",
minor_version = "version/MINOR",
patch_version = "version/PATCH",
pkg_json_base = "package.template.json",
readme = "README.md",
version_lock = ".version.lock",
visibility = ["//ci:__subpackages__"],
)

bazel_lint(name = "bazel_lint")
31 changes: 0 additions & 31 deletions ts/cmd/svgshot/testing/BUILD.bazel

This file was deleted.

13 changes: 0 additions & 13 deletions ts/cmd/svgshot/testing/do_not_depend_on_typescript_test.ts

This file was deleted.

22 changes: 0 additions & 22 deletions ts/do-sync/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
load("//bzl:rules.bzl", "bazel_lint")
load("//js:rules.bzl", "js_library")
load("//js/npm:rules.bzl", "npm_pkg")
load("//ts:rules.bzl", "ts_project")

package(default_visibility = [
Expand All @@ -20,24 +18,4 @@ ts_project(
deps = DEPS,
)

npm_pkg(
name = "npm_pkg",
srcs = [":do-sync"],
api_lock = ".api.lock",
entry_point = "index.d.ts",
major_version = "version/MAJOR",
minor_version = "version/MINOR",
patch_version = "version/PATCH",
pkg_json_base = "package.template.json",
readme = "README.md",
version_lock = ".version.lock",
)

js_library(
name = "lib",
srcs = ["//ts/do-sync:npm_pkg"],
visibility = ["//:__subpackages__"],
deps = DEPS,
)

bazel_lint(name = "bazel_lint")
2 changes: 1 addition & 1 deletion ts/do-sync/testing/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ts_project(
"//:node_modules/@types/node",
"//:node_modules/@types/sharp",
"//:node_modules/sharp",
"//ts/do-sync:lib",
"//ts/do-sync",
],
)

Expand Down
5 changes: 1 addition & 4 deletions ts/do-sync/testing/doSync_test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import sharpT from 'sharp';

import {
doSync,
JSONObject,
} from '#root/ts/do-sync/npm_pkg/npm_pkg_dir/index.js';
import { doSync, JSONObject } from '#root/ts/do-sync/index.js';

const pixel =
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==';
Expand Down
7 changes: 5 additions & 2 deletions ts/math/conv_test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import * as cartesian from '#root/ts/math/cartesian.js';
import {
Cartestian as C,
Euler as E,
Quaternion as Q,
} from '#root/ts/math/conv.js';
import * as euler_angle from '#root/ts/math/euler_angle.js';
import * as quaternion from '#root/ts/math/quaternion.js';

import { Cartestian as C, Euler as E, Quaternion as Q } from './conv';

describe('Conversions', () => {
test('Quaternion from EulerAngles', () => {
const eulerAngles = new euler_angle.EulerAngle(
Expand Down
2 changes: 1 addition & 1 deletion ts/next.js/component/Redirect/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* app router.
*/

import Head from 'next/head';
import Head from 'next/head.js';
import { useRouter } from 'next/navigation';
import { useEffect } from 'react';

Expand Down
2 changes: 1 addition & 1 deletion ts/next.js/component/Redirect/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Head from 'next/head';
import { useRouter } from 'next/router';
import { useRouter } from 'next/router.js';
import { useEffect } from 'react';

export interface Props {
Expand Down
2 changes: 1 addition & 1 deletion ts/rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def ts_project(name, visibility = None, deps = [], ignores_lint = [], resolve_js

_ts_project(
name = name,
srcs = srcs,
srcs = srcs + ["//:package_json"],
tsconfig = tsconfig,
# swc injects this
deps = deps + ["//:node_modules/regenerator-runtime"],
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"module": "node16",
"module": "esnext",
"moduleResolution": "bundler",
"target": "es2020",
"strictFunctionTypes": true,
"esModuleInterop": true,
"moduleResolution": "node16",
"strict": true,
"jsx": "react-jsx",
"resolveJsonModule": true,
Expand Down

0 comments on commit fb775a6

Please sign in to comment.