rollup plugins fix

This commit is contained in:
codecalm 2024-01-19 02:15:46 +01:00
parent a06ad58685
commit 0a955dcc11
12 changed files with 364 additions and 381 deletions

View File

@ -4,11 +4,6 @@ import { PACKAGES_DIR, readSvgs, readAliases, toPascalCase } from './helpers.mjs
import { stringify } from 'svgson' import { stringify } from 'svgson'
import prettier from "@prettier/sync" import prettier from "@prettier/sync"
import bundleSize from '@atomico/rollup-plugin-sizes'
import { visualizer } from 'rollup-plugin-visualizer'
import license from 'rollup-plugin-license'
import esbuild from 'rollup-plugin-esbuild'
/** /**
* Build icons * Build icons
* *
@ -121,18 +116,3 @@ export const buildIcons = ({
} }
} }
export const getRollupPlugins = (pkg, minify) => {
return [
esbuild({
minify
}),
license({
banner: `${pkg.name} v${pkg.version} - ${pkg.license}`
}),
bundleSize(),
visualizer({
sourcemap: false,
filename: `stats/${pkg.name}${minify ? '-min' : ''}.html`
})
].filter(Boolean)
}

23
.build/rollup-plugins.mjs Normal file
View File

@ -0,0 +1,23 @@
import bundleSize from '@atomico/rollup-plugin-sizes'
import { visualizer } from 'rollup-plugin-visualizer'
import license from 'rollup-plugin-license'
import esbuild from 'rollup-plugin-esbuild'
export const getRollupPlugins = (pkg, minify) => {
return [
esbuild({
minify
}),
license({
banner: `@license ${pkg.name} v${pkg.version} - ${pkg.license}
This source code is licensed under the ${pkg.license} license.
See the LICENSE file in the root directory of this source tree.`
}),
bundleSize(),
visualizer({
sourcemap: false,
filename: `stats/${pkg.name}${minify ? '-min' : ''}.html`
})
].filter(Boolean)
}

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2020-2023 Paweł Kuna Copyright (c) 2020-2024 Paweł Kuna
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -93,7 +93,7 @@
"svgpath": "^2.6.0", "svgpath": "^2.6.0",
"svgson": "^5.3.1", "svgson": "^5.3.1",
"typescript": "^5.3.3", "typescript": "^5.3.3",
"vitest": "^1.2.1" "vitest": "^1.1.3"
}, },
"release-it": { "release-it": {
"plugins": { "plugins": {

View File

@ -1,5 +1,5 @@
import fs from 'fs' import fs from 'fs'
import { getRollupPlugins } from '../../.build/build-icons.mjs' import { getRollupPlugins } from '../../.build/rollup-plugins.mjs'
import dts from "rollup-plugin-dts"; import dts from "rollup-plugin-dts";
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8')) const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'))
@ -38,7 +38,7 @@ const configs = bundles
inputs.map(input => ({ inputs.map(input => ({
input, input,
plugins: getRollupPlugins(pkg, minify), plugins: getRollupPlugins(pkg, minify),
external: ['preact', 'prop-types'], external: ['preact'],
output: { output: {
name: packageName, name: packageName,
...(preserveModules ...(preserveModules
@ -52,8 +52,7 @@ const configs = bundles
format, format,
sourcemap: true, sourcemap: true,
globals: { globals: {
preact: 'preact', preact: 'preact'
'prop-types': 'PropTypes',
}, },
}, },
})), })),

View File

@ -40,13 +40,12 @@
"@tabler/icons": "3.0.0-alpha.0" "@tabler/icons": "3.0.0-alpha.0"
}, },
"devDependencies": { "devDependencies": {
"@babel/preset-env": "7.11.5", "@babel/preset-env": "7.23.8",
"@babel/preset-react": "7.10.4", "@babel/preset-react": "7.23.3",
"@testing-library/react": "^14.1.2", "@testing-library/react": "^14.1.2",
"@types/react": "18.2.0", "@types/react": "18.2.48",
"@vitejs/plugin-react": "^4.2.1", "@vitejs/plugin-react": "^4.2.1",
"babel-jest": "^29.4.1", "babel-jest": "^29.7.0",
"prop-types": "^15.8.1",
"react": "18.2.0", "react": "18.2.0",
"react-dom": "18.2.0", "react-dom": "18.2.0",
"react-test-renderer": "18.2.0" "react-test-renderer": "18.2.0"

View File

@ -1,5 +1,5 @@
import fs from 'fs' import fs from 'fs'
import { getRollupPlugins } from '../../.build/build-icons.mjs' import { getRollupPlugins } from '../../.build/rollup-plugins.mjs'
import dts from "rollup-plugin-dts"; import dts from "rollup-plugin-dts";
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8')) const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'))
@ -38,7 +38,7 @@ const configs = bundles
inputs.map(input => ({ inputs.map(input => ({
input, input,
plugins: getRollupPlugins(pkg, minify), plugins: getRollupPlugins(pkg, minify),
external: ['react', 'prop-types'], external: ['react'],
output: { output: {
name: packageName, name: packageName,
...(preserveModules ...(preserveModules
@ -52,8 +52,7 @@ const configs = bundles
sourcemap: true, sourcemap: true,
preserveModules, preserveModules,
globals: { globals: {
react: 'react', react: 'react'
'prop-types': 'PropTypes'
}, },
}, },
})), })),

View File

@ -1,5 +1,5 @@
import fs from 'fs' import fs from 'fs'
import { getRollupPlugins } from '../../.build/build-icons.mjs' import { getRollupPlugins } from '../../.build/rollup-plugins.mjs'
import dts from "rollup-plugin-dts"; import dts from "rollup-plugin-dts";
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8')) const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'))

View File

@ -1,5 +1,5 @@
import fs from 'fs' import fs from 'fs'
import { getRollupPlugins } from '../../.build/build-icons.mjs' import { getRollupPlugins } from '../../.build/rollup-plugins.mjs'
import dts from "rollup-plugin-dts"; import dts from "rollup-plugin-dts";
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8')) const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'))

View File

@ -1,5 +1,5 @@
import fs from 'fs' import fs from 'fs'
import { getRollupPlugins } from '../../.build/build-icons.mjs' import { getRollupPlugins } from '../../.build/rollup-plugins.mjs'
import dts from "rollup-plugin-dts"; import dts from "rollup-plugin-dts";
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8')) const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'))

File diff suppressed because it is too large Load Diff

View File

@ -15,10 +15,10 @@
"react-dom": "^18.2.0" "react-dom": "^18.2.0"
}, },
"devDependencies": { "devDependencies": {
"@types/react": "^18.0.26", "@types/react": "^18.2.48",
"@types/react-dom": "^18.0.9", "@types/react-dom": "^18.2.18",
"@vitejs/plugin-react": "^3.0.0", "@vitejs/plugin-react": "^4.2.1",
"typescript": "^4.9.3", "typescript": "^5.3.3",
"vite": "^4.0.0" "vite": "^5.0.11"
} }
} }