Move from TS to JS

pull/16/head
Nikita Karamov 2020-07-31 18:18:17 +02:00
parent 841ed23855
commit 12187ca227
No known key found for this signature in database
GPG Key ID: E40DFE6E993540FF
4 changed files with 20 additions and 37 deletions

View File

@ -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),
},

View File

@ -1,4 +1,4 @@
import './style.scss';
import './style.css';
import initializeShareon from './shareon';

View File

@ -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 <div class="shareon">
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 <div class="shareon">
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);

View File

@ -1,18 +0,0 @@
{
"compilerOptions": {
"lib": [
"dom",
"es6"
],
"module": "ES2020",
"noImplicitAny": true,
"noImplicitReturns": true,
"target": "es5"
},
"include": [
"./src/**/*"
],
"exclude": [
"node_modules"
]
}