Skip to content

Commit

Permalink
move to using loader-utils 1.x (#475)
Browse files Browse the repository at this point in the history
* move to using loader-utils 1.0.0

* Update package.json

* Cater for getOptions can return null

* cater for getLoaderOptions returning null

* try that again
  • Loading branch information
johnnyreilly authored Feb 22, 2017
1 parent cc95c0b commit f306dc3
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ module.exports = {
}
```

For a full breakdown of the power of query syntax have a read of [this](https://github.com/webpack/loader-utils#parsequery).
For a full breakdown of the power of query syntax have a read of [this](https://github.com/webpack/loader-utils#getoptions).

#### Available Options

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"dependencies": {
"colors": "^1.0.3",
"enhanced-resolve": "^3.0.0",
"loader-utils": "^0.2.6",
"loader-utils": "^1.0.2",
"semver": "^5.0.1"
},
"devDependencies": {
Expand Down
3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ function loader(this: interfaces.Webpack, contents: string) {
this.cacheable && this.cacheable();
const callback = this.async();
const options = getLoaderOptions(this);

const { instance, error } = instances.getTypeScriptInstance(options, this);

if (error) {
Expand Down Expand Up @@ -63,7 +62,7 @@ function getLoaderOptions(loader: interfaces.Webpack) {
webpackIndex = webpackInstances.push(loader._compiler) - 1;
}

const queryOptions = loaderUtils.parseQuery<interfaces.LoaderOptions>(loader.query);
const queryOptions = loaderUtils.getOptions<interfaces.LoaderOptions>(loader) || {} as interfaces.LoaderOptions;
const configFileOptions: PartialLoaderOptions = loader.options.ts || {};

const instanceName = webpackIndex + '_' + (queryOptions.instance || configFileOptions.instance || 'default');
Expand Down
2 changes: 1 addition & 1 deletion src/typings/loaderUtils/loaderUtils.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
declare module 'loader-utils' {
export function parseQuery<T>(query: string): T;
export function getOptions<T>(loaderContext: { query: string; }): T;
export function getRemainingRequest(loaderContext: any): any;
export function getCurrentRequest(loaderContext: any): any;
}

0 comments on commit f306dc3

Please sign in to comment.