Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ npm install rtp.js
// Using ESM:
import { packets as rtpJsPackets, utils as rtpJsUtils } from 'rtp.js';

// Using CJS:
// Using CommonJS:
const { packets: rtpJsPackets, utils: rtpJsUtils } = require('rtp.js');

const { RtpPacket /* etc. */ } = rtpJsPackets;
Expand Down
34 changes: 0 additions & 34 deletions babel.config-cjs.mjs

This file was deleted.

34 changes: 0 additions & 34 deletions babel.config-esm.mjs

This file was deleted.

24 changes: 0 additions & 24 deletions babel.config-jest.cjs

This file was deleted.

16 changes: 8 additions & 8 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,21 @@ const config = tsEslint.config(
yoda: 2,
},
},
// NOTE: We need to apply this only to .mts source files (and not to .mjs
// NOTE: We need to apply this only to .ts source files (and not to .mjs
// files).
...tsEslint.configs.recommendedTypeChecked.map(item => ({
...item,
files: ['src/**/*.mts'],
files: ['src/**/*.ts'],
})),
// NOTE: We need to apply this only to .mts source files (and not to .mjs
// NOTE: We need to apply this only to .ts source files (and not to .mjs
// files).
...tsEslint.configs.stylisticTypeChecked.map(item => ({
...item,
files: ['src/**/*.mts'],
files: ['src/**/*.ts'],
})),
{
name: '.mts source files',
files: ['src/**/*.mts'],
name: '.ts source files',
files: ['src/**/*.ts'],
languageOptions: {
parserOptions: {
projectService: true,
Expand Down Expand Up @@ -165,9 +165,9 @@ const config = tsEslint.config(
},
},
{
name: '.mts test files',
name: '.ts test files',
...jestEslint.configs['flat/recommended'],
files: ['src/test/**/*.mts'],
files: ['src/test/**/*.ts'],
rules: {
...jestEslint.configs['flat/recommended'].rules,
'jest/no-disabled-tests': 2,
Expand Down
16 changes: 3 additions & 13 deletions jest.config.mjs
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
const config = {
verbose: true,
testEnvironment: 'node',
testRegex: 'src/test/.*.test.mts',
// Make Jest consider .mts files as if they were ES modules.
moduleFileExtensions: ['mts', 'mjs', 'js', 'ts'],
testRegex: 'src/test/.*.test.ts',
transform: {
'^.+\\.mts?$': [
'babel-jest',
{
// We need special Babel settings for Jest plust we need it to be in
// a CJS configuration file, otherwise old versions of Node will fail
// to run Jest.
configFile: './babel.config-jest.cjs',
},
],
'^.+\\.ts?$': ['ts-jest'],
},
coveragePathIgnorePatterns: ['src/Logger.mts', 'src/test'],
coveragePathIgnorePatterns: ['src/Logger.ts', 'src/test'],
cacheDirectory: '.cache/jest',
};

Expand Down
44 changes: 4 additions & 40 deletions npm-scripts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ const RELEASE_BRANCH = 'master';

// Paths for ESLint to check. Converted to string for convenience.
const ESLINT_PATHS = [
'babel.config-cjs.mjs',
'babel.config-esm.mjs',
'babel.config-jest.cjs',
'eslint.config.mjs',
'jest.config.mjs',
'npm-scripts.mjs',
Expand All @@ -25,9 +22,6 @@ const ESLINT_IGNORE_PATTERN_ARGS = []
// Paths for Prettier to check/write. Converted to string for convenience.
const PRETTIER_PATHS = [
'README.md',
'babel.config-cjs.mjs',
'babel.config-esm.mjs',
'babel.config-jest.cjs',
'eslint.config.mjs',
'jest.config.mjs',
'npm-scripts.mjs',
Expand Down Expand Up @@ -161,50 +155,20 @@ function buildTypescript() {

deleteLib();

// Generate .mjs ESM files in lib/.
executeCmd(
'babel ./src --config-file "./babel.config-esm.mjs" --out-dir "./lib" --ignore "./src/test/**" --extensions .mts --out-file-extension .mjs --source-maps true'
);

// Generate .cjs CJS files in lib/.
executeCmd(
'babel ./src --config-file "./babel.config-cjs.mjs" --out-dir "./lib" --ignore "./src/test/**" --extensions .mts --out-file-extension .cjs --source-maps true'
);

// Generate .d.mts TypeScript declaration files in lib/.
// Generate .js CommonJS code and .d.ts TypeScript declaration files in lib/.
executeCmd('tsc');

// Delete generated TypeScript declaration files in lib/test/ because we don't
// want to expose them.
// Delete generated lib/test because we don't to expose them in the published
// library.
fs.rmSync('lib/test', { recursive: true, force: true });
}

async function watchTypescript() {
logInfo('watchTypescript()');

// NOTE: Load dep on demand since it's a devDependency.
const { concurrently } = await import('concurrently');

deleteLib();

concurrently([
// Generate .mjs ESM files in lib/ and watch for changes.
{
name: 'babel ESM',
command:
'babel ./src --config-file "./babel.config-esm.mjs" --out-dir "./lib" --ignore "./src/test/**" --extensions .mts --out-file-extension .mjs --source-maps true --watch',
raw: true,
},
// Generate .cjs CJS files in lib/ and watch for changes.
{
name: 'babel CJS',
command:
'babel ./src --config-file "./babel.config-cjs.mjs" --out-dir "./lib" --ignore "./src/test/**" --extensions .mts --out-file-extension .cjs --source-maps true --watch',
raw: true,
},
// Generate .d.mts TypeScript declaration files in lib/ and watch for changes.
{ name: 'tsc', command: 'tsc --watch', prefixColors: 'auto', raw: true },
]);
executeCmd('tsc --watch');
}

function lint() {
Expand Down
Loading