diff --git a/depper.js b/depper.js index f9a84c7..f5b0fa8 100644 --- a/depper.js +++ b/depper.js @@ -92,6 +92,8 @@ function Depper(opts) { opts = opts || {} + this._inlineSource = '' + this._inlineName = genInlineName() this._async = opts.async || false this._i = 0 this._deps = [] @@ -106,6 +108,10 @@ function Depper(opts) { /** @type {TransformDefinition[]} */ this._globalTransforms = [] + if (typeof this._cwd !== 'string') { + throw new Error('glslify-deps: cwd must be a string path') + } + if (!opts.readFile) { throw new Error('glslify-deps: readFile must be defined') } @@ -122,6 +128,8 @@ function Depper(opts) { throw new Error('glslify-deps: transformRequire must be defined') } + this.transformRequire = opts.transformRequire + // @ts-ignore this._transformRequireAsync = !!opts.transformRequire.sync @@ -129,15 +137,6 @@ function Depper(opts) { throw new Error('glslify-deps: transformRequire async detected \ \nwhen sync context, please ensure your resolver is even with the context') } - - this.transformRequire = opts.transformRequire - - this._inlineSource = '' - this._inlineName = genInlineName() - - if (typeof this._cwd !== 'string') { - throw new Error('glslify-deps: cwd must be a string path') - } } Depper.prototype.inline = function(source, basedir, done) {