-
Notifications
You must be signed in to change notification settings - Fork 2
fix(build): prevent scoped variables become global after transpilation #42
Conversation
The build process of the fork includes a Babel plugin to transoform top level block scope to IIFE. This prevents having variables like Element exposed in window (side effects).
package.json
Outdated
@@ -32,7 +32,7 @@ | |||
"fs-extra": "^8.1.0", | |||
"html-postcss": "^0.1.2", | |||
"merge-stream": "^2.0.0", | |||
"polymer-build": "^3.1.2", | |||
"polymer-build": "git+https://github.com/BBVAEngineering/polymer-build.git#v3.2.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use a published package instead of a repo tag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use a published package changing the package name or using a scope...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you open a PR to the main package in order to try to merge the change? I don't personally like cloning 3th party packages and maintaining them...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can try it but it's not going to be merged. There are more than 1000 open issues and the repo is unmaintained. I think that this package (polymer-build) is not going to receive new PRs and wont require maintenance. However, if we publish it with another name, we have to maintain it, set a proper publish / build process, etc.
Another option, not good (very bad in fact) since this package requires modules of polymer-build explicitly, is to include it as peerDependency and let the app specify the version to use.
Third option: include the package as a bundledDependency.
Fourth: move everything (polymer-build, this package and ember-cli-polymer-bundler) to private repos. I think that this option does not deserve the effort for the time we, and maybe other people, are going to use Polymer.
As a last resource, I can publish it in npm from my Github account. I'm not going to maintain the repo, except for security updates, but at least it will be published in npm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR in Polymer/tools: Polymer/tools#3502
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to build-polymer (published in npm) instead of polymer-build.
I don't have permissions to delete the fork of polymer-build in BBVAEngineering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a leave the company and the team needs to make some modification to that package, you'll probably need to make a fork again... That was the point of moving the fork here.
Codecov Report
@@ Coverage Diff @@
## master #42 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 2 2
Lines 64 64
=========================================
Hits 64 64
Continue to review full report at Codecov.
|
build-polymer is the same package with an additional Babel plugin
The build process of the polymer-build fork includes a Babel plugin to transform block scopes used at the top level of a file to an IIFE. This prevents side effects caused by exposing variables like
Element
(native) inwindow
. This global variable exposing happens after transpilation to ES5, that transformsconst
andlet
tovar
, so the block scope has no effect.Original code:
After transpilation:
Using the included Babel plugin:
The Polymer Tools monorepo, where the original polymer-build package is located, is unmaintained and Polymer has announced that they will no longer contribute to its own tools, so we have created a "fork" in BBVAEngineering org to include this change: https://github.com/BBVAEngineering/polymer-build