Skip to content

Commit a256185

Browse files
chore: Lazy load paypal button (#3713)
1 parent fb2434e commit a256185

File tree

4 files changed

+355
-7
lines changed

4 files changed

+355
-7
lines changed

app/components/paypal-button.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import paypal from 'paypal-checkout';
21
import Component from '@ember/component';
32
import { inject as service } from '@ember/service';
43

@@ -8,6 +7,8 @@ export default Component.extend({
87

98
async didInsertElement() {
109
this._super(...arguments);
10+
const paypal = await import('paypal-checkout');
11+
1112
if (this.paymentFor === 'order') {
1213
let order = this.data;
1314
let createPayload = {

ember-cli-build.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const EmberApp = require('ember-cli/lib/broccoli/ember-app');
33
const MergeTrees = require('broccoli-merge-trees');
44
const Funnel = require('broccoli-funnel');
55
const targets = require('./config/targets');
6+
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
67

78
let env = process.env.EMBER_ENV || 'development';
89

@@ -22,7 +23,8 @@ module.exports = function(defaults) {
2223
},
2324
babel: {
2425
plugins: [
25-
'@babel/plugin-proposal-object-rest-spread'
26+
'@babel/plugin-proposal-object-rest-spread',
27+
require.resolve('ember-auto-import/babel-plugin')
2628
],
2729
targets,
2830
sourceMaps: 'inline'
@@ -32,7 +34,18 @@ module.exports = function(defaults) {
3234
generateAssetMap : true,
3335
exclude : ['package.json'],
3436
extensions : ['js', 'css', 'png', 'jpg', 'gif', 'map', 'svg', 'json']
35-
}
37+
},
38+
autoImport: {
39+
webpack: {
40+
plugins: env === 'production' ? [
41+
new BundleAnalyzerPlugin({
42+
analyzerMode: 'static',
43+
openAnalyzer: false,
44+
generateStatsFile: true
45+
})
46+
] : []
47+
},
48+
},
3649
});
3750

3851
app.import('bower_components/semantic-ui-calendar/dist/calendar.min.css');

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127
"string_decoder": "^1.2.0",
128128
"torii": "^0.10.1",
129129
"url-parse": "^1.4.7",
130+
"webpack-bundle-analyzer": "^3.6.0",
130131
"xgettext-template": "^3.4.2"
131132
},
132133
"engines": {

0 commit comments

Comments
 (0)