Skip to content

Commit c87e845

Browse files
committed
fix: remove wrapper plugin
2 parents 6708186 + a6831aa commit c87e845

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

package-lock.json

Lines changed: 1 addition & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@
6666
"typedoc-plugin-rename-defaults": "0.6.6",
6767
"typescript": "~5.0.4",
6868
"webpack": "^5.96.1",
69-
"webpack-inject-plugin": "^1.5.5",
70-
"wrapper-webpack-plugin": "^2.2.2"
69+
"webpack-inject-plugin": "^1.5.5"
7170
},
7271
"dependencies": {
7372
"@types/url-join": "^4.0.2",

src/server/WebpackPlugins.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import InjectPlugin, { ENTRY_ORDER } from 'webpack-inject-plugin';
21
import UglifyJs from 'uglify-js';
2+
import InjectPlugin, { ENTRY_ORDER } from 'webpack-inject-plugin';
33

4-
import { FactoryConfig } from './types';
4+
import { BannerPlugin, WebpackPluginInstance } from 'webpack';
55
import resolveDirectory from '../app/utils/resolveDirectory';
66
import { publicPathTpl } from './constants';
7+
import { FactoryConfig } from './types';
78

89
/* istanbul ignore file */
910

@@ -16,16 +17,19 @@ const defaultConf: FactoryConfig = {
1617
},
1718
};
1819

20+
type FactoryResult = {
21+
client: WebpackPluginInstance[];
22+
server: WebpackPluginInstance[];
23+
};
24+
1925
/**
2026
* This function allows you to simplify client side Webpack configuration for Apps/Parcels that work with ILC.
2127
* It's main features:
2228
* - Automatic compatibility with legacy UMD bundles. More details [available here](https://github.com/namecheap/ilc/blob/master/docs/umd_bundles_compatibility.md)
2329
* - Automatic public path configuration for Webpack bundle.
2430
* [Detailed description](https://namecheap.github.io/ilc-sdk/pages/Pages/public_path.html).
2531
*/
26-
export function WebpackPluginsFactory(config: RegExp | FactoryConfig = {}) {
27-
const WrapperPlugin = require('wrapper-webpack-plugin');
28-
32+
export function WebpackPluginsFactory(config: RegExp | FactoryConfig = {}): FactoryResult {
2933
if (config instanceof RegExp) {
3034
config = {
3135
jsFilesTest: config,
@@ -38,15 +42,21 @@ export function WebpackPluginsFactory(config: RegExp | FactoryConfig = {}) {
3842
publicPathDetection: { ...defaultConf.publicPathDetection, ...config.publicPathDetection },
3943
};
4044

41-
const plugins = {
45+
const plugins: FactoryResult = {
4246
client: [
43-
new WrapperPlugin({
47+
new BannerPlugin({
48+
test: conf.jsFilesTest, // only wrap output of bundle files with '.js' extension
49+
banner: '(function(define){const __ilc_script_url__ = document.currentScript.src;',
50+
raw: true,
51+
}),
52+
new BannerPlugin({
4453
test: conf.jsFilesTest, // only wrap output of bundle files with '.js' extension
45-
header: '(function(define){const __ilc_script_url__ = document.currentScript.src;\n',
46-
footer: '\n})((window.ILC && window.ILC.define) || window.define);',
54+
banner: '})((window.ILC && window.ILC.define) || window.define);',
55+
raw: true,
56+
footer: true,
4757
}),
4858
],
49-
server: [] as any[],
59+
server: [],
5060
};
5161

5262
if (conf.publicPathDetection && conf.publicPathDetection.disable) {

0 commit comments

Comments
 (0)