@rollup-extras/plugin-html 1.4.4 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,8 +4,8 @@ Rollup plugin to inject assets names into html template.
4
4
 
5
5
  Points:
6
6
 
7
- - Inject file names with hashes
8
- - Watch on a template file and trigger rebuild if it is changed
7
+ - Injects file names with hashes
8
+ - Watches the template file and triggers a rebuild if it changes
9
9
  - Provides a minimalistic template by default, so you are ready to start without configuration
10
10
  - Supports multiple rollup configs (will trigger only when last output generated)
11
11
  - Extensible through API so you can plug in something for HTML processing or generate new types of HTML elements
@@ -1,33 +1,39 @@
1
- import { createLogger } from '@niceties/logger';
2
- import { a as getNonModuleScriptElement, b as getModuleScriptElement, t as toAssetPredicate } from './shared.mjs';
1
+ import { createLogger, LogLevel } from '@niceties/logger';
2
+
3
+ import { getModuleScriptElement, getNonModuleScriptElement, toAssetPredicate } from './shared.js';
3
4
 
4
5
  const noopPredicate = () => false;
6
+
5
7
  let logger;
6
- function simpleES5Script(predicateSource) {
8
+
9
+ export function simpleES5Script(predicateSource) {
7
10
  const predicate = getPredicate(predicateSource);
8
- return (fileName) => {
11
+ return fileName => {
9
12
  if (predicate(fileName)) {
10
13
  return getNonModuleScriptElement(fileName, false);
11
14
  }
12
15
  };
13
16
  }
14
- function simpleES5FallbackScript(predicateSource) {
17
+
18
+ export function simpleES5FallbackScript(predicateSource) {
15
19
  const predicate = getPredicate(predicateSource);
16
- return (fileName) => {
20
+ return fileName => {
17
21
  if (predicate(fileName)) {
18
22
  return getNonModuleScriptElement(fileName, true);
19
23
  }
20
24
  };
21
25
  }
22
- function simpleModuleScript(predicateSource) {
26
+
27
+ export function simpleModuleScript(predicateSource) {
23
28
  const predicate = getPredicate(predicateSource);
24
- return (fileName) => {
29
+ return fileName => {
25
30
  if (predicate(fileName)) {
26
31
  return getModuleScriptElement(fileName);
27
32
  }
28
33
  };
29
34
  }
30
- function combineAssetFactories(...factories) {
35
+
36
+ export function combineAssetFactories(...factories) {
31
37
  return (fileName, content, type) => {
32
38
  for (const factory of factories) {
33
39
  const result = factory(fileName, content, type);
@@ -37,20 +43,20 @@ function combineAssetFactories(...factories) {
37
43
  }
38
44
  };
39
45
  }
46
+
40
47
  function getPredicate(predicateSource) {
41
48
  let predicate = toAssetPredicate(predicateSource);
42
49
  if (!predicate) {
43
50
  const logger = getLogger();
44
- logger(`${predicateSource} is not valid, using noopPredicate`, 2 /* LogLevel.warn */);
51
+ logger(`${predicateSource} is not valid, using noopPredicate`, LogLevel.warn);
45
52
  predicate = noopPredicate;
46
53
  }
47
54
  return predicate;
48
55
  }
56
+
49
57
  function getLogger() {
50
58
  if (!logger) {
51
59
  logger = createLogger('@rollup-extras/plugin-html/asset-factories');
52
60
  }
53
61
  return logger;
54
62
  }
55
-
56
- export { combineAssetFactories, simpleES5FallbackScript, simpleES5Script, simpleModuleScript };
package/index.d.ts ADDED
@@ -0,0 +1,67 @@
1
+ declare module '@rollup-extras/plugin-html' {
2
+ import type { Plugin, InternalModuleFormat } from 'rollup';
3
+ import type { createLogger } from '@niceties/logger';
4
+ export default function _default(options?: HtmlPluginOptions): Plugin & {
5
+ api: {
6
+ addInstance(): Plugin;
7
+ };
8
+ };
9
+ export type PredicateSource = boolean | AssetPredicate | RegExp | string;
10
+ export type AssetType = "asset" | InternalModuleFormat;
11
+ export type Assets = { [key in AssetType]?: AssetDescriptor[]; };
12
+ export type AssetPredicate = (fileName: string) => boolean;
13
+ export type AssetDescriptor = {
14
+ html: string | ((assets: Assets, context?: unknown) => string | unknown);
15
+ head: boolean;
16
+ type: "asset" | InternalModuleFormat;
17
+ };
18
+ export type SimpleAssetDescriptor = {
19
+ html: string;
20
+ head: boolean;
21
+ type: "asset" | InternalModuleFormat;
22
+ };
23
+ export type AssetFactory = (fileName: string, content: string | Uint8Array, type: "asset" | InternalModuleFormat) => AssetDescriptor | string | undefined | Promise<AssetDescriptor | string | undefined>;
24
+ export type DefaultTemplateFactory = (initialTemplate: string, assets: Assets) => string;
25
+ export type TemplateFactory = (initialTemplate: string, assets: Assets, defaultTemplateFactory: DefaultTemplateFactory) => string | Uint8Array | Promise<string | Uint8Array>;
26
+ export type HtmlPluginOptions = {
27
+ pluginName?: string;
28
+ outputFile?: string;
29
+ template?: string;
30
+ watch?: boolean;
31
+ emitFile?: boolean | "auto";
32
+ verbose?: boolean;
33
+ useWriteBundle?: boolean;
34
+ useEmittedTemplate?: boolean;
35
+ conditionalLoading?: boolean;
36
+ injectIntoHead?: PredicateSource;
37
+ ignore?: PredicateSource;
38
+ assetsFactory?: AssetFactory;
39
+ templateFactory?: TemplateFactory;
40
+ };
41
+ export type Logger = ReturnType<typeof createLogger>;
42
+
43
+ export {};
44
+ }
45
+
46
+ declare module '@rollup-extras/plugin-html/asset-factories' {
47
+ import type { InternalModuleFormat } from 'rollup';
48
+ export function simpleES5Script(predicateSource: PredicateSource): AssetFactory;
49
+
50
+ export function simpleES5FallbackScript(predicateSource: PredicateSource): AssetFactory;
51
+
52
+ export function simpleModuleScript(predicateSource: PredicateSource): AssetFactory;
53
+
54
+ export function combineAssetFactories(...factories: AssetFactory[]): AssetFactory;
55
+ export type PredicateSource = boolean | AssetPredicate | RegExp | string;
56
+ export type AssetPredicate = (fileName: string) => boolean;
57
+ export type AssetDescriptor = {
58
+ html: string | ((assets: any, context?: unknown) => string | unknown);
59
+ head: boolean;
60
+ type: "asset" | InternalModuleFormat;
61
+ };
62
+ export type AssetFactory = (fileName: string, content: string | Uint8Array, type: "asset" | InternalModuleFormat) => AssetDescriptor | string | undefined | Promise<AssetDescriptor | string | undefined>;
63
+
64
+ export {};
65
+ }
66
+
67
+ //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "version": 3,
3
+ "file": "index.d.ts",
4
+ "names": [
5
+ "PredicateSource",
6
+ "AssetType",
7
+ "Assets",
8
+ "AssetPredicate",
9
+ "AssetDescriptor",
10
+ "SimpleAssetDescriptor",
11
+ "AssetFactory",
12
+ "DefaultTemplateFactory",
13
+ "TemplateFactory",
14
+ "HtmlPluginOptions",
15
+ "Logger",
16
+ "simpleES5Script",
17
+ "simpleES5FallbackScript",
18
+ "simpleModuleScript",
19
+ "combineAssetFactories"
20
+ ],
21
+ "sources": [
22
+ "index.js",
23
+ "asset-factories.js"
24
+ ],
25
+ "sourcesContent": [
26
+ null,
27
+ null
28
+ ],
29
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBCQgBW,eAAeA;;iBASfC,uBAAuBA;;iBASvBC,kBAAkBA;;iBASlBC,qBAAqBA;;;;;;;;",
30
+ "ignoreList": []
31
+ }
package/index.js ADDED
@@ -0,0 +1,346 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { mkdir, readFile, writeFile } from 'node:fs/promises';
3
+ import { dirname, join, relative } from 'node:path';
4
+
5
+ import { createLogger, LogLevel } from '@niceties/logger';
6
+ import logger from '@rollup-extras/utils/logger';
7
+ import { multiConfigPluginBase } from '@rollup-extras/utils/multi-config-plugin-base';
8
+ import { getOptionsObject } from '@rollup-extras/utils/options';
9
+
10
+ import { getLinkElement, getModuleScriptElement, getNonModuleScriptElement, toAssetPredicate } from './shared.js';
11
+
12
+ const defaultTemplate = '<!DOCTYPE html><html><head></head><body></body></html>';
13
+ const headClosingElement = '</head>';
14
+ const bodyClosingElement = '</body>';
15
+ const cssExtention = '.css';
16
+
17
+ const defaults = {
18
+ pluginName: '@rollup-extras/plugin-html',
19
+ outputFile: 'index.html',
20
+ watch: true,
21
+ useWriteBundle: false,
22
+ emitFile: 'auto',
23
+ injectIntoHead: (( fileName) => fileName.endsWith(cssExtention)),
24
+ ignore: (toAssetPredicate(false)),
25
+ templateFactory: (
26
+ ( template, assets, defaultTemplateFactory) =>
27
+ defaultTemplateFactory(template, assets)
28
+ ),
29
+ };
30
+
31
+ const factories = {
32
+ logger,
33
+ injectIntoHead: (predicateFactory),
34
+ ignore: (predicateFactory),
35
+ };
36
+
37
+ export default function (options = {}) {
38
+ const {
39
+ pluginName,
40
+ outputFile,
41
+ template,
42
+ watch,
43
+ emitFile,
44
+ conditionalLoading,
45
+ logger,
46
+ useWriteBundle,
47
+ logLevel,
48
+ useEmittedTemplate,
49
+ injectIntoHead,
50
+ ignore,
51
+ assetsFactory,
52
+ templateFactory,
53
+ } = getOptionsObject(
54
+ options,
55
+ {
56
+ ...defaults,
57
+ useEmittedTemplate: !('template' in options),
58
+ logLevel: options.verbose ? LogLevel.info : LogLevel.verbose,
59
+ },
60
+ factories
61
+ ),
62
+ hasCustomTemplateFactory = 'templateFactory' in options;
63
+
64
+ let templateString = defaultTemplate;
65
+ let hasTemplateFile = false;
66
+
67
+ if (template) {
68
+ if (isUsableByDefaultTemplateFactory(template)) {
69
+ templateString = template;
70
+ } else {
71
+ if (watch) {
72
+ try {
73
+
74
+ useNewTemplate(readFileSync(template, { encoding: 'utf8' }));
75
+ hasTemplateFile = true;
76
+ } catch (e) {
77
+ handleTemplateReadError(e);
78
+ }
79
+ } else {
80
+ templateString = new Promise(resolve => {
81
+ readFile(template, { encoding: 'utf8' })
82
+ .then(newTemplateString => {
83
+ if (!isUsableByDefaultTemplateFactory(newTemplateString) && !hasCustomTemplateFactory) {
84
+ warnAboutUsingDefaultTemplate();
85
+ resolve(defaultTemplate);
86
+ } else {
87
+ resolve(newTemplateString);
88
+ }
89
+ })
90
+ .catch(handleTemplateReadError);
91
+ });
92
+ }
93
+ }
94
+ }
95
+
96
+ let initialDir = '',
97
+ fileNameInInitialDir,
98
+ assets = freshAssets();
99
+
100
+ const processedFiles = new Set();
101
+
102
+ const instance = multiConfigPluginBase(useWriteBundle, pluginName, generateBundle, updateAssets);
103
+
104
+ const baseRenderStart = (instance).renderStart;
105
+ const baseAddInstance = (instance.api.addInstance);
106
+
107
+ instance.renderStart = function (
108
+ outputOptions,
109
+ inputOptions
110
+ ) {
111
+ logger('started collecting information', LogLevel.verbose);
112
+ initialDir = outputOptions.dir ?? '';
113
+ fileNameInInitialDir = join(initialDir, outputFile);
114
+ return (
115
+ baseRenderStart
116
+ ).call(this, outputOptions, inputOptions);
117
+ };
118
+
119
+ instance.api.addInstance = () => {
120
+ const instance = baseAddInstance();
121
+
122
+ if (hasTemplateFile && watch) {
123
+ ( (instance)).buildStart = buildStart;
124
+ }
125
+
126
+ return instance;
127
+ };
128
+
129
+ if (hasTemplateFile && watch) {
130
+
131
+ instance.buildStart = async function () {
132
+ try {
133
+ useNewTemplate(await readFile( (template), { encoding: 'utf8' }));
134
+ } catch (e) {
135
+ handleTemplateReadError(e);
136
+ }
137
+ await buildStart.apply(this);
138
+ };
139
+ }
140
+
141
+ return instance;
142
+
143
+ async function updateAssets(
144
+ options,
145
+ bundle,
146
+ remainingConfigsCount,
147
+ remainingOutputsCount
148
+ ) {
149
+ await getAssets(options, bundle);
150
+ const statistics = Object.keys(assets)
151
+ .map(key => ({ key, count: (assets[ (key)]).length }))
152
+ .filter(item => item.count)
153
+ .map(({ key, count }) => `${key}: ${count}`)
154
+ .join(', ');
155
+ logger(
156
+ `assets collected: [${statistics}], remaining: ${remainingOutputsCount} outputs, ${remainingConfigsCount} configs`,
157
+ LogLevel.verbose
158
+ );
159
+ const dir = options.dir ?? '',
160
+ fileName = relative(dir, fileNameInInitialDir);
161
+ if (fileName in bundle) {
162
+ if (useEmittedTemplate) {
163
+ logger(`using existing emitted ${fileName} as an input for our templateFactory`, LogLevel.verbose);
164
+ const source =
165
+ (bundle[fileName]).type === 'asset'
166
+ ? (bundle[fileName]).source.toString()
167
+ : (bundle[fileName]).code;
168
+ useNewTemplate(source);
169
+ } else {
170
+ logger(`removing existing emitted ${fileName}`, LogLevel.verbose);
171
+ }
172
+ if (remainingConfigsCount === 0 && emitFile && !useWriteBundle) {
173
+ delete bundle[fileName];
174
+ }
175
+ }
176
+ }
177
+
178
+ function freshAssets() {
179
+ return {
180
+ asset: [],
181
+ es: [],
182
+ iife: [],
183
+ umd: [],
184
+ };
185
+ }
186
+
187
+ function useNewTemplate(newTemplateString) {
188
+ if (!isUsableByDefaultTemplateFactory(newTemplateString) && !hasCustomTemplateFactory) {
189
+ warnAboutUsingDefaultTemplate();
190
+ } else {
191
+ templateString = newTemplateString;
192
+ }
193
+ }
194
+
195
+ function handleTemplateReadError(e) {
196
+ if ( (e)?.code === 'ENOENT') {
197
+ logger('template is neither a file nor a string', LogLevel.warn, e);
198
+ } else {
199
+ logger('error reading template', LogLevel.warn, e);
200
+ }
201
+ }
202
+
203
+ function warnAboutUsingDefaultTemplate() {
204
+ logger('template is unusable by default template factory, using default one', LogLevel.warn);
205
+ }
206
+
207
+ async function buildStart() {
208
+ this.addWatchFile( (template));
209
+ }
210
+
211
+ async function generateBundle( options) {
212
+ logger.start('generating html', logLevel);
213
+ try {
214
+ const dir = options.dir ?? '',
215
+ fileName = relative(dir, fileNameInInitialDir);
216
+ const depromisifiedTemplateString = await templateString,
217
+ source = await templateFactory(depromisifiedTemplateString, assets, defaultTemplateFactory);
218
+
219
+ if (!emitFile || fileName.startsWith('..') || useWriteBundle) {
220
+ if (emitFile && emitFile !== 'auto') {
221
+ logger('cannot emitFile because it is outside of current output.dir, using writeFile instead', LogLevel.verbose);
222
+ }
223
+ await mkdir(dirname(fileNameInInitialDir), { recursive: true });
224
+ await writeFile(fileNameInInitialDir, source);
225
+ } else {
226
+ this.emitFile({
227
+ type: 'asset',
228
+ fileName,
229
+ source,
230
+ });
231
+ }
232
+
233
+ assets = freshAssets();
234
+ processedFiles.clear();
235
+ logger.finish('html file generated');
236
+ } catch (e) {
237
+ logger.finish('html generation failed', LogLevel.error, e);
238
+ }
239
+ }
240
+
241
+ async function getAssets(options, bundle) {
242
+ const dir = options.dir ?? '';
243
+ for (const fileName of Object.keys(bundle)) {
244
+ const relativeToRootAssetPath = join(dir, fileName);
245
+ const assetPath = relative(initialDir, relativeToRootAssetPath);
246
+ if (ignore(relativeToRootAssetPath) || processedFiles.has(relativeToRootAssetPath)) {
247
+ continue;
248
+ }
249
+ processedFiles.add(relativeToRootAssetPath);
250
+ if ( (bundle[fileName]).type === 'asset') {
251
+ if (
252
+ await useAssetFactory(assetPath, relativeToRootAssetPath, (bundle[fileName]).source, 'asset')
253
+ ) {
254
+ continue;
255
+ }
256
+ if (fileName.endsWith(cssExtention)) {
257
+ (assets.asset).push({
258
+ html: getLinkElement(assetPath),
259
+ head: injectIntoHead(relativeToRootAssetPath),
260
+ type: 'asset',
261
+ });
262
+ }
263
+ } else if ( (bundle[fileName]).type === 'chunk') {
264
+ const chunk = (bundle[fileName]);
265
+ if (chunk.isEntry) {
266
+ if (await useAssetFactory(assetPath, relativeToRootAssetPath, chunk.code, options.format)) {
267
+ continue;
268
+ }
269
+ if (options.format === 'es' || options.format === 'iife' || options.format === 'umd') {
270
+ (assets[options.format]).push({
271
+ html: ( assets) => {
272
+ let useConditionalLoading = conditionalLoading;
273
+ useConditionalLoading ??= !!((assets.iife?.length || assets.umd?.length) && assets.es?.length);
274
+ return options.format === 'iife' || options.format === 'umd'
275
+ ? getNonModuleScriptElement(assetPath, !!useConditionalLoading)
276
+ : getModuleScriptElement(assetPath);
277
+ },
278
+ head: injectIntoHead(relativeToRootAssetPath),
279
+ type: 'asset',
280
+ });
281
+ }
282
+ }
283
+ }
284
+ }
285
+ }
286
+
287
+ async function useAssetFactory(fileName, relativeToRootAssetPath, source, format) {
288
+ if (assetsFactory) {
289
+ try {
290
+ let asset = await assetsFactory(fileName, source, format);
291
+ if (asset) {
292
+ if (typeof asset === 'string') {
293
+ asset = {
294
+ html: asset,
295
+ head: injectIntoHead(relativeToRootAssetPath),
296
+ type: format,
297
+ };
298
+ }
299
+ if (!assets[asset.type]) {
300
+ assets[asset.type] = [];
301
+ }
302
+ (assets[asset.type]).push(asset);
303
+ return true;
304
+ }
305
+ } catch (e) {
306
+ logger('exception in assetFactory', LogLevel.warn, e);
307
+ }
308
+ }
309
+ return false;
310
+ }
311
+ }
312
+
313
+ function isUsableByDefaultTemplateFactory(template) {
314
+ return template.indexOf(headClosingElement) >= 0 && template.indexOf(bodyClosingElement) >= 0;
315
+ }
316
+
317
+ function predicateFactory(options, field) {
318
+ if (options[field] != null) {
319
+ const predicate = toAssetPredicate( (options[field]));
320
+ if (predicate) {
321
+ return predicate;
322
+ } else {
323
+ options.logger?.(`${field} option ignored because it is not a function, RegExp, string or boolean`, LogLevel.warn);
324
+ }
325
+ }
326
+ return defaults[field];
327
+ }
328
+
329
+ function defaultTemplateFactory(template, assets) {
330
+
331
+ const assetsAsArray = (assets.asset)
332
+ .concat( ( (assets.iife).length ? assets.iife : assets.umd))
333
+ .concat( (assets.es))
334
+ .map(( asset) => {
335
+ if (typeof asset.html === 'function') {
336
+ asset.html = (asset.html(assets));
337
+ }
338
+ return (asset);
339
+ });
340
+ const headElements = assetsAsArray.filter(asset => asset.head).map(asset => asset.html);
341
+ const bodyElements = assetsAsArray.filter(asset => !asset.head).map(asset => asset.html);
342
+ const headIndex = template.toLowerCase().indexOf(headClosingElement);
343
+ template = `${template.substring(0, headIndex)}${headElements.join('')}${template.substring(headIndex)}`;
344
+ const bodyIndex = template.toLowerCase().indexOf(bodyClosingElement);
345
+ return `${template.substring(0, bodyIndex)}${bodyElements.join('')}${template.substring(bodyIndex)}`;
346
+ }
package/package.json CHANGED
@@ -1,28 +1,23 @@
1
1
  {
2
- "type": "module",
3
- "version": "1.4.4",
4
- "name": "@rollup-extras/plugin-html",
5
- "description": "Rollup plugin to inject assets names into html template.",
2
+ "version": "2.0.0",
6
3
  "license": "MIT",
4
+ "name": "@rollup-extras/plugin-html",
7
5
  "author": "Konstantin Shutkin",
8
- "main": "./dist/index.cjs",
9
- "module": "./dist/index.mjs",
6
+ "type": "module",
7
+ "types": "./index.d.ts",
10
8
  "exports": {
11
9
  ".": {
12
- "require": "./dist/index.cjs",
13
- "default": "./dist/index.mjs"
10
+ "types": "./index.d.ts",
11
+ "default": "./index.js"
14
12
  },
15
13
  "./asset-factories": {
16
- "require": "./dist/asset-factories.cjs",
17
- "default": "./dist/asset-factories.mjs"
14
+ "types": "./index.d.ts",
15
+ "default": "./asset-factories.js"
18
16
  },
19
17
  "./package.json": "./package.json"
20
18
  },
21
- "files": [
22
- "dist",
23
- "LICENSE",
24
- "asset-factories"
25
- ],
19
+ "main": "./index.js",
20
+ "module": "./index.js",
26
21
  "engines": {
27
22
  "node": ">=15"
28
23
  },
@@ -34,27 +29,22 @@
34
29
  "bugs": "https://github.com/kshutkin/rollup-extras/issues",
35
30
  "homepage": "https://github.com/kshutkin/rollup-extras/blob/main/plugin-html/README.md",
36
31
  "readme": "README.md",
32
+ "description": "Rollup plugin to inject assets names into html template.",
37
33
  "keywords": [
38
34
  "rollup-plugin",
39
35
  "html",
40
36
  "bundle"
41
37
  ],
42
38
  "dependencies": {
43
- "@niceties/logger": "^1.1.4",
44
- "@rollup-extras/utils": "^1.4.4"
39
+ "@niceties/logger": "^2.1.0",
40
+ "@rollup-extras/utils": "^2.0.0"
45
41
  },
46
42
  "peerDependencies": {
47
- "rollup": "^2.60.1 || ^3.0.0 || ^4.0.0"
43
+ "rollup": "^4.0.0"
48
44
  },
49
45
  "peerDependenciesMeta": {
50
46
  "rollup": {
51
47
  "optional": true
52
48
  }
53
- },
54
- "types": "./dist/index.d.ts",
55
- "scripts": {
56
- "build": "pkgbld-internal",
57
- "test": "jest --collectCoverage",
58
- "lint": "eslint ./src"
59
49
  }
60
50
  }
package/shared.js ADDED
@@ -0,0 +1,24 @@
1
+ export function getLinkElement(fileName) {
2
+ return `<link rel="stylesheet" href="${fileName}" type="text/css">`;
3
+ }
4
+
5
+ export function getNonModuleScriptElement(fileName, conditionalLoading) {
6
+ return `<script src="${fileName}" type="text/javascript"${conditionalLoading ? ' nomodule' : ''}></script>`;
7
+ }
8
+
9
+ export function getModuleScriptElement(fileName) {
10
+ return `<script src="${fileName}" type="module"></script>`;
11
+ }
12
+
13
+ export function toAssetPredicate(sourceOption) {
14
+ if (typeof sourceOption === 'boolean') {
15
+ return () => sourceOption;
16
+ } else if (typeof sourceOption === 'function') {
17
+ return sourceOption;
18
+ } else if (sourceOption instanceof RegExp) {
19
+ return ( fileName) => sourceOption.test(fileName);
20
+ } else if (typeof sourceOption === 'string') {
21
+ return ( fileName) => fileName.endsWith(sourceOption);
22
+ }
23
+ return undefined;
24
+ }
@@ -1,5 +0,0 @@
1
- {
2
- "type": "module",
3
- "types": "../dist/asset-factories.d.ts",
4
- "main": "../dist/asset-factories.mjs"
5
- }