Use es Modules for “plugin extensions”
closes CORE-2874 This makes it so we use es Modules instead of AMD for the generated Code we make in our webpack loader so that it works if those extensions Are AMD OR ES Modules. As it is written before this, if any plugin Was written as an es module it would not work unless the Babel add-module-exports plugin was also used. We have to do this before I can merge my other commits that AMD->ES modules stuff in plugin repos Test plan: * plugins that add extensions to other files should still work Change-Id: I2b6d6ee7fcabc28864b29e7f8df336316d1a3b61 Reviewed-on: https://gerrit.instructure.com/191710 Tested-by: Jenkins Reviewed-by: Steven Burnett <sburnett@instructure.com> QA-Review: Steven Burnett <sburnett@instructure.com> Product-Review: Ryan Shaw <ryan@instructure.com>
This commit is contained in:
parent
b557785d96
commit
c9c786fb33
|
@ -36,12 +36,10 @@ module.exports.pitch = function(remainingRequest, precedingRequest, data) {
|
|||
|
||||
const fileName = extractFileName(remainingRequest)
|
||||
const plugins = this.query.replace('?', '').split(',')
|
||||
const originalRequire = `unextended!coffeescripts/${fileName}`
|
||||
const pluginPaths = [originalRequire]
|
||||
const pluginImports = []
|
||||
const pluginArgs = []
|
||||
plugins.forEach((plugin, i) => {
|
||||
const pluginExtension = `${plugin}/app/coffeescripts/extensions/${fileName}`
|
||||
pluginPaths.push(pluginExtension)
|
||||
pluginImports.push(`import p${i} from "${plugin}/app/coffeescripts/extensions/${fileName}";`)
|
||||
pluginArgs.push(`p${i}`)
|
||||
})
|
||||
|
||||
|
@ -55,8 +53,9 @@ module.exports.pitch = function(remainingRequest, precedingRequest, data) {
|
|||
}
|
||||
|
||||
return `
|
||||
define(${JSON.stringify(pluginPaths)},function(orig, ${pluginArgs.join(',')}){
|
||||
return ${pluginChain}
|
||||
});
|
||||
import orig from "unextended!coffeescripts/${fileName}";
|
||||
${pluginImports.join('\n')}
|
||||
|
||||
export default ${pluginChain};
|
||||
`
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue