diff --git a/babel-plugin-add-module-to-define.js b/babel-plugin-add-module-to-define.js index 2169daed0b2..133df3ff2af 100644 --- a/babel-plugin-add-module-to-define.js +++ b/babel-plugin-add-module-to-define.js @@ -36,6 +36,7 @@ module.exports = ({ template, types }) => { const fs = require('fs'); + const path = require('path'); const glob = require('glob'); const cwd = process.cwd(); @@ -72,7 +73,7 @@ module.exports = ({ template, types }) => { var rawContents = fs.readFileSync(file); var subplugins = JSON.parse(rawContents); - for (const [component, path] of Object.entries(subplugins)) { + for (const [component, path] of Object.entries(subplugins.plugintypes)) { if (path) { moodlePlugins[path] = component; } @@ -92,7 +93,7 @@ module.exports = ({ template, types }) => { */ function getModuleNameFromFileName(searchFileName) { searchFileName = fs.realpathSync(searchFileName); - const relativeFileName = searchFileName.replace(`${cwd}/`, ''); + const relativeFileName = searchFileName.replace(`${cwd}${path.sep}`, '').replace(/\\/g, '/'); const [componentPath, file] = relativeFileName.split('/amd/src/'); const fileName = file.replace('.js', ''); @@ -202,4 +203,4 @@ module.exports = ({ template, types }) => { } } }; -}; \ No newline at end of file +};