Skip to content

Commit ae0a8a7

Browse files
committed
feat(loader): initial commit
support webpack 5
1 parent 1f9ac33 commit ae0a8a7

File tree

4 files changed

+28
-23
lines changed

4 files changed

+28
-23
lines changed

packages/json-map-keys-loader/index.js

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import jsonParser from 'json-map-keys'
2+
import { interpolateName } from 'loader-utils'
3+
4+
export default function generateMappings(content) {
5+
const options = this.getOptions()
6+
7+
let prefix = ''
8+
if (options.prefix) {
9+
prefix = interpolateName(this, options.prefix, { content })
10+
}
11+
const resources = jsonParser(JSON.parse(content), prefix)
12+
13+
return JSON.stringify(resources)
14+
}

packages/json-map-keys-loader/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "json-map-keys-loader",
33
"version": "1.0.1",
4+
"type": "module",
45
"description": "Webpack loader to replace json values with the key path.",
56
"homepage": "https://github.com/tiagoporto/json-map-keys/tree/main/packages/json-map-keys-loader#readme",
67
"keywords": [
@@ -18,12 +19,12 @@
1819
},
1920
"funding": "https://github.com/sponsors/tiagoporto",
2021
"license": "MIT",
21-
"main": "./index.js",
22+
"main": "./index.mjs",
2223
"dependencies": {
2324
"json-map-keys": "^1.0.0-beta.1",
24-
"loader-utils": "^2.0.0"
25+
"loader-utils": "^3.3.1"
2526
},
2627
"peerDependencies": {
27-
"webpack": ">= 4"
28+
"webpack": ">= 5"
2829
}
2930
}

pnpm-lock.yaml

Lines changed: 10 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)