Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Sep 17, 2022. It is now read-only.

Commit 71d4b64

Browse filesBrowse files
authored
Remove loader-utils dependency (#6)
1 parent 3ee133f commit 71d4b64
Copy full SHA for 71d4b64

File tree

Expand file treeCollapse file tree

3 files changed

+11
-13
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+11
-13
lines changed

‎package.json

Copy file name to clipboardExpand all lines: package.json
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,5 @@
7676
"vue": "3.2.20",
7777
"vue-loader": "16.8.2",
7878
"webpack": "5.61.0"
79-
},
80-
"dependencies": {
81-
"loader-utils": "^2.0.0"
8279
}
8380
}

‎pnpm-lock.yaml

Copy file name to clipboardExpand all lines: pnpm-lock.yaml
+5-4Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/index.ts

Copy file name to clipboardExpand all lines: src/index.ts
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import type { LoaderDefinitionFunction } from 'webpack/types'
22

3-
import { parseQuery, OptionObject } from 'loader-utils'
4-
5-
function generateCode (rawData: string, query: OptionObject, hot = false): string {
3+
function generateCode (rawData: string, query: URLSearchParams, hot = false): string {
64
// vue-loader pads SFC file sections with newlines - trim those
75
const data = rawData.replace(/^(\n|\r\n)+|(\n|\r\n)+$/g, '')
86

9-
if (typeof query.locale !== 'string') {
7+
const locale = query.get('locale')
8+
if (typeof locale !== 'string') {
109
throw new Error('Custom block does not have locale attribute')
1110
}
1211

@@ -33,14 +32,15 @@ import { FluentResource } from '@fluent/bundle'
3332
export default function (Component) {
3433
const target = Component.options || Component
3534
target.fluent = target.fluent || {}
36-
target.fluent['${query.locale}'] = new FluentResource(\`${data}\`)
35+
target.fluent['${locale}'] = new FluentResource(\`${data}\`)
3736
${hotCode}
3837
}\n`
3938
}
4039

4140
const loader: LoaderDefinitionFunction = function (this, source, sourceMap) {
4241
try {
43-
this.callback(null, generateCode(source, parseQuery(this.resourceQuery), this.hot), sourceMap)
42+
const options = new URLSearchParams(this.resourceQuery.slice(1))
43+
this.callback(null, generateCode(source, options, this.hot), sourceMap)
4444
} catch (err) {
4545
this.emitError(err as Error)
4646
this.callback(err as Error)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.