html-inline-webpack-plugin
Advanced tools
Comparing version
{ | ||
"name": "html-inline-webpack-plugin", | ||
"description": "This webpack plugin package is bundling related HTML files by injecting inline tags.", | ||
"version": "1.0.0-alpha2", | ||
"version": "1.0.0-alpha5", | ||
"main": "./dist/index.js", | ||
@@ -6,0 +6,0 @@ "types": "./dist/types/index.d.ts", |
@@ -8,3 +8,3 @@ <div align="center"> | ||
<th>Version</th> | ||
<th>v1.0.0-alpha2</th> | ||
<th>v1.0.0-alpha5</th> | ||
</tr> | ||
@@ -11,0 +11,0 @@ </tbody> |
import { AssetInjector } from "./asset_injector"; | ||
export abstract class AssetInsertorWithBlob<T> extends AssetInjector<T> { | ||
// TODO: ... | ||
blobOf() { | ||
} | ||
} |
import { HTMLElement } from "node-html-parser"; | ||
import { Compilation } from "webpack"; | ||
/** | ||
* Signature for the interface that defines the required information | ||
* for injecting HTML elements about asset. | ||
* | ||
* Used by [AssetInjector]. | ||
*/ | ||
export interface AssetInjectorContext { | ||
@@ -9,2 +15,3 @@ compilation: Compilation; | ||
/** This class provides injecting HTML elements about asset. */ | ||
export abstract class AssetInjector<T> { | ||
@@ -15,11 +22,9 @@ abstract createElement(): HTMLElement; | ||
export interface DrivenAssetInjectorOptions { | ||
inline: boolean; | ||
} | ||
/** This class provides injecting HTML elements about asset based on the string. */ | ||
export abstract class DrivenAssetInjector extends AssetInjector<string> { | ||
constructor(public options: DrivenAssetInjectorOptions) { | ||
constructor(public options: {inline: boolean}) { | ||
super(); | ||
} | ||
/** Whether to include asset data within the tag for synchronous data loading. */ | ||
get isInline(): boolean { | ||
@@ -36,3 +41,3 @@ return this.options.inline; | ||
} else { | ||
target.setAttribute("src", context.assetName); | ||
this.setAttribute(context, target); | ||
} | ||
@@ -42,2 +47,4 @@ | ||
} | ||
abstract setAttribute(context: AssetInjectorContext, element: HTMLElement): void; | ||
} | ||
@@ -49,2 +56,7 @@ | ||
} | ||
setAttribute(context: AssetInjectorContext, element: HTMLElement): void { | ||
element.setAttribute("defer", ""); | ||
element.setAttribute("src", context.assetName); | ||
} | ||
} | ||
@@ -54,4 +66,9 @@ | ||
createElement(): HTMLElement { | ||
return new HTMLElement("style", {}); | ||
return new HTMLElement(this.isInline ? "style" : "link", {}); | ||
} | ||
setAttribute(context: AssetInjectorContext, element: HTMLElement): void { | ||
element.setAttribute("href", context.assetName); | ||
element.setAttribute("rel", "stylesheet"); | ||
} | ||
} |
@@ -15,3 +15,3 @@ import { Compilation, Compiler, sources } from "webpack"; | ||
inject?: boolean; | ||
injectByBlob: boolean; | ||
// injectByBlob: boolean; | ||
inline?: boolean; | ||
@@ -40,3 +40,3 @@ pretty?: boolean; | ||
const inject = this.options?.inject ?? true; | ||
const injectByBlob = this.options?.injectByBlob ?? true; | ||
// const injectByBlob = this.options?.injectByBlob ?? true; | ||
const inline = this.options?.inline ?? mode == "production"; | ||
@@ -50,3 +50,3 @@ const pretty = this.options?.pretty ?? false; | ||
inject: inject, | ||
injectByBlob: injectByBlob, | ||
// injectByBlob: injectByBlob, | ||
inline: inline, | ||
@@ -98,2 +98,6 @@ pretty: pretty, | ||
for (const asset in compilation.assets) { | ||
if (asset.endsWith("hot-update.js")) { | ||
continue; | ||
} | ||
const source = compilation.assets[asset].source() as string; | ||
@@ -100,0 +104,0 @@ const active = this.injectors.get(path.extname(asset)); |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
23805
115.98%19
111.11%435
190%0
-100%2
100%1
Infinity%