Skip to content

Commit

Permalink
fix: ESM and CJS
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDevMinerTV committed Jun 6, 2024
1 parent 1df1f94 commit 876591c
Show file tree
Hide file tree
Showing 62 changed files with 618 additions and 510 deletions.
11 changes: 11 additions & 0 deletions .changeset/lazy-dancers-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@slimevr/firmware-protocol-debugger-shared': patch
'@slimevr/firmware-protocol-debugger-utils': patch
'slimevr-firmware-protocol-debugger-gui': patch
'@slimevr/emulated-tracker-demo': patch
'@slimevr/firmware-protocol': patch
'@slimevr/tracker-emulation': patch
'@slimevr/common': patch
---

fixed ESM and CJS stuff
16 changes: 11 additions & 5 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@
"name": "@slimevr/common",
"version": "0.1.1",
"license": "(MIT OR Apache-2.0)",
"main": "dist/cjs/index.js",
"types": "dist/dts/index.d.ts",
"module": "dist/esm/index.js",
"type": "module",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/dts/index.d.ts",
"exports": {
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js",
"types": "./dist/dts/index.d.ts",
"default": "./dist/esm/index.js"
},
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "pnpm run build:esm && pnpm run build:cjs",
"build:esm": "tsc",
"build:cjs": "babel dist/esm --plugins @babel/transform-export-namespace-from --plugins @babel/transform-modules-commonjs --out-dir dist/cjs --source-maps",
"build:esm": "tsc -p tsconfig.esm.json",
"build:cjs": "tsc -p tsconfig.cjs.json",
"prepack": "pnpm build",
"dev": "pnpm build:esm -- -w",
"clean": "rimraf dist"
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './utils';
export * from './utils.js';
8 changes: 8 additions & 0 deletions packages/common/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "@slimevr/tsconfig/node-lib-cjs.json",
"include": ["src/**/*.ts"],
"exclude": ["dist", "build", "node_modules"],
"compilerOptions": {
"outDir": "dist/cjs"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "@slimevr/tsconfig/node-lib.json",
"extends": "@slimevr/tsconfig/node-lib-esm.json",
"include": ["src/**/*.ts"],
"exclude": ["dist", "build", "node_modules"],
"compilerOptions": {
Expand Down
16 changes: 11 additions & 5 deletions packages/firmware-protocol-debugger-shared/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
{
"name": "@slimevr/firmware-protocol-debugger-shared",
"version": "0.0.9",
"main": "dist/cjs/index.js",
"types": "dist/dts/index.d.ts",
"module": "dist/esm/index.js",
"type": "module",
"main": "./dist/cjs/index.js",
"types": "./dist/dts/index.d.ts",
"module": "./dist/esm/index.js",
"exports": {
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js",
"types": "./dist/dts/index.d.ts",
"default": "./dist/esm/index.js"
},
"private": true,
"scripts": {
"build": "pnpm run build:esm && pnpm run build:cjs",
"build:esm": "tsc",
"build:cjs": "babel dist/esm --plugins @babel/transform-export-namespace-from --plugins @babel/transform-modules-commonjs --out-dir dist/cjs --source-maps",
"build:esm": "tsc -p tsconfig.esm.json",
"build:cjs": "tsc -p tsconfig.cjs.json",
"dev": "pnpm run build:esm -- -w",
"clean": "rimraf dist"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/firmware-protocol-debugger-shared/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './IPCMessages';
export * from './IPCMessages.js';
8 changes: 8 additions & 0 deletions packages/firmware-protocol-debugger-shared/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "@slimevr/tsconfig/node-lib-cjs.json",
"include": ["src/**/*.ts"],
"exclude": ["dist", "build", "node_modules"],
"compilerOptions": {
"outDir": "dist/cjs",
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "@slimevr/tsconfig/node-lib.json",
"extends": "@slimevr/tsconfig/node-lib-esm.json",
"include": ["src/**/*.ts"],
"exclude": ["dist", "build", "node_modules"],
"compilerOptions": {
Expand Down
16 changes: 11 additions & 5 deletions packages/firmware-protocol-debugger-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
{
"name": "@slimevr/firmware-protocol-debugger-utils",
"version": "0.0.9",
"main": "dist/cjs/index.js",
"types": "dist/dts/index.d.ts",
"module": "dist/esm/index.js",
"type": "module",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/dts/index.d.ts",
"exports": {
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js",
"types": "./dist/dts/index.d.ts",
"default": "./dist/esm/index.js"
},
"private": true,
"scripts": {
"build": "pnpm run build:esm && pnpm run build:cjs",
"build:esm": "tsc",
"build:cjs": "babel dist/esm --plugins @babel/transform-export-namespace-from --plugins @babel/transform-modules-commonjs --out-dir dist/cjs --source-maps",
"build:esm": "tsc -p tsconfig.esm.json",
"build:cjs": "tsc -p tsconfig.cjs.json",
"dev": "pnpm run build:esm -- -w",
"clean": "rimraf dist"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MACAddress } from '@slimevr/common';
import type { Events } from './Events';
import { serializeTracker } from './serialization';
import type { Tracker } from './Tracker';
import type { Events } from './Events.js';
import { serializeTracker } from './serialization.js';
import type { Tracker } from './Tracker.js';

export class ConnectionTracker {
private readonly connectionsByMAC = new Map<string, Tracker>();
Expand Down
10 changes: 5 additions & 5 deletions packages/firmware-protocol-debugger-utils/src/Sensor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import {
ServerBoundSignalStrengthPacket,
ServerBoundTemperaturePacket
} from '@slimevr/firmware-protocol';
import { Events } from './Events';
import { shouldDumpRotationDataPacketsProcessed, shouldDumpRotationDataPacketsRaw } from './flags';
import { serializeTracker } from './serialization';
import { Tracker } from './Tracker';
import { VectorAggregator } from './VectorAggretator';
import { Events } from './Events.js';
import { shouldDumpRotationDataPacketsProcessed, shouldDumpRotationDataPacketsRaw } from './flags.js';
import { serializeTracker } from './serialization.js';
import { Tracker } from './Tracker.js';
import { VectorAggregator } from './VectorAggretator.js';

export class Sensor {
private readonly rotation = new VectorAggregator<Quaternion>(4, Quaternion.zero());
Expand Down
12 changes: 6 additions & 6 deletions packages/firmware-protocol-debugger-utils/src/Tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ import {
} from '@slimevr/firmware-protocol';
import { Socket } from 'dgram';
import { createWriteStream, WriteStream } from 'fs';
import type { ConnectionTracker } from './ConnectionTracker';
import { Events } from './Events';
import type { ConnectionTracker } from './ConnectionTracker.js';
import { Events } from './Events.js';
import {
correctionDataDumpFile,
fusedIMUDataDumpFile,
Expand All @@ -51,10 +51,10 @@ import {
shouldDumpFusedDataRaw,
shouldDumpRawIMUDataProcessed,
shouldDumpRawIMUDataRaw
} from './flags';
import { Sensor } from './Sensor';
import { serializeTracker } from './serialization';
import { VectorAggregator } from './VectorAggretator';
} from './flags.js';
import { Sensor } from './Sensor.js';
import { serializeTracker } from './serialization.js';
import { VectorAggregator } from './VectorAggretator.js';

const serverFeatures = (() => {
const flags = new Map<ServerFeatureFlag, boolean>();
Expand Down
16 changes: 8 additions & 8 deletions packages/firmware-protocol-debugger-utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export { ConnectionTracker } from './ConnectionTracker';
export { newEvents } from './Events';
export type { EmittableEvents, Events } from './Events';
export * as flags from './flags';
export * as serialization from './serialization';
export { Tracker } from './Tracker';
export * as utils from './utils';
export { VectorAggregator } from './VectorAggretator';
export { ConnectionTracker } from './ConnectionTracker.js';
export { newEvents } from './Events.js';
export type { EmittableEvents, Events } from './Events.js';
export * as flags from './flags.js';
export * as serialization from './serialization.js';
export { Tracker } from './Tracker.js';
export * as utils from './utils.js';
export { VectorAggregator } from './VectorAggretator.js';
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SerializedSensor, SerializedTracker } from '@slimevr/firmware-protocol-debugger-shared';
import { Sensor } from './Sensor';
import { Tracker } from './Tracker';
import { Sensor } from './Sensor.js';
import { Tracker } from './Tracker.js';

export const serializeTracker = (tracker: Tracker): SerializedTracker => {
const sensors: Record<string, SerializedSensor> = {};
Expand Down
8 changes: 8 additions & 0 deletions packages/firmware-protocol-debugger-utils/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "@slimevr/tsconfig/node-lib-cjs.json",
"include": ["src/**/*.ts"],
"exclude": ["dist", "build", "node_modules"],
"compilerOptions": {
"outDir": "dist/cjs",
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "@slimevr/tsconfig/node-lib.json",
"extends": "@slimevr/tsconfig/node-lib-esm.json",
"include": ["src/**/*.ts"],
"exclude": ["dist", "build", "node_modules"],
"compilerOptions": {
Expand Down
18 changes: 12 additions & 6 deletions packages/firmware-protocol/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
{
"name": "@slimevr/firmware-protocol",
"version": "0.6.2",
"main": "dist/cjs/index.js",
"types": "dist/dts/index.d.ts",
"module": "dist/esm/index.js",
"type": "module",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/dts/index.d.ts",
"exports": {
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js",
"types": "./dist/dts/index.d.ts",
"default": "./dist/esm/index.js"
},
"license": "(MIT OR Apache-2.0)",
"author": {
"name": "DevMiner",
Expand All @@ -22,10 +28,10 @@
},
"scripts": {
"build": "pnpm run build:esm && pnpm run build:cjs",
"build:esm": "tsc",
"build:cjs": "babel dist/esm --plugins @babel/transform-export-namespace-from --plugins @babel/transform-modules-commonjs --out-dir dist/cjs --source-maps",
"build:esm": "tsc -p tsconfig.esm.json",
"build:cjs": "tsc -p tsconfig.cjs.json",
"prepack": "pnpm build",
"dev": "pnpm build:dev -- -w",
"dev": "pnpm build:esm -- -w",
"clean": "rimraf dist"
},
"dependencies": {
Expand Down
6 changes: 3 additions & 3 deletions packages/firmware-protocol/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './constants';
export * from './packets';
export * from './FeatureFlags';
export * from './constants.js';
export * from './FeatureFlags.js';
export * from './packets/index.js';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ServerFeatureFlags } from '../FeatureFlags';
import { Packet } from './Packet';
import { ServerFeatureFlags } from '../FeatureFlags.js';
import { Packet } from './Packet.js';

export class DeviceBoundFeatureFlagsPacket extends Packet {
constructor(readonly flags: ServerFeatureFlags) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Packet } from './Packet';
import { Packet } from './Packet.js';

export class DeviceBoundHandshakePacket extends Packet {
constructor() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Packet } from './Packet';
import { Packet } from './Packet.js';

export class DeviceBoundHeartbeatPacket extends Packet {
constructor() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Packet } from './Packet';
import { Packet } from './Packet.js';

export class DeviceBoundPingPacket extends Packet {
constructor(readonly id: number) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SensorStatus } from '../constants';
import { PacketWithSensorId } from './Packet';
import { SensorStatus } from '../constants.js';
import { PacketWithSensorId } from './Packet.js';

export class DeviceBoundSensorInfoPacket extends PacketWithSensorId {
constructor(sensorId: number, readonly sensorStatus: SensorStatus) {
Expand Down
52 changes: 26 additions & 26 deletions packages/firmware-protocol/src/packets/PacketParser.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import { DeviceBoundFeatureFlagsPacket } from './DeviceBoundFeatureFlagsPacket';
import { DeviceBoundHandshakePacket } from './DeviceBoundHandshakePacket';
import { DeviceBoundHeartbeatPacket } from './DeviceBoundHeartbeatPacket';
import { DeviceBoundPingPacket } from './DeviceBoundPingPacket';
import { DeviceBoundSensorInfoPacket } from './DeviceBoundSensorInfoPacket';
import { Packet } from './Packet';
import { ServerBoundAccelPacket } from './ServerBoundAccelPacket';
import { ServerBoundBatteryLevelPacket } from './ServerBoundBatteryLevelPacket';
import { ServerBoundBundlePacket } from './ServerBoundBundlePacket';
import { ServerBoundCalibrationFinishedPacket } from './ServerBoundCalibrationFinishedPacket';
import { ServerBoundErrorPacket } from './ServerBoundErrorPacket';
import { ServerBoundFeatureFlagsPacket } from './ServerBoundFeatureFlagsPacket';
import { ServerBoundGyroPacket } from './ServerBoundGyroPacket';
import { ServerBoundHandshakePacket } from './ServerBoundHandshakePacket';
import { ServerBoundHeartbeatPacket } from './ServerBoundHeartbeatPacket';
import { ServerBoundMagnetometerAccuracyPacket } from './ServerBoundMagnetometerAccuracy';
import { ServerBoundPongPacket } from './ServerBoundPongPacket';
import { ServerBoundRawCalibrationDataPacket } from './ServerBoundRawCalibrationDataPacket';
import { ServerBoundRotationDataPacket } from './ServerBoundRotationDataPacket';
import { ServerBoundRotationPacket } from './ServerBoundRotationPacket';
import { ServerBoundSensorInfoPacket } from './ServerBoundSensorInfoPacket';
import { ServerBoundSignalStrengthPacket } from './ServerBoundSignalStrengthPacket';
import { ServerBoundTapPacket } from './ServerBoundTapPacket';
import { ServerBoundTemperaturePacket } from './ServerBoundTemperaturePacket';
import { ServerBoundUserActionPacket } from './ServerBoundUserActionPacket';
import { InspectionPacketParser } from './inspection/PacketParser';
import { DeviceBoundFeatureFlagsPacket } from './DeviceBoundFeatureFlagsPacket.js';
import { DeviceBoundHandshakePacket } from './DeviceBoundHandshakePacket.js';
import { DeviceBoundHeartbeatPacket } from './DeviceBoundHeartbeatPacket.js';
import { DeviceBoundPingPacket } from './DeviceBoundPingPacket.js';
import { DeviceBoundSensorInfoPacket } from './DeviceBoundSensorInfoPacket.js';
import { Packet } from './Packet.js';
import { ServerBoundAccelPacket } from './ServerBoundAccelPacket.js';
import { ServerBoundBatteryLevelPacket } from './ServerBoundBatteryLevelPacket.js';
import { ServerBoundBundlePacket } from './ServerBoundBundlePacket.js';
import { ServerBoundCalibrationFinishedPacket } from './ServerBoundCalibrationFinishedPacket.js';
import { ServerBoundErrorPacket } from './ServerBoundErrorPacket.js';
import { ServerBoundFeatureFlagsPacket } from './ServerBoundFeatureFlagsPacket.js';
import { ServerBoundGyroPacket } from './ServerBoundGyroPacket.js';
import { ServerBoundHandshakePacket } from './ServerBoundHandshakePacket.js';
import { ServerBoundHeartbeatPacket } from './ServerBoundHeartbeatPacket.js';
import { ServerBoundMagnetometerAccuracyPacket } from './ServerBoundMagnetometerAccuracy.js';
import { ServerBoundPongPacket } from './ServerBoundPongPacket.js';
import { ServerBoundRawCalibrationDataPacket } from './ServerBoundRawCalibrationDataPacket.js';
import { ServerBoundRotationDataPacket } from './ServerBoundRotationDataPacket.js';
import { ServerBoundRotationPacket } from './ServerBoundRotationPacket.js';
import { ServerBoundSensorInfoPacket } from './ServerBoundSensorInfoPacket.js';
import { ServerBoundSignalStrengthPacket } from './ServerBoundSignalStrengthPacket.js';
import { ServerBoundTapPacket } from './ServerBoundTapPacket.js';
import { ServerBoundTemperaturePacket } from './ServerBoundTemperaturePacket.js';
import { ServerBoundUserActionPacket } from './ServerBoundUserActionPacket.js';
import { InspectionPacketParser } from './inspection/PacketParser.js';

const bundle = (num: bigint, packet: Packet | null) => [num, packet] as const;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Vector } from '@slimevr/common';
import { Packet } from './Packet';
import { Packet } from './Packet.js';

export class ServerBoundAccelPacket extends Packet {
constructor(readonly sensorId: number | null, readonly acceleration: Vector) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Packet } from './Packet';
import { Packet } from './Packet.js';

export class ServerBoundBatteryLevelPacket extends Packet {
constructor(readonly voltage: number, readonly percentage: number) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Packet } from './Packet';
import { parse } from './PacketParser';
import { Packet } from './Packet.js';
import { parse } from './PacketParser.js';

export class ServerBoundBundlePacket extends Packet {
constructor(readonly packets: Packet[]) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PacketWithSensorId } from './Packet';
import { PacketWithSensorId } from './Packet.js';

export class ServerBoundCalibrationFinishedPacket extends PacketWithSensorId {
constructor(sensorId: number, readonly dataType: number) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PacketWithSensorId } from './Packet';
import { PacketWithSensorId } from './Packet.js';

export class ServerBoundErrorPacket extends PacketWithSensorId {
constructor(sensorId: number, readonly reason: number) {
Expand Down
Loading

0 comments on commit 876591c

Please sign in to comment.