Skip to content

Commit 6c01906

Browse files
committed
Switch back from ESM to commonJs
1 parent 5fc8cc3 commit 6c01906

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+217
-1515
lines changed
File renamed without changes.

broadway/Player.cjs broadway/Player.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ p.decode(<binary>);
2424
(function (root, factory) {
2525
if (typeof define === 'function' && define.amd) {
2626
// AMD. Register as an anonymous module.
27-
define(['./Decoder.cjs', './YUVCanvas.cjs'], factory);
27+
define(['./Decoder.js', './YUVCanvas.js'], factory);
2828
} else if (typeof exports === 'object') {
2929
// Node. Does not work with strict CommonJS, but
3030
// only CommonJS-like environments that support module.exports,
3131
// like Node.
32-
module.exports = factory(require('./Decoder.cjs'), require('./YUVCanvas.cjs'));
32+
module.exports = factory(require('./Decoder.js'), require('./YUVCanvas.js'));
3333
} else {
3434
// Browser globals (root is window)
3535
root.Player = factory(root.Decoder, root.YUVCanvas);
@@ -50,7 +50,7 @@ p.decode(<binary>);
5050

5151
this.nowValue = nowValue;
5252

53-
this._config.workerFile = this._config.workerFile || 'Decoder.cjs';
53+
this._config.workerFile = this._config.workerFile || 'Decoder.js';
5454
if (this._config.preserveDrawingBuffer) {
5555
this._config.contextOptions = this._config.contextOptions || {};
5656
this._config.contextOptions.preserveDrawingBuffer = true;
File renamed without changes.

build.server.ts build.server.mts

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import * as esbuild from 'esbuild';
2+
import { join } from 'path';
23

34
console.info('- esbuild server...');
45

5-
await esbuild.build({
6+
const outPath = './build';
7+
8+
export const esbuildSeverConfig: esbuild.BuildOptions = {
69
entryPoints: ['./src/server/main.ts'],
7-
outfile: './build/server.js',
10+
outfile: join(outPath, 'server.js'),
811
platform: 'node',
912
sourcemap: 'external',
1013
external: ['onoff'],
1114
bundle: true,
1215
minify: true,
13-
// format: 'esm'
14-
});
16+
};
17+
18+
await esbuild.build(esbuildSeverConfig);
1519

1620
console.info('- build server complete');

build.site.ts build.site.mts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const copyToBuild = (folder: string, file: string) =>
2323
console.info('- copy dependencies...');
2424

2525
await Promise.all([
26-
copyToBuild('./broadway', 'Decoder.cjs'),
26+
copyToBuild('./broadway', 'Decoder.js'),
2727
copyToBuild('./broadway', 'avc.wasm'),
2828
copyToBuild('./src/site/public', 'index.html'),
2929
copyToBuild('./src/site/public', 'favicon.ico'),

package.json

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,32 @@
11
{
22
"name": "raspicam",
33
"version": "2.0.0",
4-
"type": "module",
5-
"exports": "./src/server/main.ts",
4+
"type": "commonjs",
65
"browser": {
76
"stream": false
87
},
98
"author": "Patrick Matt",
109
"license": "MIT",
11-
"node": ">=14.16",
1210
"scripts": {
13-
"start:site": "ts-node-esm ./serve.site.ts",
14-
"start:server": "ts-node-esm src/server/main.ts",
11+
"start:site": "ts-node-esm ./serve.site.mts",
12+
"start:server": "npm run build:server && node ./build/server.js",
1513
"code:check": "npm run code:check-eslint && yarn code:check-tsc",
1614
"code:check-eslint": "eslint --fix ./src/",
1715
"code:check-tsc": "tsc -p ./tsconfig.json",
1816
"build": "npm run build:site && npm run build:server",
19-
"build:server": "ts-node-esm ./build.server.ts",
20-
"build:site": "ts-node-esm ./build.site.ts"
17+
"build:server": "ts-node-esm ./build.server.mts",
18+
"build:site": "ts-node-esm ./build.site.mts"
2119
},
2220
"dependencies": {
2321
"buffer": "^6.0.3",
24-
"chalk": "^5.2.0",
22+
"chalk": "^4.1.2",
2523
"express": "^4.18.2",
2624
"jmuxer": "^2.0.5",
2725
"onoff": "^6.0.3",
2826
"react": "^18.2.0",
2927
"react-dom": "^18.2.0",
3028
"react-router-dom": "^6.6.2",
31-
"styled-components": "^6.0.0-beta.9",
29+
"styled-components": "^5.3.6",
3230
"styled-normalize": "^8.0.7",
3331
"yargs": "^17.6.2"
3432
},

serve.site.mts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import * as esbuild from 'esbuild';
2+
import { esbuildSiteConfig } from './build.site.mjs';
3+
4+
await esbuild.context(esbuildSiteConfig).then((x) => x.watch());
5+
6+
console.info('- watch site');

serve.site.ts

-158
This file was deleted.

src/server/button.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Gpio } from 'onoff';
2-
import { RaspiControl } from './control.js';
3-
import { createLogger } from './logger.js';
4-
import { SettingsHelper } from './settings.js';
2+
import { RaspiControl } from './control';
3+
import { createLogger } from './logger';
4+
import { SettingsHelper } from './settings';
55

66
const logger = createLogger('button');
77

src/server/control.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import path from 'path';
22
import internal from 'stream';
3-
import { getIsoDataTime } from '../shared/helperFunctions.js';
4-
import { RaspiMode, RaspiStatus } from '../shared/settings/types.js';
5-
import { createLogger } from './logger.js';
6-
import { spawnProcess } from './process.js';
7-
import { SettingsHelper } from './settings.js';
8-
import { photosAbsPath } from './watcher.js';
3+
import { getIsoDataTime } from '../shared/helperFunctions';
4+
import { RaspiMode, RaspiStatus } from '../shared/settings/types';
5+
import { createLogger } from './logger';
6+
import { spawnProcess } from './process';
7+
import { SettingsHelper } from './settings';
8+
import { photosAbsPath } from './watcher';
99

1010
const logger = createLogger('control');
1111

src/server/main.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import http from 'http';
2-
import { createButtonControl } from './button.js';
3-
import { createRaspiControl } from './control.js';
4-
import { createLogger } from './logger.js';
5-
import { server } from './server.js';
6-
import { createSettingsHelper } from './settings.js';
7-
import { createFileWatcher } from './watcher.js';
2+
import { createButtonControl } from './button';
3+
import { createRaspiControl } from './control';
4+
import { createLogger } from './logger';
5+
import { server } from './server';
6+
import { createSettingsHelper } from './settings';
7+
import { createFileWatcher } from './watcher';
88
import yargs from 'yargs/yargs';
99

1010
const logger = createLogger('server');

src/server/process.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ChildProcess, StdioOptions, spawn } from 'child_process';
22
import { Readable } from 'stream';
3-
import { createLogger } from './logger.js';
3+
import { createLogger } from './logger';
44

55
const logger = createLogger('process');
66

src/server/server.ts

+8-13
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
import express from 'express';
22
import path from 'path';
3-
import { isDefined } from '../shared/helperFunctions.js';
4-
import {
5-
RaspiGallery,
6-
RaspiStatus,
7-
GenericSettingDesc,
8-
Setting,
9-
} from '../shared/settings/types.js';
10-
import { ButtonControl } from './button.js';
11-
import { curDirName } from './common.js';
12-
import { RaspiControl } from './control.js';
13-
import { SettingsBase, SettingsHelper } from './settings.js';
14-
import { splitJpeg } from './splitJpeg.js';
15-
import { FileWatcher } from './watcher.js';
3+
import { isDefined } from '../shared/helperFunctions';
4+
import { RaspiGallery, RaspiStatus, GenericSettingDesc, Setting } from '../shared/settings/types';
5+
import { ButtonControl } from './button';
6+
import { curDirName } from './common';
7+
import { RaspiControl } from './control';
8+
import { SettingsBase, SettingsHelper } from './settings';
9+
import { splitJpeg } from './splitJpeg';
10+
import { FileWatcher } from './watcher';
1611

1712
type SettingRequest = express.Request<undefined, undefined, Setting<GenericSettingDesc>>;
1813

src/server/settings.ts

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import fs from 'fs';
22
import path from 'path';
3-
import { shallowEqualObjects } from '../shared/helperFunctions.js';
4-
import { applicationSettingDesc } from '../shared/settings/application.js';
5-
import { buttonSettingDesc } from '../shared/settings/button.js';
6-
import { cameraSettingConverter, cameraSettingDesc } from '../shared/settings/camera.js';
7-
import { controlSettingDesc } from '../shared/settings/control.js';
8-
import { defaultSettings } from '../shared/settings/defaultSettings.js';
9-
import { applySettings, extractSettings } from '../shared/settings/helper.js';
10-
import { photoSettingConverter, photoSettingDesc } from '../shared/settings/photo.js';
11-
import { previewSettingDesc } from '../shared/settings/preview.js';
12-
import { streamSettingDesc } from '../shared/settings/stream.js';
13-
import { GenericSettingDesc, Setting } from '../shared/settings/types.js';
14-
import { videoSettingDesc } from '../shared/settings/video.js';
15-
import { curDirName } from './common.js';
16-
import { createLogger } from './logger.js';
3+
import { shallowEqualObjects } from '../shared/helperFunctions';
4+
import { applicationSettingDesc } from '../shared/settings/application';
5+
import { buttonSettingDesc } from '../shared/settings/button';
6+
import { cameraSettingConverter, cameraSettingDesc } from '../shared/settings/camera';
7+
import { controlSettingDesc } from '../shared/settings/control';
8+
import { defaultSettings } from '../shared/settings/defaultSettings';
9+
import { applySettings, extractSettings } from '../shared/settings/helper';
10+
import { photoSettingConverter, photoSettingDesc } from '../shared/settings/photo';
11+
import { previewSettingDesc } from '../shared/settings/preview';
12+
import { streamSettingDesc } from '../shared/settings/stream';
13+
import { GenericSettingDesc, Setting } from '../shared/settings/types';
14+
import { videoSettingDesc } from '../shared/settings/video';
15+
import { curDirName } from './common';
16+
import { createLogger } from './logger';
1717

1818
const logger = createLogger('settings');
1919
const settingsFolder = path.join(curDirName, 'settings');

src/server/watcher.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { exec } from 'child_process';
22
import fs from 'fs';
33
import path from 'path';
4-
import { RaspiFile, RaspiFileType, photosPath } from '../shared/settings/types.js';
5-
import { curDirName } from './common.js';
6-
import { createLogger } from './logger.js';
4+
import { RaspiFile, RaspiFileType, photosPath } from '../shared/settings/types';
5+
import { curDirName } from './common';
6+
import { createLogger } from './logger';
77

88
const logger = createLogger('watcher');
99

0 commit comments

Comments
 (0)