Skip to content

Commit 0b20626

Browse files
committed
Add named exports for classes and enums to ESM output
Resolves video-dev#5630
1 parent 7a4f809 commit 0b20626

File tree

6 files changed

+70
-4
lines changed

6 files changed

+70
-4
lines changed

build-config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,13 @@ const buildRollupConfig = ({
248248
includeCoverage,
249249
sourcemap = true,
250250
outputFile = null,
251+
input = './src/exports-default.ts',
251252
}) => {
252253
const outputName = buildTypeToOutputName[type];
253254
const extension = format === FORMAT.esm ? 'mjs' : 'js';
254255

255256
return {
256-
input: './src/hls.ts',
257+
input,
257258
onwarn: (e) => {
258259
if (allowCircularDeps && e.code === 'CIRCULAR_DEPENDENCY') return;
259260

@@ -307,6 +308,7 @@ const configs = Object.entries({
307308
minified: true,
308309
}),
309310
fullEsm: buildRollupConfig({
311+
input: './src/exports-named.ts',
310312
type: BUILD_TYPE.full,
311313
format: FORMAT.esm,
312314
minified: false,
@@ -322,6 +324,7 @@ const configs = Object.entries({
322324
minified: true,
323325
}),
324326
lightEsm: buildRollupConfig({
327+
input: './src/exports-named.ts',
325328
type: BUILD_TYPE.light,
326329
format: FORMAT.esm,
327330
minified: false,

src/controller/buffer-controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import type { ComponentAPI } from '../types/component-api';
3232
import type { ChunkMetadata } from '../types/transmuxer';
3333
import type Hls from '../hls';
3434
import type { LevelDetails } from '../loader/level-details';
35-
import type { HlsConfig } from '../hls';
35+
import type { HlsConfig } from '../config';
3636

3737
const VIDEO_CODEC_PROFILE_REPLACE =
3838
/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/;

src/controller/error-controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type { RetryConfig } from '../config';
1414
import type { NetworkComponentAPI } from '../types/component-api';
1515
import type { ErrorData } from '../types/events';
1616
import type { Fragment } from '../loader/fragment';
17-
import type { LevelDetails } from '../hls';
17+
import type { LevelDetails } from '../loader/level-details';
1818

1919
const RENDITION_PENALTY_DURATION_MS = 300000;
2020

src/exports-default.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Hls from './hls';
2+
3+
export default Hls;

src/exports-named.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import Hls from './hls';
2+
import { Events } from './events';
3+
import { ErrorTypes, ErrorDetails } from './errors';
4+
import { Level } from './types/level';
5+
import AbrController from './controller/abr-controller';
6+
import AudioTrackController from './controller/audio-track-controller';
7+
import AudioStreamController from './controller/audio-stream-controller';
8+
import BasePlaylistController from './controller/base-playlist-controller';
9+
import BaseStreamController from './controller/base-stream-controller';
10+
import BufferController from './controller/buffer-controller';
11+
import CapLevelController from './controller/cap-level-controller';
12+
import CMCDController from './controller/cmcd-controller';
13+
import ContentSteeringController from './controller/content-steering-controller';
14+
import EMEController from './controller/eme-controller';
15+
import ErrorController from './controller/error-controller';
16+
import FPSController from './controller/fps-controller';
17+
import SubtitleTrackController from './controller/subtitle-track-controller';
18+
19+
export default Hls;
20+
21+
export {
22+
Hls,
23+
ErrorDetails,
24+
ErrorTypes,
25+
Events,
26+
Level,
27+
AbrController,
28+
AudioStreamController,
29+
AudioTrackController,
30+
BasePlaylistController,
31+
BaseStreamController,
32+
BufferController,
33+
CapLevelController,
34+
CMCDController,
35+
ContentSteeringController,
36+
EMEController,
37+
ErrorController,
38+
FPSController,
39+
SubtitleTrackController,
40+
};
41+
export { SubtitleStreamController } from './controller/subtitle-stream-controller';
42+
export { TimelineController } from './controller/timeline-controller';
43+
export { KeySystems, KeySystemFormats } from './utils/mediakeys-helper';
44+
export { DateRange } from './loader/date-range';
45+
export { LoadStats } from './loader/load-stats';
46+
export { LevelKey } from './loader/level-key';
47+
export { LevelDetails } from './loader/level-details';
48+
export { MetadataSchema } from './types/demuxer';
49+
export { HlsSkip, HlsUrlParameters } from './types/level';
50+
export { PlaylistLevelType } from './types/loader';
51+
export { ChunkMetadata } from './types/transmuxer';
52+
export { BaseSegment, Fragment, Part } from './loader/fragment';
53+
export {
54+
NetworkErrorAction,
55+
ErrorActionFlags,
56+
} from './controller/error-controller';
57+
export { AttrList } from './utils/attr-list';

tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
"src/**/*",
88
"tests/**/*",
99
"demo/**/*",
10-
"tests/**/.eslintrc.js" /* needed for eslint to work for some reason ¯\_(ツ)_/¯ */
10+
/* needed for eslint to work for some reason ¯\_(ツ)_/¯ */
11+
"tests/**/.eslintrc.js",
12+
"rollup.config.js",
13+
"build-config.js"
1114
]
1215
}

0 commit comments

Comments
 (0)