From e70673b3463b28a6333e4d76065bf3e94a84cf99 Mon Sep 17 00:00:00 2001 From: Adam Yost Date: Sun, 12 May 2019 09:30:53 -0400 Subject: [PATCH] add test case for webpack 5 --- .travis.yml | 3 +-- package.json | 2 +- src/plugin.ts | 11 ++++++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5144ad4..2932d9f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,13 @@ language: node_js node_js: - "8" - - "9" - "10" - - "11" - "12" env: - WEBPACK_VERSION=4 HTML_PLUGIN_VERSION=3 - WEBPACK_VERSION=4 HTML_PLUGIN_VERSION=next + - WEBPACK_VERSION=5.0.0-alpha.12 HTML_PLUGIN_VERSION=next install: - npm install diff --git a/package.json b/package.json index e9cd44b..18b3d89 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "webpack-nomodule-plugin", - "version": "1.0.0", + "version": "1.0.1", "description": "a plugin for html-webpack-plugin to label certain chunks as legacy-only via the nomodule attribute", "main": "dist/plugin.js", "scripts": { diff --git a/src/plugin.ts b/src/plugin.ts index c728a76..8ab9471 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -1,9 +1,14 @@ import * as HtmlWebpackPlugin from 'html-webpack-plugin'; import * as minimatch from 'minimatch'; +export type NoModuleConfig = { + filePatterns: string[]; + // in case I want to add other optional configs later without breaking old uses +} + export class WebpackNoModulePlugin { - constructor(private _config: {filePatterns: string[]} = {filePatterns: []}) { + constructor(private _config: NoModuleConfig = {filePatterns: []}) { } @@ -21,9 +26,9 @@ export class WebpackNoModulePlugin { return cb(null, data); } ) - } else if (HtmlWebpackPlugin && HtmlWebpackPlugin['getHooks']) { + } else if (HtmlWebpackPlugin && HtmlWebpackPlugin.getHooks) { // html-webpack 4 - const hooks = (HtmlWebpackPlugin as any).getHooks(compilation); + const hooks = HtmlWebpackPlugin.getHooks(compilation); hooks.alterAssetTags.tapAsync( 'NoModulePlugin', (data, cb) => {