Skip to content

Commit 6739ca8

Browse files
Ajay-singh1craigboxdhawton
authored
LFX'25:Update the pipeline to achieve clean build without any errors (#16637)
* Refactor code to ES6 standard and add esbuild as a bundler and transpiler Co-authored-by: Craig Box <[email protected]> Co-authored-by: Daniel Hawton <[email protected]> * Resolve Conflicts * Remove .js file and replace it with .ts file Co-authored-by: Daniel Hawton <[email protected]> Co-authored-by: Craig Box <[email protected]> * Resolve Errors --------- Co-authored-by: Craig Box <[email protected]> Co-authored-by: Daniel Hawton <[email protected]>
1 parent 008d00b commit 6739ca8

22 files changed

+231
-104
lines changed

Makefile.core.mk

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,7 @@ netlify_install:
142142
143143
144144
145-
146-
147-
148-
149-
@npm install --omit=dev --save-dev \
150-
151-
@npm install --save \
152-
145+
153146

154147
netlify: netlify_install
155148
@scripts/gen_site.sh

scripts/gen_site.sh

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,27 @@ set -ex
1818

1919
mkdir -p generated/js generated/img tmp/js
2020

21-
tsc
22-
23-
babel --source-maps --minified --no-comments --presets minify \
24-
tmp/js/constants.js \
25-
tmp/js/utils.js \
26-
tmp/js/feedback.js \
27-
tmp/js/kbdnav.js \
28-
tmp/js/themes.js \
29-
tmp/js/menu.js \
30-
tmp/js/header.js \
31-
tmp/js/sidebar.js \
32-
tmp/js/tabset.js \
33-
tmp/js/prism.js \
34-
tmp/js/codeBlocks.js \
35-
tmp/js/links.js \
36-
tmp/js/resizeObserver.js \
37-
tmp/js/scroll.js \
38-
tmp/js/overlays.js \
39-
tmp/js/lang.js \
40-
tmp/js/callToAction.js \
41-
tmp/js/events.js \
42-
tmp/js/faq.js \
43-
--out-file generated/js/all.min.js
44-
45-
babel --source-maps --minified --no-comments --presets minify \
46-
tmp/js/headerAnimation.js \
47-
--out-file generated/js/headerAnimation.min.js
48-
49-
babel --source-maps --minified --no-comments \
50-
tmp/js/themes_init.js \
51-
--out-file generated/js/themes_init.min.js
21+
22+
23+
# Bundle + minify with sourcemap
24+
esbuild ./src/ts/entrypoint.ts \
25+
--bundle \
26+
--minify \
27+
--sourcemap \
28+
--target=es6 \
29+
--outfile=generated/js/all.min.js
30+
31+
esbuild ./src/ts/headerAnimation.js \
32+
--minify \
33+
--sourcemap \
34+
--target=es6 \
35+
--outfile=generated/js/headerAnimation.min.js
36+
37+
esbuild ./src/ts/themes_init.js \
38+
--bundle \
39+
--minify \
40+
--sourcemap \
41+
--target=es6 \
42+
--outfile=generated/js/themes_init.min.js
5243

5344
svg-symbol-sprite -i src/icons -o generated/img/icons.svg --prefix ""

src/ts/callToAction.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14+
export {}; // Make this file a module
1415

