Skip to content

Commit a028ea6

Browse files
committed
release 3.0.0; fixes for webpack v5 & deps upgrade
1 parent d3a799d commit a028ea6

File tree

7 files changed

+1248
-8
lines changed

7 files changed

+1248
-8
lines changed

.npmignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
*.swp
55
node_modules/
66
package-lock.json
7+
yarn.lock
78
test/

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ Perform replacements (plain and regular expression) in the contents loaded by th
55
## Install:
66

77
```bash
8-
$ npm install --save-dev string-replace-loader
8+
$ yarn add --dev string-replace-loader
99
```
1010

1111
With release of 2.0.0 the loader is expected to be used in Node v4+ environment.
1212
Support for Node v3 and lower was dropped, but you can install and use the loader version of 1.3.0 in older environments.
1313

14+
With release of 3.0.0 the loader is expected to be used with Webpack v5+.
15+
Support for Webpack v4 and lower was dropped, but you can install and use the loader version of 2.3.0 in older environments.
16+
1417
## Usage:
1518

1619
Loader allows to perform replacements in a way [String.prototype.replace()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) does (loader uses it internally).

lib/getOptionsArray.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const { getOptions } = require('loader-utils')
2-
const validateOptions = require('schema-utils')
2+
const { validate } = require('schema-utils')
33

44
const loaderName = 'string-replace-loader'
55

@@ -53,7 +53,7 @@ function getOptionsArray (config) {
5353
const optionsArray = []
5454

5555
for (const optionsIndex in rawOptionsArray) {
56-
validateOptions(optionsSchema, rawOptionsArray[optionsIndex], loaderName)
56+
validate(optionsSchema, rawOptionsArray[optionsIndex], { name: loaderName })
5757

5858
optionsArray[optionsIndex] = Object.assign({}, defaultOptions, rawOptionsArray[optionsIndex])
5959
}

node_modules/__this-loader/index.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "string-replace-loader",
3-
"version": "2.3.0",
3+
"version": "3.0.0",
44
"description": "Replace loader for Webpack",
55
"keywords": [
66
"webpack",
@@ -24,7 +24,7 @@
2424
"webpack": "^5.3.0"
2525
},
2626
"peerDependencies": {
27-
"webpack": "1 || 2 || 3 || 4 || 5"
27+
"webpack": "5"
2828
},
2929
"repository": {
3030
"type": "git",

test/index.test.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const outputFilePath = path.join(outputDirPath, outputFileName)
1111
function getTestWebPackConfig(loaderConfig) {
1212
return {
1313
mode: 'development',
14+
devtool: false,
1415
entry: entryFilePath,
1516
output: {
1617
path: outputDirPath,
@@ -193,9 +194,21 @@ describe('Webpack replace loader ...', () => {
193194
webpack(getTestWebPackConfig(
194195
{
195196
test: /\.js$/,
196-
loaders: [
197-
'__this-loader?search=var value&replace=var a',
198-
'__this-loader?search=module.exports = value&replace=module.exports = a'
197+
use: [
198+
{
199+
loader: '__this-loader',
200+
options: {
201+
search: 'var value',
202+
replace: 'var a'
203+
}
204+
},
205+
{
206+
loader: '__this-loader',
207+
options: {
208+
search: 'module.exports = value',
209+
replace: 'module.exports = a'
210+
}
211+
}
199212
]
200213
}),
201214
(error, stats) => {

0 commit comments

Comments
 (0)