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

UI5 Tooling: Extend custom task to use of babel polyfills #2

Open
BenReim opened this issue Feb 14, 2019 · 2 comments
Open

UI5 Tooling: Extend custom task to use of babel polyfills #2

BenReim opened this issue Feb 14, 2019 · 2 comments

Comments

@BenReim
Copy link

BenReim commented Feb 14, 2019

Hi Peter,

I've been playing around with your ES6 UI5 app sample and got stuck at when I tried to include polyfills so that such an app should be shipped to browsers like ie11.

I started by adding the according dependency...

npm install --save @babel/polyfill

The babel config that I used for the builder Transpile task looks like this:

{
	sourceMap: false,
	presets: [
		["@babel/preset-env", {
			targets: {
				"ie": "11"
			},
			useBuiltIns: "usage",
			modules: "amd"
		}]
	],
	plugins: [
		["@babel/plugin-transform-modules-commonjs", {
			"strictMode": false
		}]

	]
}

However, this causes the polyfill imports to be added to the top of the js files as require calls, such as this, which can not be understood by the browser.

require("core-js/modules/es6.array.find");
require("core-js/modules/es6.regexp.constructor");

sap.ui.define(["sap/ui/model/json/JSONModel"], function(e) {
    "use strict";
    // ....
}

But even if the polyfills would be imported as AMD modules, I wonder if those files would be available in a build result and be respected by a ui5 self-contained build?

I'm wondering if you could give any insights and information on how such an extended setup of your sample project could look like?

@petermuessig
Copy link
Owner

Hi Benjamin,

the UI5 self-contained build doesn't consider Common JS require calls in the scripts. They must be either added to the sap.ui.define and available as modules or another tool needs to ensure to append the content of those files in front of the modules.

In general, your question is really interesting and if I find some time the next days I would really like to look into your requirement and see how to solve this together with Babel and the UI5 tooling.

Cheers,
Peter

@BenReim
Copy link
Author

BenReim commented Feb 18, 2019

Hi Peter,

thanks for your fast response. Regarding the CommonJS require syntax, I was aware that this is probably not going to work with the tooling, yet hadn't found a way to force Babbel to add polyfills using AMD syntax.

Cool, its been really exciting to explore the new capabilities of the evolutionized UI5 in conjugation with the ui5-tooling, keep up the good work 👍

Greetings,
Ben

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants