Skip to content

Commit

Permalink
fix(targets): prevent exceptions on JS SDK (#285)
Browse files Browse the repository at this point in the history
- Prevent errors when assigning readonly 'name' property.
- Prevent exceptions when used with webpack DefinePlugin
  • Loading branch information
roperzh committed Nov 14, 2019
1 parent 5796249 commit eb2b4c1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/targets/sources/web/js.component.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class {{{componentName}}} {
}

{{#if public}}
{{{componentName}}}.name = '{{{componentName}}}';
Object.defineProperty({{{componentName}}}, 'name', {value: '{{{componentName}}}'});
{{/if}}

module.exports.{{{componentName}}} = {{{componentName}}};
4 changes: 3 additions & 1 deletion packages/targets/sources/web/sdk/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
if (typeof process === 'undefined' || !process) {
process = {env: {}};
} else if (!process.env) {
process.env = {};
Object.defineProperty(process, 'env', {
value: {},
});
}

const Environment = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
if (typeof process === 'undefined' || !process) {
process = {env: {}};
} else if (!process.env) {
process.env = {};
Object.defineProperty(process, 'env', {
value: {},
});
}

const Environment = {
Expand Down Expand Up @@ -486,7 +488,7 @@ class Bindings {
}
}

Bindings.name = 'Bindings';
Object.defineProperty(Bindings, 'name', {value: 'Bindings'});

module.exports.Bindings = Bindings;

Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
if (typeof process === 'undefined' || !process) {
process = {env: {}};
} else if (!process.env) {
process.env = {};
Object.defineProperty(process, 'env', {
value: {},
});
}

const Environment = {
Expand Down Expand Up @@ -57,7 +59,7 @@ class Primitives {
}
}

Primitives.name = 'Primitives';
Object.defineProperty(Primitives, 'name', {value: 'Primitives'});

module.exports.Primitives = Primitives;

0 comments on commit eb2b4c1

Please sign in to comment.