Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Lazy load paypal button #3713

Merged
merged 1 commit into from
Dec 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/components/paypal-button.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import paypal from 'paypal-checkout';
import Component from '@ember/component';
import { inject as service } from '@ember/service';

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

async didInsertElement() {
this._super(...arguments);
const paypal = await import('paypal-checkout');

if (this.paymentFor === 'order') {
let order = this.data;
let createPayload = {
Expand Down
17 changes: 15 additions & 2 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const EmberApp = require('ember-cli/lib/broccoli/ember-app');
const MergeTrees = require('broccoli-merge-trees');
const Funnel = require('broccoli-funnel');
const targets = require('./config/targets');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why adding this dependency ? Also how it is related to reduce the bundle sizes of js chunks ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All can be answered if you search the name of the dependency

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


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

Expand All @@ -22,7 +23,8 @@ module.exports = function(defaults) {
},
babel: {
plugins: [
'@babel/plugin-proposal-object-rest-spread'
'@babel/plugin-proposal-object-rest-spread',
require.resolve('ember-auto-import/babel-plugin')
],
targets,
sourceMaps: 'inline'
Expand All @@ -32,7 +34,18 @@ module.exports = function(defaults) {
generateAssetMap : true,
exclude : ['package.json'],
extensions : ['js', 'css', 'png', 'jpg', 'gif', 'map', 'svg', 'json']
}
},
autoImport: {
webpack: {
plugins: env === 'production' ? [
new BundleAnalyzerPlugin({
analyzerMode: 'static',
openAnalyzer: false,
generateStatsFile: true
})
] : []
},
},
});

app.import('bower_components/semantic-ui-calendar/dist/calendar.min.css');
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
"string_decoder": "^1.2.0",
"torii": "^0.10.1",
"url-parse": "^1.4.7",
"webpack-bundle-analyzer": "^3.6.0",
"xgettext-template": "^3.4.2"
},
"engines": {
Expand Down
Loading