From 2c28ba8888eb6aaa623b1da2157a4711c8069343 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Thu, 1 Aug 2019 20:52:02 +0800 Subject: [PATCH 1/2] MDL-66307 js: Add missing plugintypes structure in subplugin read --- babel-plugin-add-module-to-define.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/babel-plugin-add-module-to-define.js b/babel-plugin-add-module-to-define.js index 2169daed0b2..27794724ab6 100644 --- a/babel-plugin-add-module-to-define.js +++ b/babel-plugin-add-module-to-define.js @@ -72,7 +72,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; } @@ -202,4 +202,4 @@ module.exports = ({ template, types }) => { } } }; -}; \ No newline at end of file +}; From ac1a91bf47bbe35dcd0a4bad6ede1964af69d3cd Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Thu, 1 Aug 2019 14:54:05 +0100 Subject: [PATCH 2/2] MDL-66307 js: fix path handling on Windows --- babel-plugin-add-module-to-define.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/babel-plugin-add-module-to-define.js b/babel-plugin-add-module-to-define.js index 27794724ab6..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(); @@ -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', '');