From 5f324c41297d97eca0c162169c18d7e2c9998d8e Mon Sep 17 00:00:00 2001 From: makhnatkin Date: Mon, 21 Oct 2024 17:30:32 +0200 Subject: [PATCH 1/5] feat(build): export css and js without tabs amd cuts --- esbuild/build.mjs | 24 ++++++++++++++++++++++++ src/js/base.ts | 5 +++++ src/js/index.ts | 6 +----- src/scss/base.scss | 9 +++++++++ src/scss/yfm.scss | 11 +---------- 5 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 src/js/base.ts create mode 100644 src/scss/base.scss diff --git a/esbuild/build.mjs b/esbuild/build.mjs index 8812d4e7..6cc6e754 100755 --- a/esbuild/build.mjs +++ b/esbuild/build.mjs @@ -51,6 +51,13 @@ const common = { format: 'iife', plugins, }), + build({ + ...common, + entryPoints: ['src/scss/base.scss'], + outfile: 'dist/css/yfm-base.css', + format: 'iife', + plugins, + }), build({ ...common, entryPoints: ['src/scss/print.scss'], @@ -66,6 +73,12 @@ const common = { outfile: 'dist/css/yfm.min.css', minify: true, }); + await build({ + ...common, + entryPoints: ['dist/css/yfm-base.css'], + outfile: 'dist/css/yfm-base.min.css', + minify: true, + }); })(); (async function buildJs() { @@ -75,6 +88,11 @@ const common = { entryPoints: ['src/js/index.ts'], outfile: 'dist/js/yfm.js', }), + build({ + ...common, + entryPoints: ['src/js/base.ts'], + outfile: 'dist/js/yfm-base.js', + }), build({ ...common, entryPoints: ['src/js/print/index.ts'], @@ -88,4 +106,10 @@ const common = { outfile: 'dist/js/yfm.min.js', minify: true, }); + await build({ + ...common, + entryPoints: ['dist/js/yfm-base.js'], + outfile: 'dist/js/yfm-base.min.js', + minify: true, + }); })(); diff --git a/src/js/base.ts b/src/js/base.ts new file mode 100644 index 00000000..7d4b950e --- /dev/null +++ b/src/js/base.ts @@ -0,0 +1,5 @@ +import './polyfill'; +import './code'; +import './term'; +import './wide-mode'; +import './patch'; diff --git a/src/js/index.ts b/src/js/index.ts index 13aaabb8..ace390d8 100644 --- a/src/js/index.ts +++ b/src/js/index.ts @@ -1,8 +1,4 @@ import '@diplodoc/cut-extension/runtime'; import '@diplodoc/tabs-extension/runtime'; -import './polyfill'; -import './code'; -import './term'; -import './wide-mode'; -import './patch'; +import './base'; diff --git a/src/scss/base.scss b/src/scss/base.scss new file mode 100644 index 00000000..19c5814a --- /dev/null +++ b/src/scss/base.scss @@ -0,0 +1,9 @@ +@import 'common'; +@import 'note'; +@import 'anchor'; +@import 'highlight'; +@import 'code'; +@import 'file'; +@import 'term'; +@import 'table'; +@import 'modal'; diff --git a/src/scss/yfm.scss b/src/scss/yfm.scss index 474aff24..380c81c6 100644 --- a/src/scss/yfm.scss +++ b/src/scss/yfm.scss @@ -1,12 +1,3 @@ -@import 'common'; -@import 'note'; -@import 'anchor'; -@import 'highlight'; -@import 'code'; -@import 'file'; -@import 'term'; -@import 'table'; -@import 'modal'; - +@import 'base'; @import '@diplodoc/cut-extension/runtime'; @import '@diplodoc/tabs-extension/runtime'; From 6389c350dd5470f335b71ece83aeaa3d90e11edb Mon Sep 17 00:00:00 2001 From: makhnatkin Date: Mon, 21 Oct 2024 21:26:43 +0200 Subject: [PATCH 2/5] feat(build): added _yfm-only.scss --- esbuild/build.mjs | 25 +++++++++++++++++++------ src/scss/_yfm-only.scss | 10 ++++++++++ src/scss/base.scss | 3 --- src/scss/yfm.scss | 1 + 4 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 src/scss/_yfm-only.scss diff --git a/esbuild/build.mjs b/esbuild/build.mjs index 6cc6e754..df53590d 100755 --- a/esbuild/build.mjs +++ b/esbuild/build.mjs @@ -54,7 +54,14 @@ const common = { build({ ...common, entryPoints: ['src/scss/base.scss'], - outfile: 'dist/css/yfm-base.css', + outfile: 'dist/css/base.css', + format: 'iife', + plugins, + }), + build({ + ...common, + entryPoints: ['src/scss/_yfm-only.scss'], + outfile: 'dist/css/_yfm-only.css', format: 'iife', plugins, }), @@ -75,8 +82,14 @@ const common = { }); await build({ ...common, - entryPoints: ['dist/css/yfm-base.css'], - outfile: 'dist/css/yfm-base.min.css', + entryPoints: ['dist/css/base.css'], + outfile: 'dist/css/base.min.css', + minify: true, + }); + await build({ + ...common, + entryPoints: ['dist/css/_yfm-only.css'], + outfile: 'dist/css/_yfm-only.min.css', minify: true, }); })(); @@ -91,7 +104,7 @@ const common = { build({ ...common, entryPoints: ['src/js/base.ts'], - outfile: 'dist/js/yfm-base.js', + outfile: 'dist/js/base.js', }), build({ ...common, @@ -108,8 +121,8 @@ const common = { }); await build({ ...common, - entryPoints: ['dist/js/yfm-base.js'], - outfile: 'dist/js/yfm-base.min.js', + entryPoints: ['dist/js/base.js'], + outfile: 'dist/js/base.min.js', minify: true, }); })(); diff --git a/src/scss/_yfm-only.scss b/src/scss/_yfm-only.scss new file mode 100644 index 00000000..65bc0494 --- /dev/null +++ b/src/scss/_yfm-only.scss @@ -0,0 +1,10 @@ +/** + Note: This file excludes cut and tabs for flexibility, + as they may be handled separately in the future. + Direct usage is not recommended, as the file is subject + to changes without prior notice. +*/ + +@import 'note'; +@import 'file'; +@import 'table'; diff --git a/src/scss/base.scss b/src/scss/base.scss index 19c5814a..7b93b3cd 100644 --- a/src/scss/base.scss +++ b/src/scss/base.scss @@ -1,9 +1,6 @@ @import 'common'; -@import 'note'; @import 'anchor'; @import 'highlight'; @import 'code'; -@import 'file'; @import 'term'; -@import 'table'; @import 'modal'; diff --git a/src/scss/yfm.scss b/src/scss/yfm.scss index 380c81c6..58c0af6d 100644 --- a/src/scss/yfm.scss +++ b/src/scss/yfm.scss @@ -1,3 +1,4 @@ @import 'base'; +@import 'yfm-only'; @import '@diplodoc/cut-extension/runtime'; @import '@diplodoc/tabs-extension/runtime'; From d63d526538f9800860dd426ba8af3ce0686d1677 Mon Sep 17 00:00:00 2001 From: makhnatkin Date: Tue, 22 Oct 2024 11:52:25 +0200 Subject: [PATCH 3/5] feat(build): updated _yfm-only.scss comment and base.scss --- src/scss/_yfm-only.scss | 12 +++++++----- src/scss/base.scss | 2 -- src/scss/yfm.scss | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/scss/_yfm-only.scss b/src/scss/_yfm-only.scss index 65bc0494..acd5bc81 100644 --- a/src/scss/_yfm-only.scss +++ b/src/scss/_yfm-only.scss @@ -1,10 +1,12 @@ /** - Note: This file excludes cut and tabs for flexibility, - as they may be handled separately in the future. - Direct usage is not recommended, as the file is subject - to changes without prior notice. -*/ + Note: This file excludes "cut" and "tabs" as they are handled separately + in dedicated extensions (packages). In the future, "note", "file", "term" + and "table" will also be excluded from this file and moved to yfm.scss, + once they are moved to separate packages. Direct usage is not recommended, + as the file is subject to changes without prior notice. + */ @import 'note'; @import 'file'; @import 'table'; +@import 'term'; diff --git a/src/scss/base.scss b/src/scss/base.scss index 7b93b3cd..d865c1fc 100644 --- a/src/scss/base.scss +++ b/src/scss/base.scss @@ -2,5 +2,3 @@ @import 'anchor'; @import 'highlight'; @import 'code'; -@import 'term'; -@import 'modal'; diff --git a/src/scss/yfm.scss b/src/scss/yfm.scss index 58c0af6d..24b79e70 100644 --- a/src/scss/yfm.scss +++ b/src/scss/yfm.scss @@ -1,4 +1,5 @@ @import 'base'; @import 'yfm-only'; +@import 'modal'; @import '@diplodoc/cut-extension/runtime'; @import '@diplodoc/tabs-extension/runtime'; From 5a4ff1608bf64f912c094cded579712cd6ea0038 Mon Sep 17 00:00:00 2001 From: makhnatkin Date: Tue, 22 Oct 2024 13:23:47 +0200 Subject: [PATCH 4/5] feat(build): added _yfm-only.js --- esbuild/build.mjs | 37 +++++++++++++++++++++++++------------ src/js/_yfm-only.ts | 1 + src/js/base.ts | 3 --- src/js/index.ts | 3 +++ 4 files changed, 29 insertions(+), 15 deletions(-) create mode 100644 src/js/_yfm-only.ts diff --git a/esbuild/build.mjs b/esbuild/build.mjs index df53590d..aa9db739 100755 --- a/esbuild/build.mjs +++ b/esbuild/build.mjs @@ -106,6 +106,11 @@ const common = { entryPoints: ['src/js/base.ts'], outfile: 'dist/js/base.js', }), + build({ + ...common, + entryPoints: ['src/js/_yfm-only.ts'], + outfile: 'dist/js/_yfm-only.js', + }), build({ ...common, entryPoints: ['src/js/print/index.ts'], @@ -113,16 +118,24 @@ const common = { }), ]); - await build({ - ...common, - entryPoints: ['dist/js/yfm.js'], - outfile: 'dist/js/yfm.min.js', - minify: true, - }); - await build({ - ...common, - entryPoints: ['dist/js/base.js'], - outfile: 'dist/js/base.min.js', - minify: true, - }); + await Promise.all([ + build({ + ...common, + entryPoints: ['dist/js/yfm.js'], + outfile: 'dist/js/yfm.min.js', + minify: true, + }), + build({ + ...common, + entryPoints: ['dist/js/base.js'], + outfile: 'dist/js/base.min.js', + minify: true, + }), + build({ + ...common, + entryPoints: ['dist/js/_yfm-only.js'], + outfile: 'dist/js/_yfm-only.min.js', + minify: true, + }), + ]); })(); diff --git a/src/js/_yfm-only.ts b/src/js/_yfm-only.ts new file mode 100644 index 00000000..7af3a58a --- /dev/null +++ b/src/js/_yfm-only.ts @@ -0,0 +1 @@ +import './term'; diff --git a/src/js/base.ts b/src/js/base.ts index 7d4b950e..8fe8d245 100644 --- a/src/js/base.ts +++ b/src/js/base.ts @@ -1,5 +1,2 @@ import './polyfill'; import './code'; -import './term'; -import './wide-mode'; -import './patch'; diff --git a/src/js/index.ts b/src/js/index.ts index ace390d8..7d615414 100644 --- a/src/js/index.ts +++ b/src/js/index.ts @@ -2,3 +2,6 @@ import '@diplodoc/cut-extension/runtime'; import '@diplodoc/tabs-extension/runtime'; import './base'; +import './_yfm-only'; +import './wide-mode'; +import './patch'; From 0953c348396d27f698046f2be3106a8c8f3c6607 Mon Sep 17 00:00:00 2001 From: makhnatkin Date: Tue, 22 Oct 2024 13:29:51 +0200 Subject: [PATCH 5/5] feat(build): fixed build (Promise.all) --- esbuild/build.mjs | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/esbuild/build.mjs b/esbuild/build.mjs index aa9db739..b33cf1fb 100755 --- a/esbuild/build.mjs +++ b/esbuild/build.mjs @@ -74,24 +74,26 @@ const common = { }), ]); - await build({ - ...common, - entryPoints: ['dist/css/yfm.css'], - outfile: 'dist/css/yfm.min.css', - minify: true, - }); - await build({ - ...common, - entryPoints: ['dist/css/base.css'], - outfile: 'dist/css/base.min.css', - minify: true, - }); - await build({ - ...common, - entryPoints: ['dist/css/_yfm-only.css'], - outfile: 'dist/css/_yfm-only.min.css', - minify: true, - }); + await Promise.all([ + build({ + ...common, + entryPoints: ['dist/css/yfm.css'], + outfile: 'dist/css/yfm.min.css', + minify: true, + }), + build({ + ...common, + entryPoints: ['dist/css/base.css'], + outfile: 'dist/css/base.min.css', + minify: true, + }), + build({ + ...common, + entryPoints: ['dist/css/_yfm-only.css'], + outfile: 'dist/css/_yfm-only.min.css', + minify: true, + }), + ]); })(); (async function buildJs() {