Move from TS to JS
parent
841ed23855
commit
12187ca227
|
@ -4,7 +4,6 @@ import postcssPluginBanner from 'postcss-banner';
|
||||||
import postcssPluginCssnano from 'cssnano';
|
import postcssPluginCssnano from 'cssnano';
|
||||||
import strip from '@rollup/plugin-strip';
|
import strip from '@rollup/plugin-strip';
|
||||||
import { terser } from 'rollup-plugin-terser';
|
import { terser } from 'rollup-plugin-terser';
|
||||||
import typescript from '@rollup/plugin-typescript';
|
|
||||||
|
|
||||||
const isDev = process.env.ROLLUP_WATCH || process.env.NODE_ENV === 'development';
|
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[]}
|
* @type {Plugin[]}
|
||||||
*/
|
*/
|
||||||
const plugins = [
|
const plugins = [
|
||||||
typescript(),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!isDev) {
|
if (!isDev) {
|
||||||
|
@ -98,12 +96,12 @@ const getOutputs = (baseDir) => {
|
||||||
|
|
||||||
const config = [
|
const config = [
|
||||||
{
|
{
|
||||||
input: './src/autoinit.ts',
|
input: './src/autoinit.js',
|
||||||
output: getOutputs(`${outputDir}`),
|
output: getOutputs(`${outputDir}`),
|
||||||
plugins,
|
plugins,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
input: './src/shareon.ts',
|
input: './src/shareon.js',
|
||||||
output: getOutputs(`${outputDir}noinit/`),
|
output: getOutputs(`${outputDir}noinit/`),
|
||||||
plugins: plugins.slice(0, -1),
|
plugins: plugins.slice(0, -1),
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import './style.scss';
|
import './style.css';
|
||||||
|
|
||||||
import initializeShareon from './shareon';
|
import initializeShareon from './shareon';
|
||||||
|
|
|
@ -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');
|
const shareonContainers = document.getElementsByClassName('shareon');
|
||||||
|
|
||||||
// iterate over <div class="shareon">
|
// iterate over <div class="shareon">
|
||||||
for (let i = 0; i < shareonContainers.length; i += 1) {
|
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">
|
// iterate over children of <div class="shareon">
|
||||||
for (let j = 0; j < container.children.length; j += 1) {
|
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) {
|
if (child) {
|
||||||
const classListLength = child.classList.length;
|
const classListLength = child.classList.length;
|
||||||
|
@ -23,28 +26,28 @@ const initializeShareon = () : void => {
|
||||||
const preset = {
|
const preset = {
|
||||||
url: encodeURIComponent(
|
url: encodeURIComponent(
|
||||||
child.dataset.url
|
child.dataset.url
|
||||||
|| container.dataset.url
|
|| container.dataset.url
|
||||||
|| window.location.href,
|
|| window.location.href,
|
||||||
),
|
),
|
||||||
title: encodeURIComponent(
|
title: encodeURIComponent(
|
||||||
child.dataset.title
|
child.dataset.title
|
||||||
|| container.dataset.title
|
|| container.dataset.title
|
||||||
|| document.title,
|
|| document.title,
|
||||||
),
|
),
|
||||||
media: encodeURIComponent(
|
media: encodeURIComponent(
|
||||||
child.dataset.media
|
child.dataset.media
|
||||||
|| container.dataset.media
|
|| container.dataset.media
|
||||||
|| '',
|
|| '',
|
||||||
),
|
),
|
||||||
text: encodeURIComponent(
|
text: encodeURIComponent(
|
||||||
child.dataset.text
|
child.dataset.text
|
||||||
|| container.dataset.text
|
|| container.dataset.text
|
||||||
|| '',
|
|| '',
|
||||||
),
|
),
|
||||||
via: encodeURIComponent(
|
via: encodeURIComponent(
|
||||||
child.dataset.via
|
child.dataset.via
|
||||||
|| container.dataset.via
|
|| container.dataset.via
|
||||||
|| '',
|
|| '',
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
const url = urlBuilderMap[cls](preset);
|
const url = urlBuilderMap[cls](preset);
|
|
@ -1,18 +0,0 @@
|
||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"lib": [
|
|
||||||
"dom",
|
|
||||||
"es6"
|
|
||||||
],
|
|
||||||
"module": "ES2020",
|
|
||||||
"noImplicitAny": true,
|
|
||||||
"noImplicitReturns": true,
|
|
||||||
"target": "es5"
|
|
||||||
},
|
|
||||||
"include": [
|
|
||||||
"./src/**/*"
|
|
||||||
],
|
|
||||||
"exclude": [
|
|
||||||
"node_modules"
|
|
||||||
]
|
|
||||||
}
|
|
Loading…
Reference in New Issue