Skip to content

Commit f9c13ca

Browse files
abhijithvijayanabhijith-vijayan
authored andcommitted
feat: use wext-manifest-transformer module
Signed-off-by: Abhijith Vijayan [FLUXON] <abhijith.vijayan@fluxon.com>
1 parent b0c50b4 commit f9c13ca

File tree

12 files changed

+19
-494
lines changed

12 files changed

+19
-494
lines changed

.github/workflows/npm-publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ jobs:
2424
steps:
2525
- uses: actions/checkout@v4
2626

27-
- name: Use Node.js 18
27+
- name: Use Node.js 20
2828
uses: actions/setup-node@v4
2929
with:
30-
node-version: '18.18.0'
30+
node-version: '20.19.2'
3131
registry-url: 'https://registry.npmjs.org'
3232
scope: "@abhijithvijayan"
3333

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v18.18.0
1+
v20.19.2

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wext-manifest-loader",
3-
"version": "2.4.2",
3+
"version": "3.0.0",
44
"description": "Webpack loader that lets you specify `manifest.json` properties to appear only in specific browsers.",
55
"license": "MIT",
66
"repository": "https://github.com/abhijithvijayan/wext-manifest-loader.git",
@@ -53,8 +53,9 @@
5353
"opera"
5454
],
5555
"dependencies": {
56-
"loader-utils": "^2.0.0",
57-
"schema-utils": "^2.7.1"
56+
"loader-utils": "^2.0.4",
57+
"schema-utils": "^2.7.1",
58+
"wext-manifest-transformer": "^1.1.0"
5859
},
5960
"devDependencies": {
6061
"@abhijithvijayan/eslint-config": "^2.8.0",
@@ -63,7 +64,7 @@
6364
"@babel/eslint-parser": "^7.23.9",
6465
"@types/jest": "^26.0.23",
6566
"@types/loader-utils": "^2.0.3",
66-
"@types/node": "^15.0.2",
67+
"@types/node": "^20.19.1",
6768
"@typescript-eslint/eslint-plugin": "^6.20.0",
6869
"@typescript-eslint/parser": "^6.20.0",
6970
"eslint": "^8.56.0",
@@ -80,6 +81,6 @@
8081
"prettier": "^3.2.4",
8182
"rimraf": "^3.0.2",
8283
"ts-jest": "^26.5.6",
83-
"typescript": "4.4.4"
84+
"typescript": "4.9.5"
8485
}
8586
}

readme.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<a href="https://travis-ci.com/abhijithvijayan/wext-manifest-loader">
88
<img src="https://travis-ci.com/abhijithvijayan/wext-manifest-loader.svg?branch=main" alt="Travis Build" />
99
</a>
10-
</a>
1110
<a href="https://david-dm.org/abhijithvijayan/wext-manifest-loader">
1211
<img src="https://img.shields.io/david/abhijithvijayan/wext-manifest-loader.svg?colorB=orange" alt="DEPENDENCIES" />
1312
</a>

source/constants.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1 @@
11
export const LOADER_NAME = 'wext-manifest-loader';
2-
3-
export const ENVKeys = {
4-
DEV: 'dev',
5-
PROD: 'prod',
6-
} as const;
7-
8-
export const Browser = {
9-
CHROME: 'chrome',
10-
FIREFOX: 'firefox',
11-
OPERA: 'opera',
12-
EDGE: 'edge',
13-
} as const;
14-
export type BrowserType = (typeof Browser)[keyof typeof Browser];
15-
16-
export const browserVendors: BrowserType[] = [
17-
Browser.CHROME,
18-
Browser.FIREFOX,
19-
Browser.OPERA,
20-
Browser.EDGE,
21-
];
22-
export const envVariables: string[] = [ENVKeys.DEV, ENVKeys.PROD];
23-
24-
// Refer: https://regex101.com/r/ddSEHh/1
25-
export const CUSTOM_PREFIX_REGEX = new RegExp(
26-
`^__((?:(?:${[...browserVendors, ...envVariables].join('|')})\\|?)+)__(.*)`
27-
);

source/loader.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ import fs from 'fs';
99
import path from 'path';
1010
import validateOptions from 'schema-utils';
1111
import {getOptions, interpolateName} from 'loader-utils';
12-
import {BrowserType, browserVendors, LOADER_NAME} from './constants';
13-
import {transformManifest} from './transform';
12+
import transformer, {
13+
BrowserType,
14+
browserVendors,
15+
} from 'wext-manifest-transformer';
16+
import {LOADER_NAME} from './constants';
1417

1518
const packageJSONPath: string = path.resolve('./package.json');
1619

@@ -64,7 +67,11 @@ export function loader(this: any, source: any): string {
6467
}
6568

6669
// Transform manifest
67-
const manifest = transformManifest(content, vendor as BrowserType);
70+
const manifest = transformer(
71+
content,
72+
vendor as BrowserType,
73+
process.env.NODE_ENV || 'development'
74+
);
6875

6976
// update version field with package.json version
7077
if (usePackageJSONVersion) {

source/tests/chrome.json

Lines changed: 0 additions & 39 deletions
This file was deleted.

source/tests/firefox.json

Lines changed: 0 additions & 41 deletions
This file was deleted.

source/tests/manifest.json

Lines changed: 0 additions & 67 deletions
This file was deleted.

source/tests/match.test.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)