@elementor/entry-initialization-webpack-plugin 0.0.1

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/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @elementor/entry-initialization-webpack-plugin
2
+
3
+ ## 0.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 42c42ee: Remove side-effects
@@ -0,0 +1,15 @@
1
+ import { BannerPlugin, Compiler } from 'webpack';
2
+
3
+ type Options = {
4
+ initializer: (args: InitializerArgs) => string;
5
+ };
6
+ type InitializerArgs = Parameters<BannerPlugin['banner']>[0] & {
7
+ entryName: string;
8
+ };
9
+ declare class EntryInitializationWebpackPlugin {
10
+ private options;
11
+ constructor(options: Options);
12
+ apply(compiler: Compiler): void;
13
+ }
14
+
15
+ export { EntryInitializationWebpackPlugin };
@@ -0,0 +1,15 @@
1
+ import { BannerPlugin, Compiler } from 'webpack';
2
+
3
+ type Options = {
4
+ initializer: (args: InitializerArgs) => string;
5
+ };
6
+ type InitializerArgs = Parameters<BannerPlugin['banner']>[0] & {
7
+ entryName: string;
8
+ };
9
+ declare class EntryInitializationWebpackPlugin {
10
+ private options;
11
+ constructor(options: Options);
12
+ apply(compiler: Compiler): void;
13
+ }
14
+
15
+ export { EntryInitializationWebpackPlugin };
package/dist/index.js ADDED
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ EntryInitializationWebpackPlugin: () => EntryInitializationWebpackPlugin
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+
27
+ // src/plugin.ts
28
+ var import_webpack = require("webpack");
29
+
30
+ // src/kebab-to-camel-case.ts
31
+ function kebabToCamelCase(kebabCase) {
32
+ return kebabCase.replace(/-(\w)/g, (_, w) => w.toUpperCase());
33
+ }
34
+
35
+ // src/plugin.ts
36
+ var EntryInitializationWebpackPlugin = class {
37
+ constructor(options) {
38
+ this.options = options;
39
+ }
40
+ apply(compiler) {
41
+ new import_webpack.BannerPlugin({
42
+ banner: (args) => {
43
+ const { name } = args.chunk;
44
+ if (!name) {
45
+ return "";
46
+ }
47
+ if (!/\.js$/.test(args.filename)) {
48
+ return "";
49
+ }
50
+ return this.options.initializer({
51
+ ...args,
52
+ entryName: kebabToCamelCase(name)
53
+ });
54
+ },
55
+ raw: true,
56
+ footer: true,
57
+ entryOnly: true,
58
+ stage: import_webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
59
+ }).apply(compiler);
60
+ }
61
+ };
62
+ // Annotate the CommonJS export names for ESM import in node:
63
+ 0 && (module.exports = {
64
+ EntryInitializationWebpackPlugin
65
+ });
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/plugin.ts","../src/kebab-to-camel-case.ts"],"sourcesContent":["export { EntryInitializationWebpackPlugin } from './plugin';\n","import { BannerPlugin, Compilation, type Compiler } from 'webpack';\n\nimport { kebabToCamelCase } from './kebab-to-camel-case';\n\ntype Options = {\n\tinitializer: ( args: InitializerArgs ) => string;\n};\n\ntype InitializerArgs = Parameters< BannerPlugin[ 'banner' ] >[ 0 ] & {\n\tentryName: string;\n};\n\nexport class EntryInitializationWebpackPlugin {\n\tconstructor( private options: Options ) {}\n\n\tapply( compiler: Compiler ) {\n\t\tnew BannerPlugin( {\n\t\t\tbanner: ( args ) => {\n\t\t\t\tconst { name } = args.chunk;\n\n\t\t\t\tif ( ! name ) {\n\t\t\t\t\treturn '';\n\t\t\t\t}\n\n\t\t\t\tif ( ! /\\.js$/.test( args.filename ) ) {\n\t\t\t\t\treturn '';\n\t\t\t\t}\n\n\t\t\t\treturn this.options.initializer( {\n\t\t\t\t\t...args,\n\t\t\t\t\tentryName: kebabToCamelCase( name ),\n\t\t\t\t} );\n\t\t\t},\n\t\t\traw: true,\n\t\t\tfooter: true,\n\t\t\tentryOnly: true,\n\t\t\tstage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,\n\t\t} ).apply( compiler );\n\t}\n}\n","export function kebabToCamelCase( kebabCase: string ) {\n\treturn kebabCase.replace( /-(\\w)/g, ( _, w: string ) => w.toUpperCase() );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,qBAAyD;;;ACAlD,SAAS,iBAAkB,WAAoB;AACrD,SAAO,UAAU,QAAS,UAAU,CAAE,GAAG,MAAe,EAAE,YAAY,CAAE;AACzE;;;ADUO,IAAM,mCAAN,MAAuC;AAAA,EAC7C,YAAqB,SAAmB;AAAnB;AAAA,EAAoB;AAAA,EAEzC,MAAO,UAAqB;AAC3B,QAAI,4BAAc;AAAA,MACjB,QAAQ,CAAE,SAAU;AACnB,cAAM,EAAE,KAAK,IAAI,KAAK;AAEtB,YAAK,CAAE,MAAO;AACb,iBAAO;AAAA,QACR;AAEA,YAAK,CAAE,QAAQ,KAAM,KAAK,QAAS,GAAI;AACtC,iBAAO;AAAA,QACR;AAEA,eAAO,KAAK,QAAQ,YAAa;AAAA,UAChC,GAAG;AAAA,UACH,WAAW,iBAAkB,IAAK;AAAA,QACnC,CAAE;AAAA,MACH;AAAA,MACA,KAAK;AAAA,MACL,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,OAAO,2BAAY;AAAA,IACpB,CAAE,EAAE,MAAO,QAAS;AAAA,EACrB;AACD;","names":[]}
package/dist/index.mjs ADDED
@@ -0,0 +1,39 @@
1
+ // src/plugin.ts
2
+ import { BannerPlugin, Compilation } from "webpack";
3
+
4
+ // src/kebab-to-camel-case.ts
5
+ function kebabToCamelCase(kebabCase) {
6
+ return kebabCase.replace(/-(\w)/g, (_, w) => w.toUpperCase());
7
+ }
8
+
9
+ // src/plugin.ts
10
+ var EntryInitializationWebpackPlugin = class {
11
+ constructor(options) {
12
+ this.options = options;
13
+ }
14
+ apply(compiler) {
15
+ new BannerPlugin({
16
+ banner: (args) => {
17
+ const { name } = args.chunk;
18
+ if (!name) {
19
+ return "";
20
+ }
21
+ if (!/\.js$/.test(args.filename)) {
22
+ return "";
23
+ }
24
+ return this.options.initializer({
25
+ ...args,
26
+ entryName: kebabToCamelCase(name)
27
+ });
28
+ },
29
+ raw: true,
30
+ footer: true,
31
+ entryOnly: true,
32
+ stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
33
+ }).apply(compiler);
34
+ }
35
+ };
36
+ export {
37
+ EntryInitializationWebpackPlugin
38
+ };
39
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/plugin.ts","../src/kebab-to-camel-case.ts"],"sourcesContent":["import { BannerPlugin, Compilation, type Compiler } from 'webpack';\n\nimport { kebabToCamelCase } from './kebab-to-camel-case';\n\ntype Options = {\n\tinitializer: ( args: InitializerArgs ) => string;\n};\n\ntype InitializerArgs = Parameters< BannerPlugin[ 'banner' ] >[ 0 ] & {\n\tentryName: string;\n};\n\nexport class EntryInitializationWebpackPlugin {\n\tconstructor( private options: Options ) {}\n\n\tapply( compiler: Compiler ) {\n\t\tnew BannerPlugin( {\n\t\t\tbanner: ( args ) => {\n\t\t\t\tconst { name } = args.chunk;\n\n\t\t\t\tif ( ! name ) {\n\t\t\t\t\treturn '';\n\t\t\t\t}\n\n\t\t\t\tif ( ! /\\.js$/.test( args.filename ) ) {\n\t\t\t\t\treturn '';\n\t\t\t\t}\n\n\t\t\t\treturn this.options.initializer( {\n\t\t\t\t\t...args,\n\t\t\t\t\tentryName: kebabToCamelCase( name ),\n\t\t\t\t} );\n\t\t\t},\n\t\t\traw: true,\n\t\t\tfooter: true,\n\t\t\tentryOnly: true,\n\t\t\tstage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,\n\t\t} ).apply( compiler );\n\t}\n}\n","export function kebabToCamelCase( kebabCase: string ) {\n\treturn kebabCase.replace( /-(\\w)/g, ( _, w: string ) => w.toUpperCase() );\n}\n"],"mappings":";AAAA,SAAS,cAAc,mBAAkC;;;ACAlD,SAAS,iBAAkB,WAAoB;AACrD,SAAO,UAAU,QAAS,UAAU,CAAE,GAAG,MAAe,EAAE,YAAY,CAAE;AACzE;;;ADUO,IAAM,mCAAN,MAAuC;AAAA,EAC7C,YAAqB,SAAmB;AAAnB;AAAA,EAAoB;AAAA,EAEzC,MAAO,UAAqB;AAC3B,QAAI,aAAc;AAAA,MACjB,QAAQ,CAAE,SAAU;AACnB,cAAM,EAAE,KAAK,IAAI,KAAK;AAEtB,YAAK,CAAE,MAAO;AACb,iBAAO;AAAA,QACR;AAEA,YAAK,CAAE,QAAQ,KAAM,KAAK,QAAS,GAAI;AACtC,iBAAO;AAAA,QACR;AAEA,eAAO,KAAK,QAAQ,YAAa;AAAA,UAChC,GAAG;AAAA,UACH,WAAW,iBAAkB,IAAK;AAAA,QACnC,CAAE;AAAA,MACH;AAAA,MACA,KAAK;AAAA,MACL,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,OAAO,YAAY;AAAA,IACpB,CAAE,EAAE,MAAO,QAAS;AAAA,EACrB;AACD;","names":[]}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@elementor/entry-initialization-webpack-plugin",
3
+ "version": "0.0.1",
4
+ "private": false,
5
+ "author": "Elementor Team",
6
+ "homepage": "https://elementor.com/",
7
+ "license": "GPL-3.0-or-later",
8
+ "main": "dist/index.js",
9
+ "module": "dist/index.mjs",
10
+ "types": "dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.mjs",
15
+ "require": "./dist/index.js"
16
+ },
17
+ "./package.json": "./package.json"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/elementor/elementor-packages.git",
22
+ "directory": "packages/tools/entry-initialization-webpack-plugin"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/elementor/elementor-packages/issues"
26
+ },
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "files": [
31
+ "README.md",
32
+ "CHANGELOG.md",
33
+ "/dist",
34
+ "/src",
35
+ "!**/__tests__"
36
+ ],
37
+ "scripts": {
38
+ "build": "tsup --config=../../tsup.build.ts",
39
+ "dev": "tsup --config=../../tsup.dev.ts --format=esm,cjs"
40
+ },
41
+ "peerDependencies": {
42
+ "webpack": "^5.0.0"
43
+ },
44
+ "devDependencies": {
45
+ "memfs": "^4.17.0",
46
+ "tsup": "^8.3.5"
47
+ }
48
+ }
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export { EntryInitializationWebpackPlugin } from './plugin';
@@ -0,0 +1,3 @@
1
+ export function kebabToCamelCase( kebabCase: string ) {
2
+ return kebabCase.replace( /-(\w)/g, ( _, w: string ) => w.toUpperCase() );
3
+ }
package/src/plugin.ts ADDED
@@ -0,0 +1,40 @@
1
+ import { BannerPlugin, Compilation, type Compiler } from 'webpack';
2
+
3
+ import { kebabToCamelCase } from './kebab-to-camel-case';
4
+
5
+ type Options = {
6
+ initializer: ( args: InitializerArgs ) => string;
7
+ };
8
+
9
+ type InitializerArgs = Parameters< BannerPlugin[ 'banner' ] >[ 0 ] & {
10
+ entryName: string;
11
+ };
12
+
13
+ export class EntryInitializationWebpackPlugin {
14
+ constructor( private options: Options ) {}
15
+
16
+ apply( compiler: Compiler ) {
17
+ new BannerPlugin( {
18
+ banner: ( args ) => {
19
+ const { name } = args.chunk;
20
+
21
+ if ( ! name ) {
22
+ return '';
23
+ }
24
+
25
+ if ( ! /\.js$/.test( args.filename ) ) {
26
+ return '';
27
+ }
28
+
29
+ return this.options.initializer( {
30
+ ...args,
31
+ entryName: kebabToCamelCase( name ),
32
+ } );
33
+ },
34
+ raw: true,
35
+ footer: true,
36
+ entryOnly: true,
37
+ stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
38
+ } ).apply( compiler );
39
+ }
40
+ }