Skip to content

Commit

Permalink
version v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nino-porcino authored and nino-porcino committed Aug 27, 2017
1 parent ffaa076 commit 2946013
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -2,4 +2,5 @@ node_modules/
.vscode/
*.js
!**/*.in.js
!**/*.out.js
!**/*.out.js
!**/*webpack*.js
37 changes: 32 additions & 5 deletions README.md
Expand Up @@ -67,12 +67,23 @@ const opts = {
"ifdef-triple-slash": false // add this to use double slash comment instead of default triple slash
};

// pass as JSON object into query string ?json=...
const q = require('querystring').encode({json: JSON.stringify(opts)});
/* ... */ {
test: /\.tsx?$/,
exclude: /node_modules/,
use: [
{ loader: "ts-loader" },
{ loader: "ifdef-loader", options: opts }
]
}

// alternatively, options can be passed via query string:
const q = require('querystring').encode(opts});
/* ... */ {
test: /\.tsx?$/,
exclude: /node_modules/,
loaders: [ "ts-loader", `ifdef-loader?query=${q}` ]
}

//...
{ test: /\.tsx?$/, exclude: /node_modules/, loaders: [ "ts-loader", `ifdef-loader?${q}` ] }
//...
```
in `example.ts`:
```ts
Expand All @@ -94,10 +105,26 @@ Contributions in the form of issues or pull requests are welcome.

## Changes

- v2.0.0 BREAKING CHANGE: options are now passed using the
standard Webpack API (`loader-utils`). See below for the upgrade.

- v1.0.0 changed to triple slash comment syntax. Double slash syntax
deprecated and available by turning off the `ifdef-triple-slash` option.

- v1.0.3 fixed bug occurring with short lines. Improved handling of line
termination (CRLF vs LF) in order to preserve source maps.

- v1.1.0 added support for `#else` clauses.

## Upgrading from v1 to v2

In v2 options are passed differently than v1, so you need to update your `webpack.config.js`.
Just do the following simple changes:
```js
/* from */ const q = require('querystring').encode({json: JSON.stringify(opts)});
/* to */ const q = require('querystring').encode(opts);
/* from */ ... `ifdef-loader?${q}` ...
/* to */ ... `ifdef-loader?query=${q}` ...

/* or pass options directly (see the docs) */
```
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "ifdef-loader",
"version": "1.1.1",
"version": "2.0.0",
"description": "",
"main": "ifdef-loader.js",
"devDependencies": {
Expand Down

0 comments on commit 2946013

Please sign in to comment.