Skip to content

Commit

Permalink
release 3.0.0; fixes for webpack v5 & deps upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
Va1 committed Nov 15, 2020
1 parent d3a799d commit a028ea6
Show file tree
Hide file tree
Showing 7 changed files with 1,248 additions and 8 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
*.swp
node_modules/
package-lock.json
yarn.lock
test/
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ Perform replacements (plain and regular expression) in the contents loaded by th
## Install:

```bash
$ npm install --save-dev string-replace-loader
$ yarn add --dev string-replace-loader
```

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

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

## Usage:

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).
Expand Down
4 changes: 2 additions & 2 deletions lib/getOptionsArray.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { getOptions } = require('loader-utils')
const validateOptions = require('schema-utils')
const { validate } = require('schema-utils')

const loaderName = 'string-replace-loader'

Expand Down Expand Up @@ -53,7 +53,7 @@ function getOptionsArray (config) {
const optionsArray = []

for (const optionsIndex in rawOptionsArray) {
validateOptions(optionsSchema, rawOptionsArray[optionsIndex], loaderName)
validate(optionsSchema, rawOptionsArray[optionsIndex], { name: loaderName })

optionsArray[optionsIndex] = Object.assign({}, defaultOptions, rawOptionsArray[optionsIndex])
}
Expand Down
1 change: 1 addition & 0 deletions node_modules/__this-loader/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "string-replace-loader",
"version": "2.3.0",
"version": "3.0.0",
"description": "Replace loader for Webpack",
"keywords": [
"webpack",
Expand All @@ -24,7 +24,7 @@
"webpack": "^5.3.0"
},
"peerDependencies": {
"webpack": "1 || 2 || 3 || 4 || 5"
"webpack": "5"
},
"repository": {
"type": "git",
Expand Down
19 changes: 16 additions & 3 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const outputFilePath = path.join(outputDirPath, outputFileName)
function getTestWebPackConfig(loaderConfig) {
return {
mode: 'development',
devtool: false,
entry: entryFilePath,
output: {
path: outputDirPath,
Expand Down Expand Up @@ -193,9 +194,21 @@ describe('Webpack replace loader ...', () => {
webpack(getTestWebPackConfig(
{
test: /\.js$/,
loaders: [
'__this-loader?search=var value&replace=var a',
'__this-loader?search=module.exports = value&replace=module.exports = a'
use: [
{
loader: '__this-loader',
options: {
search: 'var value',
replace: 'var a'
}
},
{
loader: '__this-loader',
options: {
search: 'module.exports = value',
replace: 'module.exports = a'
}
}
]
}),
(error, stats) => {
Expand Down

0 comments on commit a028ea6

Please sign in to comment.