Skip to content

Commit 20cb437

Browse files
Merge pull request #1329 from opencomponents/check-exports-data
check for exports data too
2 parents b03bca5 + c4ab832 commit 20cb437

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/registry/routes/helpers/get-component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ export default function getComponent(conf: Config, repository: Repository) {
523523
module: {
524524
exports: {} as Record<string, (...args: any[]) => any>
525525
},
526+
exports: {} as Record<string, (...args: any[]) => any>,
526527
console: conf.local ? console : noopConsole,
527528
setTimeout,
528529
Buffer
@@ -559,7 +560,8 @@ export default function getComponent(conf: Config, repository: Repository) {
559560

560561
try {
561562
vm.runInNewContext(dataProvider.content, context, options);
562-
const processData = context.module.exports['data'];
563+
const processData =
564+
context.module.exports['data'] || context.exports['data'];
563565
cache.set('file-contents', cacheKey, processData);
564566

565567
domain.on('error', handleError);

test/fixtures/mocked-components/plugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = {
2121
}
2222
}
2323
},
24-
data: '"use strict";module.exports.data=function(t,n){n(null,{a:t.plugins.doSomething()})};',
24+
data: '"use strict";exports.data=function(t,n){n(null,{a:t.plugins.doSomething()})};',
2525
view:
2626
'var oc=oc||{};oc.components=oc.components||{},oc.components["8b3650989d66345eea8152e89ec03e1dad8e8e9b"]' +
2727
'=function(e){var n,o=[],c=e||{};return function(e){o.push("<div>"+jade.escape(null==(n=e)?"":n)+" John </div>")}.' +

0 commit comments

Comments
 (0)