diff --git a/.babelrc.js b/.babelrc.js index 9d06939..c1b7ba8 100644 --- a/.babelrc.js +++ b/.babelrc.js @@ -1,3 +1,15 @@ module.exports = { - presets: ['@babel/preset-typescript'], + presets: [ + '@babel/preset-typescript', + [ + '@babel/preset-env', + { + useBuiltIns: 'usage', + corejs: 3, + targets: { + browsers: ['last 2 versions', 'ie >= 11'], + }, + }, + ], + ], }; diff --git a/.eslintrc.js b/.eslintrc.js index b8acc45..2515552 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -11,7 +11,4 @@ module.exports = { es6: true, mocha: true, }, - globals: { - YT: true, - }, }; diff --git a/.gitignore b/.gitignore index 229c3a2..35ce816 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ /node_modules *.log .coverage -.rpt2_cache \ No newline at end of file +.rpt2_cache +dist \ No newline at end of file diff --git a/README.md b/README.md index dfd73d2..c38b3f9 100644 --- a/README.md +++ b/README.md @@ -145,26 +145,26 @@ The `scrollTo` method allows a set of options which are synonymous with the [ScrollToOptions](https://drafts.csswg.org/cssom-view/#dictdef-scrolltooptions) of the CSS specification, but some additional ones are provided by this library until supported natively. -| Option | Type | Description | -| ---------- | ------ | ----------- | -| `behavior` | String | The type of [scroll behavior](https://drafts.csswg.org/cssom-view/#enumdef-scrollbehavior) which can be set to `auto` or `smooth`. This is the recommended option since this is already natively supported. **If this is set, all other options are ignored**. | +| Option | Type | Description | +| ---------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `behavior` | String | The type of [scroll behavior](https://drafts.csswg.org/cssom-view/#enumdef-scrollbehavior) which can be set to `auto` or `smooth`. This is the recommended option since this is already natively supported. **If this is set, all other options are ignored**. | | `duration` | Number | The number of milliseconds the scroll will take to complete | | `easing` | String | The easing to use when scrolling. Only keyword values of the [animation-timing-function](https://drafts.csswg.org/css-animations/#animation-timing-function) are supported. But passing function values will eventually be supported also (ie. `cubic-bezier(0.1, 0.7, 1.0, 0.1)`, `steps(4, end)`, etc) | ### scrollIntoView(element, [scroller], [options]) -| Option | Type | Description | -| ---------- | ----------------------- | ---------------------------- | -| `element` | `HTMLElement` | The element to scroll into the viewport | -| `scroller` | `HTMLElement` | The element to be scrolled (defaults to `document.body`) | -| `options` | `ScrollIntoViewOptions` | A set of scroll options to scroll the element into view (see writeup below) (i.e. `{behavior: 'smooth', top: '20', left: '0''}`) | +| Option | Type | Description | +| ---------- | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------- | +| `element` | `HTMLElement` | The element to scroll into the viewport | +| `scroller` | `HTMLElement` | The element to be scrolled (defaults to `document.body`) | +| `options` | `ScrollIntoViewOptions` | A set of scroll options to scroll the element into view (see writeup below) (i.e. `{behavior: 'smooth', top: '20', left: '0''}`) | #### scrollIntoView Options A set of [ScrollIntoViewOptions](https://drafts.csswg.org/cssom-view/#dictdef-scrollintoviewoptions) can be passed to the `scrollIntoView` method. -| Option | Type | Description | -| ---------- | ------ | ---------------------------------------------------------------------------------------------------- | +| Option | Type | Description | +| ---------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | | `behavior` | String | The type of [scroll behavior](https://drafts.csswg.org/cssom-view/#enumdef-scrollbehavior) which can be set to `auto` or `smooth`. Defaults to `auto`. | ## Examples @@ -173,7 +173,7 @@ Code samples showing how to use this package can be found in the [examples](exam and ```bash -npm run start-server +npm start ``` Which will make the examples available at http://localhost:9383/examples/. diff --git a/dist/scroll.d.ts b/dist/scroll.d.ts deleted file mode 100644 index e27db88..0000000 --- a/dist/scroll.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -declare type EasingOptions = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out'; -export interface ScrollToCustomOptions extends ScrollToOptions { - duration?: number; - easing?: EasingOptions; -} -export declare function scrollTo(el: Element | Window, options?: ScrollToCustomOptions): Promise; -export declare function scrollIntoView(element: HTMLElement, scroller?: Element | ScrollIntoViewOptions, options?: ScrollIntoViewOptions): Promise; -export declare const utils: { - getDocument(): HTMLDocument; -}; -declare type EasingFunction = (t: number) => number; -interface EasingFunctions { - linear: EasingFunction; - 'ease-in': EasingFunction; - 'ease-out': EasingFunction; - 'ease-in-out': EasingFunction; -} -export declare const easingMap: EasingFunctions; -export {}; diff --git a/dist/scroll.js b/dist/scroll.js deleted file mode 100644 index a7d2efc..0000000 --- a/dist/scroll.js +++ /dev/null @@ -1,184 +0,0 @@ -/*! - * Scroll-js v2.3.2 - * https://github.com/mkay581/scroll-js - * - * Copyright (c) 2019 Mark Kennedy - * Licensed under the MIT license - */ - -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ - -function __awaiter(thisArg, _arguments, P, generator) { - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -} - -function scrollTo(el, options = {}) { - return __awaiter(this, void 0, void 0, function* () { - if (!(el instanceof Element) && !(el instanceof Window)) { - throw new Error(`element passed to scrollTo() must be either the window or a DOM element, you passed ${el}!`); - } - options = sanitizeScrollOptions(options); - const scroll = (from, to, prop, startTime, duration = 300, easeFunc, callback) => { - window.requestAnimationFrame(() => { - const currentTime = Date.now(); - const time = Math.min(1, (currentTime - startTime) / duration); - if (from === to) { - return callback ? callback() : null; - } - setScrollPosition(el, easeFunc(time) * (to - from) + from); - /* prevent scrolling, if already there, or at end */ - if (time < 1) { - scroll(from, to, prop, startTime, duration, easeFunc, callback); - } - else if (callback) { - callback(); - } - }); - }; - const currentScrollPosition = getScrollPosition(el); - const scrollProperty = getScrollPropertyByElement(el); - return new Promise(resolve => { - scroll(currentScrollPosition, typeof options.top === 'number' - ? options.top - : currentScrollPosition, scrollProperty, Date.now(), options.duration, getEasing(options.easing), resolve); - }); - }); -} -function scrollIntoView(element, scroller, options) { - validateElement(element); - if (scroller && !(scroller instanceof Element)) { - options = scroller; - scroller = undefined; - } - const { duration, easing } = sanitizeScrollOptions(options); - scroller = scroller || utils.getDocument().body; - let currentContainerScrollYPos = 0; - let elementScrollYPos = element ? element.offsetTop : 0; - const document = utils.getDocument(); - // if the container is the document body or document itself, we'll - // need a different set of coordinates for accuracy - if (scroller === document.body || scroller === document.documentElement) { - // using pageYOffset for cross-browser compatibility - currentContainerScrollYPos = window.pageYOffset; - // must add containers scroll y position to ensure an absolute value that does not change - elementScrollYPos = - element.getBoundingClientRect().top + currentContainerScrollYPos; - } - return scrollTo(scroller, { - top: elementScrollYPos, - left: 0, - duration, - easing - }); -} -function validateElement(element) { - if (element === undefined) { - const errorMsg = 'The element passed to scrollIntoView() was undefined.'; - throw new Error(errorMsg); - } - if (!(element instanceof HTMLElement)) { - throw new Error(`The element passed to scrollIntoView() must be a valid element. You passed ${element}.`); - } -} -function getScrollPropertyByElement(el) { - const props = { - window: { - y: 'scrollY', - x: 'scrollX' - }, - element: { - y: 'scrollTop', - x: 'scrollLeft' - } - }; - const axis = 'y'; - if (el instanceof Window) { - return props.window[axis]; - } - else { - return props.element[axis]; - } -} -function sanitizeScrollOptions(options = {}) { - if (options.behavior === 'smooth') { - options.easing = 'ease-in-out'; - options.duration = 300; - } - if (options.behavior === 'auto') { - options.duration = 0; - options.easing = 'linear'; - } - return options; -} -function getScrollPosition(el) { - const document = utils.getDocument(); - if (el === document.body || - el === document.documentElement || - el instanceof Window) { - return document.body.scrollTop || document.documentElement.scrollTop; - } - else { - return el.scrollTop; - } -} -function setScrollPosition(el, value) { - const document = utils.getDocument(); - if (el === document.body || - el === document.documentElement || - el instanceof Window) { - document.body.scrollTop = value; - document.documentElement.scrollTop = value; - } - else { - el.scrollTop = value; - } -} -const utils = { - // we're really just exporting this so that tests can mock the document.documentElement - getDocument() { - return document; - } -}; -const easingMap = { - linear(t) { - return t; - }, - 'ease-in'(t) { - return t * t; - }, - 'ease-out'(t) { - return t * (2 - t); - }, - 'ease-in-out'(t) { - return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t; - } -}; -const getEasing = (easing) => { - const defaultEasing = 'linear'; - const easeFunc = easingMap[easing || defaultEasing]; - if (!easeFunc) { - const options = Object.keys(easingMap).join(','); - throw new Error(`Scroll error: scroller does not support an easing option of "${easing}". Supported options are ${options}`); - } - return easeFunc; -}; - -export { easingMap, scrollIntoView, scrollTo, utils }; diff --git a/dist/scroll.min.js b/dist/scroll.min.js deleted file mode 100644 index bdd2a81..0000000 --- a/dist/scroll.min.js +++ /dev/null @@ -1 +0,0 @@ -function e(e,n={}){return r=this,s=void 0,l=function*(){if(!(e instanceof Element||e instanceof Window))throw new Error(`element passed to scrollTo() must be either the window or a DOM element, you passed ${e}!`);n=o(n);const r=(n,o,i,s,c=300,l,u)=>{window.requestAnimationFrame(()=>{const a=Date.now(),d=Math.min(1,(a-s)/c);if(n===o)return u?u():null;!function(e,n){const o=t.getDocument();e===o.body||e===o.documentElement||e instanceof Window?(o.body.scrollTop=n,o.documentElement.scrollTop=n):e.scrollTop=n}(e,l(d)*(o-n)+n),d<1?r(n,o,i,s,c,l,u):u&&u()})},s=function(e){const n=t.getDocument();return e===n.body||e===n.documentElement||e instanceof Window?n.body.scrollTop||n.documentElement.scrollTop:e.scrollTop}(e),c=function(e){const n={window:{y:"scrollY",x:"scrollX"},element:{y:"scrollTop",x:"scrollLeft"}};return e instanceof Window?n.window.y:n.element.y}(e);return new Promise(e=>{r(s,"number"==typeof n.top?n.top:s,c,Date.now(),n.duration,i(n.easing),e)})},new((c=void 0)||(c=Promise))(function(e,n){function o(e){try{i(l.next(e))}catch(e){n(e)}}function t(e){try{i(l.throw(e))}catch(e){n(e)}}function i(n){n.done?e(n.value):new c(function(e){e(n.value)}).then(o,t)}i((l=l.apply(r,s||[])).next())});var r,s,c,l}function n(n,r,i){!function(e){if(void 0===e){throw new Error("The element passed to scrollIntoView() was undefined.")}if(!(e instanceof HTMLElement))throw new Error(`The element passed to scrollIntoView() must be a valid element. You passed ${e}.`)}(n),!r||r instanceof Element||(i=r,r=void 0);const{duration:s,easing:c}=o(i);r=r||t.getDocument().body;let l=0,u=n?n.offsetTop:0;const a=t.getDocument();return r!==a.body&&r!==a.documentElement||(l=window.pageYOffset,u=n.getBoundingClientRect().top+l),e(r,{top:u,left:0,duration:s,easing:c})}function o(e={}){return"smooth"===e.behavior&&(e.easing="ease-in-out",e.duration=300),"auto"===e.behavior&&(e.duration=0,e.easing="linear"),e}const t={getDocument:()=>document},r={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:(4-2*e)*e-1},i=e=>{const n=r[e||"linear"];if(!n){const n=Object.keys(r).join(",");throw new Error(`Scroll error: scroller does not support an easing option of "${e}". Supported options are ${n}`)}return n};export{r as easingMap,n as scrollIntoView,e as scrollTo,t as utils}; diff --git a/examples/index.html b/examples/index.html new file mode 100644 index 0000000..f570ce6 --- /dev/null +++ b/examples/index.html @@ -0,0 +1,14 @@ + + + Examples + + + + + + diff --git a/package-lock.json b/package-lock.json index 1cfc255..c88d85e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1022,15 +1022,6 @@ "integrity": "sha512-+YB9FtyxXGyD54p8rXwWaN1EWEyar5L58GlGWgtH2I9rGmLGBQcw63+0jw+ujqVavNuO47S1ByAjm9zdHMnskw==", "dev": true }, - "@types/resolve": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-0.0.8.tgz", - "integrity": "sha512-auApPaJf3NPfe18hSoJkp8EbZzer2ISk7o8mCC3M9he/a04+gbMF97NkpD2S8riMGvm4BMRI59/SZQSaLTKpsQ==", - "dev": true, - "requires": { - "@types/node": "*" - } - }, "@typescript-eslint/eslint-plugin": { "version": "1.13.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-1.13.0.tgz", @@ -1541,12 +1532,6 @@ "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", "dev": true }, - "builtin-modules": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.1.0.tgz", - "integrity": "sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw==", - "dev": true - }, "bytes": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", @@ -1896,14 +1881,13 @@ "dev": true }, "core-js-compat": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.1.4.tgz", - "integrity": "sha512-Z5zbO9f1d0YrJdoaQhphVAnKPimX92D6z8lCGphH89MNRxlL1prI9ExJPqVwP0/kgkQCv8c4GJGT8X16yUncOg==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.2.1.tgz", + "integrity": "sha512-MwPZle5CF9dEaMYdDeWm73ao/IflDH+FjeJCWEADcEgFSE9TLimFKwJsfmkwzI8eC0Aj0mgvMDjeQjrElkz4/A==", "dev": true, "requires": { - "browserslist": "^4.6.2", - "core-js-pure": "3.1.4", - "semver": "^6.1.1" + "browserslist": "^4.6.6", + "semver": "^6.3.0" }, "dependencies": { "semver": { @@ -1914,12 +1898,6 @@ } } }, - "core-js-pure": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.1.4.tgz", - "integrity": "sha512-uJ4Z7iPNwiu1foygbcZYJsJs1jiXrTTCvxfLDXNhI/I+NHbSIEyr548y4fcsCEyWY0XgfAG/qqaunJ1SThHenA==", - "dev": true - }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -3314,12 +3292,6 @@ "is-extglob": "^2.1.1" } }, - "is-module": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", - "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=", - "dev": true - }, "is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", @@ -5091,13 +5063,13 @@ "dev": true }, "regexpu-core": { - "version": "4.5.4", - "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.5.4.tgz", - "integrity": "sha512-BtizvGtFQKGPUcTy56o3nk1bGRp4SZOTYrDtGNlqCQufptV5IkkLN6Emw+yunAJjzf+C9FQFtvq7IoA3+oMYHQ==", + "version": "4.5.5", + "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.5.5.tgz", + "integrity": "sha512-FpI67+ky9J+cDizQUJlIlNZFKual/lUkFr1AG6zOCpwZ9cLrg8UUVakyUQJD7fCDIe9Z2nwTQJNPyonatNmDFQ==", "dev": true, "requires": { "regenerate": "^1.4.0", - "regenerate-unicode-properties": "^8.0.2", + "regenerate-unicode-properties": "^8.1.0", "regjsgen": "^0.5.0", "regjsparser": "^0.6.0", "unicode-match-property-ecmascript": "^1.0.4", @@ -5269,6 +5241,16 @@ "acorn": "^6.2.0" } }, + "rollup-plugin-babel": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/rollup-plugin-babel/-/rollup-plugin-babel-4.3.3.tgz", + "integrity": "sha512-tKzWOCmIJD/6aKNz0H1GMM+lW1q9KyFubbWzGiOG540zxPPifnEAHTZwjo0g991Y+DyOZcLqBgqOdqazYE5fkw==", + "dev": true, + "requires": { + "@babel/helper-module-imports": "^7.0.0", + "rollup-pluginutils": "^2.8.1" + } + }, "rollup-plugin-commonjs": { "version": "10.0.2", "resolved": "https://registry.npmjs.org/rollup-plugin-commonjs/-/rollup-plugin-commonjs-10.0.2.tgz", @@ -5282,17 +5264,14 @@ "rollup-pluginutils": "^2.8.1" } }, - "rollup-plugin-node-resolve": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-5.2.0.tgz", - "integrity": "sha512-jUlyaDXts7TW2CqQ4GaO5VJ4PwwaV8VUGA7+km3n6k6xtOEacf61u0VXwN80phY/evMcaS+9eIeJ9MOyDxt5Zw==", + "rollup-plugin-serve": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/rollup-plugin-serve/-/rollup-plugin-serve-1.0.1.tgz", + "integrity": "sha512-bni0pb4s1YLvn1xBmj+dH1OsLdp8gWA4zqh3yuEtT6/YHhg3nDneGU2GwMcRDQwY2tXzuI0uSeAlF1rY+ODitg==", "dev": true, "requires": { - "@types/resolve": "0.0.8", - "builtin-modules": "^3.1.0", - "is-module": "^1.0.0", - "resolve": "^1.11.1", - "rollup-pluginutils": "^2.8.1" + "mime": ">=2.0.3", + "opener": "1" } }, "rollup-plugin-terser": { diff --git a/package.json b/package.json index 9b75fdc..4387238 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,8 @@ "engines": { "node": ">=8.9.0" }, - "main": "./dist/scroll.js", + "main": "./dist/scroll.common.js", + "module": "./dist/scroll.js", "types": "./dist/scroll.d.ts", "files": [ "dist/**/*" @@ -42,10 +43,11 @@ "banner": "banner-cli dist/*.js", "start": "rollup -c --watch", "lint": "eslint '**/*.{js,ts}'", - "start-server": "http-server ./ -p 9383", "coveralls": "cat .coverage/lcov.info | coveralls" }, "devDependencies": { + "@babel/core": "^7.5.5", + "@babel/preset-env": "^7.5.5", "@babel/preset-typescript": "^7.3.3", "@open-wc/karma-esm": "^2.2.8", "@types/chai": "^4.1.7", @@ -56,7 +58,6 @@ "chai": "^4.2.0", "coveralls": "^3.0.5", "eslint": "^6.1.0", - "http-server": "^0.11.1", "karma": "^4.2.0", "karma-chrome-launcher": "^3.0.0", "karma-coverage": "^1.1.2", @@ -67,8 +68,9 @@ "prettier": "^1.18.2", "raf-stub": "^3.0.0", "rollup": "^1.18.0", + "rollup-plugin-babel": "^4.3.3", "rollup-plugin-commonjs": "^10.0.2", - "rollup-plugin-node-resolve": "^5.2.0", + "rollup-plugin-serve": "^1.0.1", "rollup-plugin-terser": "^5.1.1", "rollup-plugin-typescript2": "^0.22.1", "sinon": "^7.4.0", diff --git a/rollup.config.js b/rollup.config.js index 1bcf03a..6959a63 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,31 +1,60 @@ import typescript from 'rollup-plugin-typescript2'; -import resolve from 'rollup-plugin-node-resolve'; import commonjs from 'rollup-plugin-commonjs'; import { terser } from 'rollup-plugin-terser'; +import babel from 'rollup-plugin-babel'; +import serve from 'rollup-plugin-serve'; + +const basePlugins = [typescript()]; +const commonJSPlugins = [ + ...basePlugins, + babel({ + exclude: 'node_modules/**', + extensions: ['.ts'], + }), + commonjs(), + process.env.ROLLUP_WATCH && + serve({ + historyApiFallback: true, + contentBase: '', + port: 9383, + }), +]; export default [ { input: 'src/scroll.ts', output: { format: 'esm', - file: 'dist/scroll.js' + file: 'dist/scroll.js', + }, + plugins: basePlugins, + watch: { + include: 'src/**', + }, + }, + { + input: 'src/scroll.ts', + output: { + format: 'cjs', + file: 'dist/scroll.common.js', }, - plugins: [resolve(), typescript(), commonjs()], + plugins: commonJSPlugins, watch: { - include: 'src/**' - } + include: 'src/**', + }, }, { - input: 'dist/scroll.js', + input: 'src/scroll.ts', output: { format: 'esm', - file: 'dist/scroll.min.js' + file: 'dist/scroll.min.js', }, plugins: [ + ...commonJSPlugins, terser({ compress: true, - mangle: true - }) - ] - } + mangle: true, + }), + ], + }, ]; diff --git a/tsconfig.json b/tsconfig.json index 6580375..c52d22a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,7 @@ { "compilerOptions": { - "target": "es6", + "target": "esnext", "module": "esnext", - "moduleResolution": "node", "strict": true, "declaration": true, "esModuleInterop": true,