@rollup-extras/plugin-html 1.3.1 → 1.3.3
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/dist/index.cjs +6 -64
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +3 -61
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -3,67 +3,9 @@
|
|
|
3
3
|
var fs = require('fs/promises');
|
|
4
4
|
var oldStyleFs = require('fs');
|
|
5
5
|
var path = require('path');
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const result = Object.assign(Object.assign({}, defaults), options);
|
|
10
|
-
if (factory) {
|
|
11
|
-
for (const [k, v] of Object.entries(factory)) {
|
|
12
|
-
result[k] = v(result, k);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return result;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function logger (options) {
|
|
19
|
-
return logger$1.createLogger(options.pluginName);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function multiConfigPluginBase(useWriteBundle, pluginName, execute, onFinalHook) {
|
|
23
|
-
const finalHook = useWriteBundle ? 'writeBundle' : 'generateBundle';
|
|
24
|
-
let remainingOutputsCount = 0, configsCount = 0;
|
|
25
|
-
const configs = new Set();
|
|
26
|
-
const instance = {
|
|
27
|
-
name: pluginName,
|
|
28
|
-
renderStart,
|
|
29
|
-
[finalHook]: writeBundle,
|
|
30
|
-
api: { addInstance }
|
|
31
|
-
};
|
|
32
|
-
return instance;
|
|
33
|
-
function addInstance() {
|
|
34
|
-
const configId = ++configsCount;
|
|
35
|
-
configs.add(configId);
|
|
36
|
-
return {
|
|
37
|
-
name: `${pluginName}#${configId}`,
|
|
38
|
-
renderStart: () => {
|
|
39
|
-
configs.delete(configId);
|
|
40
|
-
return renderStart();
|
|
41
|
-
},
|
|
42
|
-
[finalHook]: writeBundle
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
function renderStart() {
|
|
46
|
-
++remainingOutputsCount;
|
|
47
|
-
}
|
|
48
|
-
async function writeBundle(options, bundle) {
|
|
49
|
-
--remainingOutputsCount;
|
|
50
|
-
if (onFinalHook) {
|
|
51
|
-
await onFinalHook.call(this, options, bundle, configs.size, remainingOutputsCount);
|
|
52
|
-
}
|
|
53
|
-
if (configs.size === 0 && remainingOutputsCount === 0) {
|
|
54
|
-
// do work
|
|
55
|
-
try {
|
|
56
|
-
await execute.call(this, options, bundle);
|
|
57
|
-
}
|
|
58
|
-
finally {
|
|
59
|
-
// reset configs
|
|
60
|
-
for (let i = configsCount; i > 0; --i) {
|
|
61
|
-
configs.add(i);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
6
|
+
var options = require('@rollup-extras/utils/options');
|
|
7
|
+
var logger = require('@rollup-extras/utils/logger');
|
|
8
|
+
var mutliConfigPluginBase = require('@rollup-extras/utils/mutli-config-plugin-base');
|
|
67
9
|
|
|
68
10
|
const defaultTemplate = '<!DOCTYPE html><html><head></head><body></body></html>';
|
|
69
11
|
const headClosingElement = '</head>';
|
|
@@ -80,8 +22,8 @@ const defaults = {
|
|
|
80
22
|
templateFactory: ((template, assets, defaultTemplateFactory) => defaultTemplateFactory(template, assets))
|
|
81
23
|
};
|
|
82
24
|
const factories = { logger, injectIntoHead: predicateFactory, ignore: predicateFactory };
|
|
83
|
-
function index (options = {}) {
|
|
84
|
-
const { pluginName, outputFile, template, watch, emitFile, conditionalLoading, logger, useWriteBundle, logLevel, useEmittedTemplate, injectIntoHead, ignore, assetsFactory, templateFactory } = getOptionsObject(options, Object.assign(Object.assign({}, defaults), { useEmittedTemplate: !('template' in options), logLevel: options.verbose ? 1 /* LogLevel.info */ : 0 /* LogLevel.verbose */ }), factories), hasCustomTemplateFactory = 'templateFactory' in options;
|
|
25
|
+
function index (options$1 = {}) {
|
|
26
|
+
const { pluginName, outputFile, template, watch, emitFile, conditionalLoading, logger, useWriteBundle, logLevel, useEmittedTemplate, injectIntoHead, ignore, assetsFactory, templateFactory } = options.getOptionsObject(options$1, Object.assign(Object.assign({}, defaults), { useEmittedTemplate: !('template' in options$1), logLevel: options$1.verbose ? 1 /* LogLevel.info */ : 0 /* LogLevel.verbose */ }), factories), hasCustomTemplateFactory = 'templateFactory' in options$1;
|
|
85
27
|
let templateString = defaultTemplate, hasTemplateFile = false;
|
|
86
28
|
if (template) {
|
|
87
29
|
if (isUsableByDefaultTemplateFactory(template)) {
|
|
@@ -117,7 +59,7 @@ function index (options = {}) {
|
|
|
117
59
|
}
|
|
118
60
|
let initialDir = '', fileNameInInitialDir, assets = freshAssets();
|
|
119
61
|
const processedFiles = new Set();
|
|
120
|
-
const instance = multiConfigPluginBase(useWriteBundle, pluginName, generateBundle, updateAssets);
|
|
62
|
+
const instance = mutliConfigPluginBase.multiConfigPluginBase(useWriteBundle, pluginName, generateBundle, updateAssets);
|
|
121
63
|
const baseRenderStart = instance.renderStart;
|
|
122
64
|
const baseAddInstance = instance.api.addInstance;
|
|
123
65
|
instance.renderStart = function (outputOptions, inputOptions) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Plugin } from 'rollup';
|
|
2
2
|
import { HtmlPluginOptions } from './types';
|
|
3
|
-
export default function (options?: HtmlPluginOptions):
|
|
3
|
+
export default function (options?: HtmlPluginOptions): Plugin & {
|
|
4
4
|
api: {
|
|
5
|
-
addInstance():
|
|
5
|
+
addInstance(): Plugin;
|
|
6
6
|
};
|
|
7
7
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -1,67 +1,9 @@
|
|
|
1
1
|
import fs from 'fs/promises';
|
|
2
2
|
import oldStyleFs from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const result = Object.assign(Object.assign({}, defaults), options);
|
|
8
|
-
if (factory) {
|
|
9
|
-
for (const [k, v] of Object.entries(factory)) {
|
|
10
|
-
result[k] = v(result, k);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
return result;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function logger (options) {
|
|
17
|
-
return createLogger(options.pluginName);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function multiConfigPluginBase(useWriteBundle, pluginName, execute, onFinalHook) {
|
|
21
|
-
const finalHook = useWriteBundle ? 'writeBundle' : 'generateBundle';
|
|
22
|
-
let remainingOutputsCount = 0, configsCount = 0;
|
|
23
|
-
const configs = new Set();
|
|
24
|
-
const instance = {
|
|
25
|
-
name: pluginName,
|
|
26
|
-
renderStart,
|
|
27
|
-
[finalHook]: writeBundle,
|
|
28
|
-
api: { addInstance }
|
|
29
|
-
};
|
|
30
|
-
return instance;
|
|
31
|
-
function addInstance() {
|
|
32
|
-
const configId = ++configsCount;
|
|
33
|
-
configs.add(configId);
|
|
34
|
-
return {
|
|
35
|
-
name: `${pluginName}#${configId}`,
|
|
36
|
-
renderStart: () => {
|
|
37
|
-
configs.delete(configId);
|
|
38
|
-
return renderStart();
|
|
39
|
-
},
|
|
40
|
-
[finalHook]: writeBundle
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
function renderStart() {
|
|
44
|
-
++remainingOutputsCount;
|
|
45
|
-
}
|
|
46
|
-
async function writeBundle(options, bundle) {
|
|
47
|
-
--remainingOutputsCount;
|
|
48
|
-
if (onFinalHook) {
|
|
49
|
-
await onFinalHook.call(this, options, bundle, configs.size, remainingOutputsCount);
|
|
50
|
-
}
|
|
51
|
-
if (configs.size === 0 && remainingOutputsCount === 0) {
|
|
52
|
-
// do work
|
|
53
|
-
try {
|
|
54
|
-
await execute.call(this, options, bundle);
|
|
55
|
-
}
|
|
56
|
-
finally {
|
|
57
|
-
// reset configs
|
|
58
|
-
for (let i = configsCount; i > 0; --i) {
|
|
59
|
-
configs.add(i);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
4
|
+
import { getOptionsObject } from '@rollup-extras/utils/options';
|
|
5
|
+
import logger from '@rollup-extras/utils/logger';
|
|
6
|
+
import { multiConfigPluginBase } from '@rollup-extras/utils/mutli-config-plugin-base';
|
|
65
7
|
|
|
66
8
|
const defaultTemplate = '<!DOCTYPE html><html><head></head><body></body></html>';
|
|
67
9
|
const headClosingElement = '</head>';
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.3.
|
|
2
|
+
"version": "1.3.3",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "@rollup-extras/plugin-html",
|
|
5
5
|
"author": {
|
|
@@ -60,13 +60,13 @@
|
|
|
60
60
|
"ts-jest": "28.0.2",
|
|
61
61
|
"typescript": "4.6.x",
|
|
62
62
|
"update-monorepo-package-json": "0.2.0",
|
|
63
|
-
"pkgbld-internal": "1.0.
|
|
63
|
+
"pkgbld-internal": "1.0.3"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"rollup": "^2.60.1 || ^3.0.0"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@niceties/logger": "^1.1.4",
|
|
70
|
-
"@rollup-extras/utils": "^1.3.
|
|
70
|
+
"@rollup-extras/utils": "^1.3.3"
|
|
71
71
|
}
|
|
72
72
|
}
|