Skip to content

Commit

Permalink
fix: correct various issues with cjs and esm dists
Browse files Browse the repository at this point in the history
  • Loading branch information
fallenoak authored Nov 26, 2023
1 parent 98b852e commit bcea7eb
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 33 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
"author": "Wowser Contributors",
"repository": "github:wowserhq/io",
"license": "MIT",
"main": "./dist/cjs/index.mjs",
"module": "./dist/esm/index.mjs",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"exports": {
"require": "./dist/cjs/index.mjs",
"import": "./dist/esm/index.mjs"
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js"
},
"types": "./dist/types/index.d.mts",
"types": "./dist/types/index.d.ts",
"scripts": {
"build": "npm run clean && npm run test && npm run build:cjs && npm run build:esm && npm run build:types && npm run build:package",
"build:cjs": "tsc --module commonjs --outDir ./dist/cjs",
Expand Down
14 changes: 6 additions & 8 deletions src/lib/index.mts → src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import ArrayIo, { ArrayOptions } from './type/ArrayIo.mjs';
import StringIo, { StringOptions } from './type/StringIo.mjs';
import StructIo, { StructFields, StructOptions } from './type/StructIo.mjs';
import TlvIo, { TlvValueCallback } from './type/TlvIo.mjs';
import { validateType } from './util.mjs';
import ArrayIo, { ArrayOptions } from './type/ArrayIo.js';
import StringIo, { StringOptions } from './type/StringIo.js';
import StructIo, { StructFields, StructOptions } from './type/StructIo.js';
import TlvIo, { TlvValueCallback } from './type/TlvIo.js';
import { validateType } from './util.js';

const array = (type: IoType, options: ArrayOptions) =>
new ArrayIo(type, options);
Expand Down Expand Up @@ -158,7 +158,7 @@ const float64le = {
write: (stream: IoStream, value: number) => stream.writeFloat64Le(value),
};

const io = {
export {
array,
string,
struct,
Expand Down Expand Up @@ -191,5 +191,3 @@ const io = {
float64le,
validateType,
};

export default io;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Endianness } from '../util.mjs';
import { Endianness } from '../util.js';

class ArrayBufferStream implements IoStream {
#buffer: ArrayBuffer;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/stream/FsStream.mts → src/lib/stream/FsStream.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from '../shim/fs.cjs';
import { Endianness } from '../util.mjs';
import { Endianness } from '../util.js';

class FsStream implements IoStream {
#fd: number;
Expand Down
6 changes: 3 additions & 3 deletions src/lib/stream/util.mts → src/lib/stream/util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ArrayBufferStream from './ArrayBufferStream.mjs';
import FsStream from './FsStream.mjs';
import { Endianness } from '../util.mjs';
import ArrayBufferStream from './ArrayBufferStream.js';
import FsStream from './FsStream.js';
import { Endianness } from '../util.js';

const isStream = (ref: any) => {
if (ref instanceof ArrayBufferStream) {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/type/ArrayIo.mts → src/lib/type/ArrayIo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { validateType } from '../util.mjs';
import { openStream } from '../stream/util.mjs';
import { validateType } from '../util.js';
import { openStream } from '../stream/util.js';

type ArrayOptions = {
size?: number;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/type/StringIo.mts → src/lib/type/StringIo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { resolveValue } from '../util.mjs';
import { openStream } from '../stream/util.mjs';
import { resolveValue } from '../util.js';
import { openStream } from '../stream/util.js';

const STRING_TERMINATOR = 0x00;
const DEFAULT_ENCODING = 'utf-8';
Expand Down
4 changes: 2 additions & 2 deletions src/lib/type/StructIo.mts → src/lib/type/StructIo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Endianness, validateType } from '../util.mjs';
import { openStream } from '../stream/util.mjs';
import { Endianness, validateType } from '../util.js';
import { openStream } from '../stream/util.js';

type StructFields = Record<string, IoType>;

Expand Down
4 changes: 2 additions & 2 deletions src/lib/type/TlvIo.mts → src/lib/type/TlvIo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Endianness } from '../util.mjs';
import { openStream } from '../stream/util.mjs';
import { Endianness } from '../util.js';
import { openStream } from '../stream/util.js';

type TlvValueCallback = (
type: string | number,
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions src/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
5 changes: 1 addition & 4 deletions src/spec/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"moduleResolution": "node16",
"compilerOptions": {
"allowImportingTsExtensions": true
}
"moduleResolution": "node16"
}
6 changes: 3 additions & 3 deletions src/spec/util.spec.mts → src/spec/util.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, test } from 'vitest';
import FsStream from '../lib/stream/FsStream.mts';
import ArrayBufferStream from '../lib/stream/ArrayBufferStream.mts';
import { openStream } from '../lib/stream/util.mjs';
import FsStream from '../lib/stream/FsStream.js';
import ArrayBufferStream from '../lib/stream/ArrayBufferStream.js';
import { openStream } from '../lib/stream/util.js';

describe('getStream', () => {
test('returns FsStream object when given path to file', () => {
Expand Down

0 comments on commit bcea7eb

Please sign in to comment.