| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,19 +14,30 @@ export default async function transform( | |||
| 14 | 14 | ||
| 15 | 15 | const id = this.resource | |
| 16 | 16 | const context = createContext(this) | |
| 17 | - const res = await plugin.transform.call( | ||
| 18 | - Object.assign( | ||
| 19 | - {}, | ||
| 20 | - this._compilation && createBuildContext(this._compiler, this._compilation, this), | ||
| 21 | - context, | ||
| 22 | - ), | ||
| 23 | - source, | ||
| 24 | - id, | ||
| 25 | - ) | ||
| 26 | 17 | ||
| 27 | - if (res == null) | ||
| 28 | - callback(null, source, map) | ||
| 29 | - else if (typeof res !== 'string') | ||
| 30 | - callback(null, res.code, map == null ? map : (res.map || map)) | ||
| 31 | - else callback(null, res, map) | ||
| 18 | + try { | ||
| 19 | + const res = await plugin.transform.call( | ||
| 20 | + Object.assign( | ||
| 21 | + {}, | ||
| 22 | + this._compilation && createBuildContext(this._compiler, this._compilation, this), | ||
| 23 | + context, | ||
| 24 | + ), | ||
| 25 | + source, | ||
| 26 | + id, | ||
| 27 | + ) | ||
| 28 | + | ||
| 29 | + if (res == null) | ||
| 30 | + callback(null, source, map) | ||
| 31 | + else if (typeof res !== 'string') | ||
| 32 | + callback(null, res.code, map == null ? map : (res.map || map)) | ||
| 33 | + else callback(null, res, map) | ||
| 34 | + } | ||
| 35 | + catch (error) { | ||
| 36 | + if (error instanceof Error) { | ||
| 37 | + callback(error) | ||
| 38 | + } | ||
| 39 | + else { | ||
| 40 | + callback(new Error(String(error))) | ||
| 41 | + } | ||
| 42 | + } | ||
| 32 | 43 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,23 +10,34 @@ export default async function transform(this: LoaderContext<any>, source: string | |||
| 10 | 10 | return callback(null, source, map) | |
| 11 | 11 | ||
| 12 | 12 | const context = createContext(this) | |
| 13 | - const res = await plugin.transform.call( | ||
| 14 | - Object.assign({}, createBuildContext({ | ||
| 15 | - addWatchFile: (file) => { | ||
| 16 | - this.addDependency(file) | ||
| 17 | - }, | ||
| 18 | - getWatchFiles: () => { | ||
| 19 | - return this.getDependencies() | ||
| 20 | - }, | ||
| 21 | - }, this._compiler!, this._compilation, this), context), | ||
| 22 | - source, | ||
| 23 | - this.resource, | ||
| 24 | - ) | ||
| 25 | 13 | ||
| 26 | - if (res == null) | ||
| 27 | - callback(null, source, map) | ||
| 28 | - else if (typeof res !== 'string') | ||
| 29 | - callback(null, res.code, map == null ? map : (res.map || map)) | ||
| 30 | - else | ||
| 31 | - callback(null, res, map) | ||
| 14 | + try { | ||
| 15 | + const res = await plugin.transform.call( | ||
| 16 | + Object.assign({}, createBuildContext({ | ||
| 17 | + addWatchFile: (file) => { | ||
| 18 | + this.addDependency(file) | ||
| 19 | + }, | ||
| 20 | + getWatchFiles: () => { | ||
| 21 | + return this.getDependencies() | ||
| 22 | + }, | ||
| 23 | + }, this._compiler!, this._compilation, this), context), | ||
| 24 | + source, | ||
| 25 | + this.resource, | ||
| 26 | + ) | ||
| 27 | + | ||
| 28 | + if (res == null) | ||
| 29 | + callback(null, source, map) | ||
| 30 | + else if (typeof res !== 'string') | ||
| 31 | + callback(null, res.code, map == null ? map : (res.map || map)) | ||
| 32 | + else | ||
| 33 | + callback(null, res, map) | ||
| 34 | + } | ||
| 35 | + catch (error) { | ||
| 36 | + if (error instanceof Error) { | ||
| 37 | + callback(error) | ||
| 38 | + } | ||
| 39 | + else { | ||
| 40 | + callback(new Error(String(error))) | ||
| 41 | + } | ||
| 42 | + } | ||
| 32 | 43 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments