@herberttn/bytenode-webpack-plugin
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -0,1 +1,10 @@ | ||
# [1.1.0](https://github.com/herberttn/bytenode-webpack-plugin/compare/v1.0.2...v1.1.0) (2021-04-01) | ||
### Bug Fixes | ||
* add throw description for entry as function ([446219e](https://github.com/herberttn/bytenode-webpack-plugin/commit/446219ec3744d1a7465cc2736025a5ca09ba6b46)) | ||
* debug logs should always use console.debug ([93979e2](https://github.com/herberttn/bytenode-webpack-plugin/commit/93979e29e8bfe92beb91ccbc10c849466783e4c0)) | ||
* remove moot config checks ([e408ccb](https://github.com/herberttn/bytenode-webpack-plugin/commit/e408ccba0149193554537a0b3a384679a4333577)) | ||
## [1.0.2](https://github.com/herberttn/bytenode-webpack-plugin/compare/v1.0.1...v1.0.2) (2021-03-31) | ||
@@ -2,0 +11,0 @@ |
@@ -1,2 +0,1 @@ | ||
import type { Hook } from 'tapable'; | ||
import type { WebpackPluginInstance } from 'webpack'; | ||
@@ -7,3 +6,3 @@ import type { Compiler, WebpackOptionsNormalized } from './normalized'; | ||
private readonly name; | ||
private options; | ||
private readonly options; | ||
constructor(options?: Partial<Options>); | ||
@@ -19,5 +18,4 @@ apply(compiler: Compiler): void; | ||
setupLifecycleLogging(compiler: Compiler): void; | ||
setupHooksLogging(type: string, hooks: Record<string, Hook>): void; | ||
} | ||
export { BytenodeWebpackPlugin, }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -144,5 +144,2 @@ "use strict"; | ||
preprocessOutput({ output }) { | ||
if (typeof output.filename !== 'string') { | ||
throw new Error(''); | ||
} | ||
let filename = output?.filename ?? '[name].js'; | ||
@@ -163,7 +160,4 @@ const { directory, extension, name } = prepare(filename); | ||
let entries; | ||
if (entry === undefined || entry === null) { | ||
throw new Error(''); | ||
} | ||
if (typeof entry === 'function') { | ||
throw new Error(''); | ||
throw new Error('Entry as a function is not supported as of yet.'); | ||
} | ||
@@ -208,3 +202,3 @@ if (typeof entry === 'string') { | ||
} | ||
this.log(title, data, ...rest); | ||
console.debug(title, data, ...rest); | ||
} | ||
@@ -215,3 +209,3 @@ log(...messages) { | ||
} | ||
console.debug(`[${this.name}]:`, ...messages); | ||
console.log(`[${this.name}]:`, ...messages); | ||
} | ||
@@ -223,24 +217,19 @@ setupLifecycleLogging(compiler) { | ||
} | ||
this.setupHooksLogging('compiler', compiler.hooks); | ||
setupHooksLogging(this.name, 'compiler', compiler.hooks); | ||
compiler.hooks.normalModuleFactory.tap(this.name, normalModuleFactory => { | ||
this.setupHooksLogging('normalModuleFactory', normalModuleFactory.hooks); | ||
setupHooksLogging(this.name, 'normalModuleFactory', normalModuleFactory.hooks); | ||
}); | ||
compiler.hooks.compilation.tap(this.name, compilation => { | ||
this.setupHooksLogging('compilation', compilation.hooks); | ||
setupHooksLogging(this.name, 'compilation', compilation.hooks); | ||
}); | ||
} | ||
setupHooksLogging(type, hooks) { | ||
const pluginName = this.name; | ||
const { debugLifecycle, silent } = this.options; | ||
if (!debugLifecycle || silent) { | ||
return; | ||
} | ||
for (const [name, hook] of Object.entries(hooks)) { | ||
try { | ||
hook.tap(pluginName, function () { | ||
console.debug(`[${pluginName}]: ${type} hook: ${name} (${arguments.length} arguments)`); | ||
}); | ||
function setupHooksLogging(pluginName, type, hooks) { | ||
for (const [name, hook] of Object.entries(hooks)) { | ||
try { | ||
hook.tap(pluginName, function () { | ||
console.debug(`[${pluginName}]: ${type} hook: ${name} (${arguments.length} arguments)`); | ||
}); | ||
} | ||
catch (_) { | ||
} | ||
} | ||
catch (_) { | ||
} | ||
} | ||
@@ -247,0 +236,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import type { Configuration, Output, Compiler as WebpackCompiler } from 'webpack'; | ||
import type { Configuration, Entry, EntryFunc, Output, Compiler as WebpackCompiler } from 'webpack'; | ||
interface Compiler extends WebpackCompiler { | ||
@@ -9,4 +9,6 @@ options: WebpackOptionsNormalized; | ||
interface WebpackOptionsNormalized extends Configuration { | ||
entry: EntryNormalized; | ||
output: OutputNormalized; | ||
} | ||
declare type EntryNormalized = string | string[] | Entry | EntryFunc; | ||
interface OutputNormalized extends Output { | ||
@@ -13,0 +15,0 @@ filename: string; |
{ | ||
"name": "@herberttn/bytenode-webpack-plugin", | ||
"description": "Compile JavaScript into bytecode using bytenode", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"license": "MIT", | ||
@@ -22,4 +22,3 @@ "repository": { | ||
"release": "semantic-release", | ||
"test": "jest --config jest.config.ts --detectOpenHandles", | ||
"test:coverage": "npm run test -- --coverage", | ||
"test": "jest --config jest.config.ts --coverage --detectOpenHandles", | ||
"test:watch": "npm run test -- --watch" | ||
@@ -26,0 +25,0 @@ }, |
@@ -33,3 +33,3 @@ @herberttn/bytenode-webpack-plugin | ||
- :heavy_check_mark: `entry` as a `string` (e.g., `'src/index.js'`) | ||
- :heavy_exclamation_mark: `entry` as an `array` (e.g., `['src/index.js']`) | ||
- :heavy_check_mark: `entry` as an `array` (e.g., `['src/index.js']`) | ||
- :heavy_check_mark: `entry` as an `object` (e.g., `{ main: 'src/index.js' }`) | ||
@@ -36,0 +36,0 @@ - :heavy_exclamation_mark: `entry` middlewares (e.g., `['src/index.js', 'webpack-hot-middleware/client']`) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
33005
329