@private @method _import @param {String} assetPath @param {Object} options @param {String} directory @param {String} subdirectory @param {String} extension
(assetPath, options, directory, subdirectory, extension)
| 1139 | @param {String} extension |
| 1140 | */ |
| 1141 | _import(assetPath, options, directory, subdirectory, extension) { |
| 1142 | // TODO: refactor, this has gotten very messy. Relevant tests: tests/unit/broccoli/ember-app-test.js |
| 1143 | let basename = path.basename(assetPath); |
| 1144 | |
| 1145 | if (p.isType(assetPath, 'js', { registry: this.registry })) { |
| 1146 | if (options.using) { |
| 1147 | if (!Array.isArray(options.using)) { |
| 1148 | throw new Error('You must pass an array of transformations for `using` option'); |
| 1149 | } |
| 1150 | options.using.forEach((entry) => { |
| 1151 | if (!entry.transformation) { |
| 1152 | throw new Error( |
| 1153 | `while importing ${assetPath}: each entry in the \`using\` list must have a \`transformation\` name` |
| 1154 | ); |
| 1155 | } |
| 1156 | |
| 1157 | let transformName = entry.transformation; |
| 1158 | |
| 1159 | if (!this._customTransformsMap.has(transformName)) { |
| 1160 | let availableTransformNames = Array.from(this._customTransformsMap.keys()).join(','); |
| 1161 | throw new Error( |
| 1162 | `while import ${assetPath}: found an unknown transformation name ${transformName}. Available transformNames are: ${availableTransformNames}` |
| 1163 | ); |
| 1164 | } |
| 1165 | |
| 1166 | // process options for the transform and update the options |
| 1167 | let customTransforms = this._customTransformsMap.get(transformName); |
| 1168 | customTransforms.options = customTransforms.processOptions(assetPath, entry, customTransforms.options); |
| 1169 | customTransforms.files.push(assetPath); |
| 1170 | }); |
| 1171 | } |
| 1172 | |
| 1173 | if (options.type === 'vendor') { |
| 1174 | options.outputFile = options.outputFile || this.options.outputPaths.vendor.js; |
| 1175 | addOutputFile('firstOneWins', this._scriptOutputFiles, assetPath, options); |
| 1176 | } else if (options.type === 'test') { |
| 1177 | if (!allowImport('firstOneWins', this.legacyTestFilesToAppend, assetPath, options)) { |
| 1178 | return; |
| 1179 | } |
| 1180 | if (options.prepend) { |
| 1181 | this.legacyTestFilesToAppend.unshift(assetPath); |
| 1182 | } else { |
| 1183 | this.legacyTestFilesToAppend.push(assetPath); |
| 1184 | } |
| 1185 | } else { |
| 1186 | throw new Error( |
| 1187 | `You must pass either \`vendor\` or \`test\` for options.type in your call to \`app.import\` for file: ${basename}` |
| 1188 | ); |
| 1189 | } |
| 1190 | } else if (extension === '.css') { |
| 1191 | if (options.type === 'vendor') { |
| 1192 | options.outputFile = options.outputFile || this.options.outputPaths.vendor.css; |
| 1193 | addOutputFile('lastOneWins', this._styleOutputFiles, assetPath, options); |
| 1194 | } else { |
| 1195 | if (!allowImport('lastOneWins', this.vendorTestStaticStyles, assetPath, options)) { |
| 1196 | return; |
| 1197 | } |
| 1198 | if (options.prepend) { |
no test coverage detected