From 12187ca227391ac1dbe7e3525c9cb34e63ba6cae Mon Sep 17 00:00:00 2001 From: Nikita Karamov Date: Fri, 31 Jul 2020 18:18:17 +0200 Subject: [PATCH] Move from TS to JS --- rollup.config.js | 6 ++---- src/{autoinit.ts => autoinit.js} | 2 +- src/{shareon.ts => shareon.js} | 31 +++++++++++++++++-------------- tsconfig.json | 18 ------------------ 4 files changed, 20 insertions(+), 37 deletions(-) rename src/{autoinit.ts => autoinit.js} (84%) rename src/{shareon.ts => shareon.js} (73%) delete mode 100644 tsconfig.json diff --git a/rollup.config.js b/rollup.config.js index 0d82244..266a6b9 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -4,7 +4,6 @@ import postcssPluginBanner from 'postcss-banner'; import postcssPluginCssnano from 'cssnano'; import strip from '@rollup/plugin-strip'; import { terser } from 'rollup-plugin-terser'; -import typescript from '@rollup/plugin-typescript'; const isDev = process.env.ROLLUP_WATCH || process.env.NODE_ENV === 'development'; @@ -20,7 +19,6 @@ const bannerText = `${pkg.name} v${pkg.version} by Nikita Karamov\n${pkg.homepag * @type {Plugin[]} */ const plugins = [ - typescript(), ]; if (!isDev) { @@ -98,12 +96,12 @@ const getOutputs = (baseDir) => { const config = [ { - input: './src/autoinit.ts', + input: './src/autoinit.js', output: getOutputs(`${outputDir}`), plugins, }, { - input: './src/shareon.ts', + input: './src/shareon.js', output: getOutputs(`${outputDir}noinit/`), plugins: plugins.slice(0, -1), }, diff --git a/src/autoinit.ts b/src/autoinit.js similarity index 84% rename from src/autoinit.ts rename to src/autoinit.js index a44dece..4374498 100644 --- a/src/autoinit.ts +++ b/src/autoinit.js @@ -1,4 +1,4 @@ -import './style.scss'; +import './style.css'; import initializeShareon from './shareon'; diff --git a/src/shareon.ts b/src/shareon.js similarity index 73% rename from src/shareon.ts rename to src/shareon.js index 72c8855..9446f3b 100644 --- a/src/shareon.ts +++ b/src/shareon.js @@ -1,15 +1,18 @@ -import urlBuilderMap from './networks'; +// eslint-disable-next-line import/no-unresolved +import urlBuilderMap from 'consts:urlBuilderMap'; -const initializeShareon = () : void => { +const initializeShareon = () => { const shareonContainers = document.getElementsByClassName('shareon'); // iterate over
for (let i = 0; i < shareonContainers.length; i += 1) { - const container = shareonContainers[i] as HTMLElement; + /** @type Element */ + const container = shareonContainers[i]; // iterate over children of
for (let j = 0; j < container.children.length; j += 1) { - const child = container.children[j] as HTMLElement; + /** @type Element */ + const child = container.children[j]; if (child) { const classListLength = child.classList.length; @@ -23,28 +26,28 @@ const initializeShareon = () : void => { const preset = { url: encodeURIComponent( child.dataset.url - || container.dataset.url - || window.location.href, + || container.dataset.url + || window.location.href, ), title: encodeURIComponent( child.dataset.title - || container.dataset.title - || document.title, + || container.dataset.title + || document.title, ), media: encodeURIComponent( child.dataset.media - || container.dataset.media - || '', + || container.dataset.media + || '', ), text: encodeURIComponent( child.dataset.text - || container.dataset.text - || '', + || container.dataset.text + || '', ), via: encodeURIComponent( child.dataset.via - || container.dataset.via - || '', + || container.dataset.via + || '', ), }; const url = urlBuilderMap[cls](preset); diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index 9014f5e..0000000 --- a/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "lib": [ - "dom", - "es6" - ], - "module": "ES2020", - "noImplicitAny": true, - "noImplicitReturns": true, - "target": "es5" - }, - "include": [ - "./src/**/*" - ], - "exclude": [ - "node_modules" - ] -}