修复 jssdk 改成内部模块化加载器后的报错

This commit is contained in:
2betop 2020-06-28 17:15:20 +08:00
parent 2724063947
commit 65dc92ff92
2 changed files with 6 additions and 8 deletions

View File

@ -132,13 +132,11 @@ module.exports = function (ret, pack, settings, opt) {
} catch (e) { } catch (e) {
d = (/((?:https?|file)\:.*)$/.test(e.stack) && RegExp.$1).replace(/\\/[^\\/]*$/, ''); d = (/((?:https?|file)\:.*)$/.test(e.stack) && RegExp.$1).replace(/\\/[^\\/]*$/, '');
} }
${contents.replace(/\"url\"\s*\:\s*('|")(\.\/.*)\1/g, function ( ${contents
_, .replace(/\"url\"\s*\:\s*('|")(\.\/.*)\1/g, function (_, quote, value) {
quote, return `"url": d + ${quote}${value.substring(1)}${quote}`;
value })
) { .replace(/require\.resourceMap/, 'amis.require.resourceMap')}
return `"url": d + ${quote}${value.substring(1)}${quote}`;
})}
})()`; })()`;
} }

View File

@ -30,7 +30,7 @@ function amisRequire(...args: Array<any>) {
let id = args.shift(); let id = args.shift();
id = Array.isArray(id) ? id.map(id => mapping[id] || id) : mapping[id] || id; id = Array.isArray(id) ? id.map(id => mapping[id] || id) : mapping[id] || id;
args.unshift(id); args.unshift(id);
return require.apply(this, args); return amis.require.apply(this, args);
} }
(window as any).amisRequire = amisRequire; (window as any).amisRequire = amisRequire;