mirror of
https://github.com/tenrok/OverlayScrollbars.git
synced 2026-06-21 21:30:35 +03:00
add treeshaking tests
This commit is contained in:
-1
@@ -1,4 +1,3 @@
|
||||
/// <reference types="jest" />
|
||||
export declare const generateSelectCallback: (targetElms: HTMLElement[] | HTMLElement | null, callback: (targetAffectedElm: HTMLElement, possibleValues: string[], selectedValue: string) => any) => (event: Event | HTMLSelectElement | null) => void;
|
||||
export declare const generateClassChangeSelectCallback: (targetElms: HTMLElement[] | HTMLElement | null) => (event: Event | HTMLSelectElement | null) => void;
|
||||
export declare const selectOption: (select: HTMLSelectElement | null, selectedOption: string | number) => boolean;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"extends": "@~local/tsconfig",
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist/",
|
||||
"baseUrl": "./src/"
|
||||
"baseUrl": "./src/",
|
||||
"typeRoots": []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,14 +5,27 @@ const resolve = require('./resolve');
|
||||
// https://jestjs.io/docs/en/configuration.html
|
||||
|
||||
module.exports = {
|
||||
clearMocks: true,
|
||||
coverageDirectory: './.coverage/jest',
|
||||
coverageProvider: 'babel',
|
||||
testEnvironment: 'jsdom',
|
||||
moduleDirectories: resolve.directories,
|
||||
moduleFileExtensions: resolve.extensions.map((ext) => ext.replace(/\./, '')),
|
||||
testPathIgnorePatterns: ['\\\\node_modules\\\\'],
|
||||
displayName: 'jest',
|
||||
setupFilesAfterEnv: [path.resolve(__dirname, './jest.setup.js')],
|
||||
testMatch: ['**/tests/jest/**/*.test.[jt]s?(x)'],
|
||||
projects: [
|
||||
{
|
||||
displayName: 'node',
|
||||
testMatch: ['**/tests/jest-node/**/*.test.[jt]s?(x)'],
|
||||
testEnvironment: 'node',
|
||||
clearMocks: true,
|
||||
moduleDirectories: resolve.directories,
|
||||
moduleFileExtensions: resolve.extensions.map((ext) => ext.replace(/\./, '')),
|
||||
testPathIgnorePatterns: ['\\\\node_modules\\\\'],
|
||||
setupFilesAfterEnv: [path.resolve(__dirname, './jest.setup.js')],
|
||||
},
|
||||
{
|
||||
displayName: 'jsdom',
|
||||
testMatch: ['**/tests/jest-jsdom/**/*.test.[jt]s?(x)'],
|
||||
testEnvironment: 'jsdom',
|
||||
clearMocks: true,
|
||||
moduleDirectories: resolve.directories,
|
||||
moduleFileExtensions: resolve.extensions.map((ext) => ext.replace(/\./, '')),
|
||||
testPathIgnorePatterns: ['\\\\node_modules\\\\'],
|
||||
setupFilesAfterEnv: [path.resolve(__dirname, './jest.setup.js')],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// remove jsdom warning for not implemented second argument for window.getComputedStyle
|
||||
const cmptdStyle = window.getComputedStyle;
|
||||
window.getComputedStyle = (a) => cmptdStyle(a);
|
||||
try {
|
||||
const cmptdStyle = window.getComputedStyle;
|
||||
window.getComputedStyle = (a) => cmptdStyle(a);
|
||||
} catch {}
|
||||
|
||||
@@ -107,22 +107,30 @@ const createConfig = (userOptions = {}) => {
|
||||
const options = mergeAndResolveOptions(userOptions);
|
||||
const { project, mode, extractTypes, extractStyles, verbose } = options;
|
||||
const isBuild = mode === 'build';
|
||||
|
||||
if (verbose) {
|
||||
console.log('');
|
||||
console.log('PROJECT : ', project);
|
||||
console.log('OPTIONS : ', options);
|
||||
}
|
||||
let result;
|
||||
|
||||
if (isBuild) {
|
||||
const styles = extractStyles && pipelineStyles(resolve, options);
|
||||
const types = extractTypes && pipelineTypes(resolve, options);
|
||||
const js = pipelineBuild(resolve, options);
|
||||
|
||||
return [styles, types, js].flat().filter((build) => !!build);
|
||||
result = [styles, types, js].flat().filter((build) => !!build);
|
||||
} else {
|
||||
result = [pipelineDev(resolve, options)];
|
||||
}
|
||||
|
||||
return [pipelineDev(resolve, options)];
|
||||
if (verbose) {
|
||||
result[0].plugins.push({
|
||||
name: 'PROJECT',
|
||||
buildStart() {
|
||||
console.log('');
|
||||
console.log('PROJECT : ', project);
|
||||
console.log('OPTIONS : ', options);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
module.exports = createConfig;
|
||||
|
||||
@@ -61,10 +61,6 @@ module.exports = (resolve, options) => {
|
||||
return {
|
||||
input,
|
||||
output,
|
||||
treeshake: {
|
||||
propertyReadSideEffects: false,
|
||||
moduleSideEffects: false,
|
||||
},
|
||||
...rollupOptions,
|
||||
plugins: [
|
||||
rollupLicense(banner, sourcemap),
|
||||
|
||||
@@ -87,7 +87,7 @@ module.exports = {
|
||||
['@babel/plugin-proposal-private-methods', { loose: true }],
|
||||
],
|
||||
babelHelpers: 'runtime',
|
||||
shouldPrintComment: () => false,
|
||||
shouldPrintComment: (comment) => /@__PURE__/.test(comment),
|
||||
caller: {
|
||||
name: 'babel-rollup-build',
|
||||
},
|
||||
|
||||
@@ -75,7 +75,6 @@ module.exports = (testDir, mode = 'dev', onListening = null) => {
|
||||
output: {
|
||||
sourcemap: true,
|
||||
},
|
||||
treeshake: true,
|
||||
plugins: [
|
||||
rollupPluginStyles(),
|
||||
rollupPluginHtml(`Playwright: ${name}`, htmlName, () =>
|
||||
|
||||
Reference in New Issue
Block a user