1516
const callToActionDelayMs = 250;
16-
17+
declare global {
18+
interface Window {
19+
handleCallToAction: () => void;
20+
}
21+
}
1722
function handleCallToAction(): void {
1823
window.setTimeout(() => {
1924
document.querySelectorAll<HTMLElement>(".call-to-action").forEach(el => {
@@ -22,4 +27,5 @@ function handleCallToAction(): void {
2227
}, callToActionDelayMs);
2328
}
2429

30+
window.handleCallToAction = handleCallToAction;
2531
handleCallToAction();

src/ts/codeBlocks.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,25 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14-
14+
import { listen, copyToClipboard, getById } from "./utils";
15+
import { button, ariaLabel, mouseenter, mouseleave, click, active } from "./constants";
16+
import { readLocalStorage } from "./themes_init";
1517
declare const buttonCopy: string;
1618
declare const buttonDownload: string;
1719
declare const buttonPrint: string;
1820
declare const docTitle: string;
1921
declare const branchName: string;
2022
declare const Prism: any;
21-
23+
declare var iconFile: string;
2224
let syntaxColoring = true;
2325

26+
export {};
27+
declare global {
28+
interface Window {
29+
handleCodeBlocks: () => void;
30+
}
31+
}
32+
2433
// All the voodoo needed to support our fancy code blocks
2534
function handleCodeBlocks() {
2635
const toolbarShow = "toolbar-show";
@@ -300,5 +309,5 @@ function handleCodeBlocks() {
300309
loadExternal(pre);
301310
});
302311
}
303-
312+
window.handleCodeBlocks = handleCodeBlocks;
304313
handleCodeBlocks();

src/ts/constants.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
const click = "click";
16-
const mouseenter = "mouseenter";
17-
const mouseleave = "mouseleave";
18-
const active = "active";
19-
const keyup = "keyup";
20-
const keydown = "keydown";
21-
const button = "button";
22-
const ariaLabel = "aria-label";
23-
const ariaExpanded = "aria-expanded";
24-
const ariaSelected = "aria-selected";
25-
const ariaControls = "aria-controls";
26-
const tabIndex = "tabindex";
15+
export const click = "click";
16+
export const mouseenter = "mouseenter";
17+
export const mouseleave = "mouseleave";
18+
export const active = "active";
19+
export const keyup = "keyup";
20+
export const keydown = "keydown";
21+
export const button = "button";
22+
export const ariaLabel = "aria-label";
23+
export const ariaExpanded = "aria-expanded";
24+
export const ariaSelected = "aria-selected";
25+
export const ariaControls = "aria-controls";
26+
export const tabIndex = "tabindex";

src/ts/entrypoint.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import "./constants.ts";
2+
import "./utils.ts";
3+
import "./feedback.ts";
4+
import "./kbdnav.ts";
5+
import "./themes.ts";
6+
import "./menu.ts";
7+
import "./header.ts";
8+
import "./sidebar.ts";
9+
import "./tabset.ts";
10+
import "./prism.js";
11+
import "./codeBlocks.ts";
12+
import "./links.ts";
13+
import "./resizeObserver.js";
14+
import "./scroll.ts";
15+
import "./overlays.ts";
16+
import "./lang.ts";
17+
import "./callToAction.ts";
18+
import "./events.ts";
19+
import "./faq.ts";

src/ts/events.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@
1313
// limitations under the License.
1414

1515
// Handles banners and stickers
16+
import { listen , getByClass } from "./utils"
17+
import { readLocalStorage } from "./themes_init";
18+
import { click } from "./constants";
19+
20+
export{};
21+
declare global {
22+
interface Window {
23+
handleEvents: () => void;
24+
}
25+
}
1626
function handleEvents(): void {
1727
const now = new Date().valueOf();
1828
let remainingEventImpressions: any = {};

src/ts/faq.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,14 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14-
14+
import { listen } from "./utils"
1515
const faqBlockCollapsed = "faq-block--collapsed";
16+
export { };
17+
declare global {
18+
interface Window {
19+
handleFaqBlocks: () => void;
20+
}
21+
}
1622

1723
function handleFaqBlocks(): void {
1824
const faqBlocks: Element[] = [];
@@ -41,5 +47,5 @@ function handleFaqBlocks(): void {
4147
// Listen to hash change to navigate to another FAQ if necessary
4248
listen(window, "hashchange", dealWithHash);
4349
}
44-
50+
window.handleFaqBlocks = handleFaqBlocks;
4551
handleFaqBlocks();

src/ts/feedback.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,17 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14-
14+
import { getById } from "./utils";
1515
declare function gtag(type: string, action: string, payload: any): void;
1616

17-
function sendFeedback(language: string, value: number): void {
17+
export{};
18+
declare global {
19+
interface Window {
20+
sendFeedback: (language: string, value: number) => void;
21+
}
22+
}
23+
24+
export function sendFeedback(language: string, value: number): void {
1825
gtag("event", "click-" + language, {
1926
event_category: "Helpful",
2027
event_label: window.location.pathname,
@@ -70,3 +77,4 @@ function sendFeedback(language: string, value: number): void {
7077
});
7178
*/
7279
}
80+
window.sendFeedback = sendFeedback;

src/ts/header.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313
// limitations under the License.
1414

1515
// Attach the event handlers to support the search box and hamburger
16+
import { getById ,getByTag , listen ,getByClass } from "./utils";
17+
import { click, keyup } from "./constants";
18+
import { closeActiveOverlay } from "./overlays";
19+
export{};
20+
declare global {
21+
interface Window {
22+
handleHeader: () => void;
23+
}
24+
}
1625
function handleHeader(): void {
1726
const searchForm = "search-form";
1827
const headerLinks = "header-links";
@@ -158,5 +167,5 @@ function handleHeader(): void {
158167
toggleActiveHeader();
159168
});
160169
}
161-
170+
window.handleHeader=handleHeader;
162171
handleHeader();

0 commit comments

Comments
 (0)