-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(js): Exporting an esm bundle of the ECL js and logos - FRONT-47…
…01 (#3751)
- Loading branch information
Showing
25 changed files
with
431 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ module.exports = { | |
ECL: 'writable', | ||
}, | ||
env: { | ||
es2020: true, | ||
node: true, | ||
browser: true, | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import '@ecl/dom-utils/polyfills'; | ||
|
||
import Accordion from '@ecl/accordion'; | ||
import autoInit from '@ecl/dom-utils/autoinit'; | ||
import Banner from '@ecl/banner'; | ||
import Carousel from '@ecl/carousel'; | ||
import CategoryFilter from '@ecl/category-filter'; | ||
import Datepicker from '@ecl/datepicker'; | ||
import Breadcrumb from '@ecl/breadcrumb'; | ||
import ContentBlock from '@ecl/content-block'; | ||
import DescriptionList from '@ecl/description-list'; | ||
import Expandable from '@ecl/expandable'; | ||
import FileDownload from '@ecl/file'; | ||
import FileUpload from '@ecl/file-upload'; | ||
import Gallery from '@ecl/gallery'; | ||
import Indicator from '@ecl/indicator'; | ||
import InpageNavigation from '@ecl/inpage-navigation'; | ||
import MediaContainer from '@ecl/media-container'; | ||
import MegaMenu from '@ecl/mega-menu'; | ||
import Menu from '@ecl/menu'; | ||
import Modal from '@ecl/modal'; | ||
import NewsTicker from '@ecl/news-ticker'; | ||
import Notification from '@ecl/notification'; | ||
import Popover from '@ecl/popover'; | ||
import Range from '@ecl/range'; | ||
import Select from '@ecl/select'; | ||
import SiteHeader from '@ecl/site-header'; | ||
import Table from '@ecl/table'; | ||
import Tabs from '@ecl/tabs'; | ||
import Timeline from '@ecl/timeline'; | ||
|
||
const ECL = { | ||
autoInit, | ||
Accordion, | ||
Banner, | ||
Carousel, | ||
CategoryFilter, | ||
Datepicker, | ||
Breadcrumb, | ||
ContentBlock, | ||
DescriptionList, | ||
Expandable, | ||
FileDownload, | ||
FileUpload, | ||
Gallery, | ||
Indicator, | ||
InpageNavigation, | ||
MediaContainer, | ||
MegaMenu, | ||
Menu, | ||
Modal, | ||
NewsTicker, | ||
Notification, | ||
Popover, | ||
Range, | ||
Select, | ||
SiteHeader, | ||
Tabs, | ||
Table, | ||
Timeline, | ||
}; | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export { ECL }; | ||
|
||
if (typeof globalThis !== 'undefined') { | ||
globalThis.ECL = ECL; | ||
} else if (typeof window !== 'undefined') { | ||
window.ECL = ECL; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import '@ecl/dom-utils/polyfills'; | ||
|
||
import Accordion from '@ecl/accordion'; | ||
import autoInit from '@ecl/dom-utils/autoinit'; | ||
import Banner from '@ecl/banner'; | ||
import Carousel from '@ecl/carousel'; | ||
import CategoryFilter from '@ecl/category-filter'; | ||
import Datepicker from '@ecl/datepicker'; | ||
import Breadcrumb from '@ecl/breadcrumb'; | ||
import ContentBlock from '@ecl/content-block'; | ||
import DescriptionList from '@ecl/description-list'; | ||
import Expandable from '@ecl/expandable'; | ||
import FileDownload from '@ecl/file'; | ||
import FileUpload from '@ecl/file-upload'; | ||
import Gallery from '@ecl/gallery'; | ||
import Indicator from '@ecl/indicator'; | ||
import InpageNavigation from '@ecl/inpage-navigation'; | ||
import MediaContainer from '@ecl/media-container'; | ||
import MegaMenu from '@ecl/mega-menu'; | ||
import Menu from '@ecl/menu'; | ||
import Modal from '@ecl/modal'; | ||
import NewsTicker from '@ecl/news-ticker'; | ||
import Notification from '@ecl/notification'; | ||
import Popover from '@ecl/popover'; | ||
import Range from '@ecl/range'; | ||
import Select from '@ecl/select'; | ||
import SiteHeader from '@ecl/site-header'; | ||
import Table from '@ecl/table'; | ||
import Tabs from '@ecl/tabs'; | ||
import Timeline from '@ecl/timeline'; | ||
|
||
const ECL = { | ||
autoInit, | ||
Accordion, | ||
Banner, | ||
Carousel, | ||
CategoryFilter, | ||
Datepicker, | ||
Breadcrumb, | ||
ContentBlock, | ||
DescriptionList, | ||
Expandable, | ||
FileDownload, | ||
FileUpload, | ||
Gallery, | ||
Indicator, | ||
InpageNavigation, | ||
MediaContainer, | ||
MegaMenu, | ||
Menu, | ||
Modal, | ||
NewsTicker, | ||
Notification, | ||
Popover, | ||
Range, | ||
Select, | ||
SiteHeader, | ||
Tabs, | ||
Table, | ||
Timeline, | ||
}; | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export { ECL }; | ||
|
||
if (typeof globalThis !== 'undefined') { | ||
globalThis.ECL = ECL; | ||
} else if (typeof window !== 'undefined') { | ||
window.ECL = ECL; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const positiveSourceDir = path.resolve(__dirname, '../src/positive'); | ||
const negativeSourceDir = path.resolve(__dirname, '../src/negative'); | ||
const positiveOutputDir = path.resolve(__dirname, '../dist/positive'); | ||
const negativeOutputDir = path.resolve(__dirname, '../dist/negative'); | ||
|
||
if (!fs.existsSync(positiveOutputDir)) { | ||
fs.mkdirSync(positiveOutputDir, { recursive: true }); | ||
} | ||
if (!fs.existsSync(negativeOutputDir)) { | ||
fs.mkdirSync(negativeOutputDir, { recursive: true }); | ||
} | ||
|
||
const toCamelCase = (str) => | ||
str | ||
.replace(/-([a-z])/g, (match, letter) => letter.toUpperCase()) | ||
.replace(/[^a-zA-Z0-9]/g, ''); | ||
|
||
const generateSvgExports = (sourceDir, outputDir) => { | ||
const files = fs | ||
.readdirSync(sourceDir) | ||
.filter((file) => file.endsWith('.svg')); | ||
|
||
const svgExports = files.map((file) => { | ||
const name = path.basename(file, '.svg'); | ||
const sanitizedName = toCamelCase(name); | ||
const svgContent = fs | ||
.readFileSync(path.join(sourceDir, file), 'utf-8') | ||
.replace(/`/g, '\\`') | ||
.trim(); | ||
|
||
return `export const ${sanitizedName} = \`${svgContent}\`;`; | ||
}); | ||
|
||
const outputFile = path.resolve(outputDir, 'esm-export.js'); | ||
fs.writeFileSync(outputFile, svgExports.join('\n\n')); | ||
}; | ||
|
||
generateSvgExports(positiveSourceDir, positiveOutputDir); | ||
generateSvgExports(negativeSourceDir, negativeOutputDir); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
fd36c4f
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.
🚀 Deployed on https://v5-dev--europa-component-library.netlify.app