Skip to content

Commit

Permalink
Import fixes (#1039)
Browse files Browse the repository at this point in the history
* fix packages imports

* imports check scripts

* update packages

* svelte build improvements

* build fix
  • Loading branch information
codecalm authored Mar 12, 2024
1 parent 41b8012 commit ceed535
Show file tree
Hide file tree
Showing 16 changed files with 20,908 additions and 100 deletions.
4 changes: 3 additions & 1 deletion .build/rollup-plugins.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ See the LICENSE file in the root directory of this source tree.`

export const getRollupConfig = (pkg, outputFileName, bundles, globals) => {
return bundles
.map(({ inputs, format, minify, preserveModules, outputDir = 'dist', extension = 'js' }) => {
.map(({ inputs, format, minify, preserveModules, outputDir = 'dist', extension = 'js', exports = 'named' }) => {
return inputs.map(input => ({
input,
plugins: getRollupPlugins(pkg, minify),
Expand All @@ -40,6 +40,8 @@ export const getRollupConfig = (pkg, outputFileName, bundles, globals) => {
format,
sourcemap: true,
preserveModules,
preserveModulesRoot: 'src',
exports,
globals,
},
}))
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ packages/icons*/icons/*
.sass-cache

!/**/.gitkeep
*.tgz
14 changes: 6 additions & 8 deletions packages/icons-preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,22 @@
"url": "git+https://github.com/tabler/tabler-icons.git",
"directory": "packages/icons-preact"
},
"amdName": "tabler-icons-preact",
"main": "dist/cjs/tabler-icons-preact.js",
"main:umd": "dist/umd/tabler-icons-preact.js",
"module": "dist/esm/tabler-icons-preact.mjs",
"unpkg": "dist/umd/tabler-icons-preact.min.js",
"typings": "dist/tabler-icons-preact.d.ts",
"main": "./dist/cjs/tabler-icons-preact.cjs",
"types": "./dist/esm/tabler-icons-preact.d.ts",
"module": "./dist/esm/tabler-icons-preact.mjs",
"sideEffects": false,
"files": [
"dist"
],
"sideEffects": false,
"scripts": {
"build": "pnpm run clean && pnpm run copy:license && pnpm run build:icons && pnpm typecheck && pnpm run build:bundles",
"build:icons": "node build.mjs",
"build:bundles": "rollup -c ./rollup.config.mjs",
"copy:license": "cp ../../LICENSE ./LICENSE",
"clean": "rm -rf dist && find . ! -name '.gitkeep' -path '*/src/icons/*' -exec rm -rf {} +",
"test": "vitest run --typecheck",
"typecheck": "tsc"
"typecheck": "tsc",
"imports-check": "attw $(npm pack)"
},
"dependencies": {
"@tabler/icons": "3.0.0"
Expand Down
14 changes: 4 additions & 10 deletions packages/icons-preact/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,9 @@ const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'))
const outputFileName = 'tabler-icons-preact';
const inputs = ['./src/tabler-icons-preact.ts'];
const bundles = [
{
format: 'umd',
inputs,
minify: true,
},
{
format: 'umd',
inputs,
},
{
format: 'cjs',
extension: 'cjs',
inputs,
},
{
Expand All @@ -32,7 +24,9 @@ export default [
{
input: inputs[0],
output: [{
file: `dist/${outputFileName}.d.ts`, format: "es"
file: `dist/esm/${outputFileName}.d.ts`
}, {
file: `dist/cjs/${outputFileName}.d.cts`
}],
plugins: [dts()],
},
Expand Down
26 changes: 18 additions & 8 deletions packages/icons-react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,22 @@
"directory": "packages/icons-react-native"
},
"type": "module",
"amdName": "tabler-icons-react-native",
"main": "dist/cjs/tabler-icons-react-native.js",
"main:umd": "dist/umd/tabler-icons-react-native.js",
"module": "dist/esm/tabler-icons-react-native.mjs",
"unpkg": "dist/umd/tabler-icons-react-native.min.js",
"typings": "dist/tabler-icons-react-native.d.ts",
"react-native": "dist/esm/tabler-icons-react-native.js",
"main": "./dist/cjs/tabler-icons-react-native.cjs",
"types": "./dist/cjs/tabler-icons-react-native.d.cts",
"module": "./dist/esm/tabler-icons-react-native.mjs",
"react-native": "./dist/esm/tabler-icons-react-native.mjs",
"exports": {
".": {
"require": {
"types": "./dist/cjs/tabler-icons-react-native.d.cts",
"default": "./dist/cjs/tabler-icons-react-native.cjs"
},
"import": {
"types": "./dist/esm/tabler-icons-react-native.d.ts",
"default": "./dist/esm/tabler-icons-react-native.cjs"
}
}
},
"sideEffects": false,
"files": [
"dist"
Expand All @@ -35,7 +44,8 @@
"build:bundles": "rollup -c ./rollup.config.mjs",
"copy:license": "cp ../../LICENSE ./LICENSE",
"clean": "rm -rf dist && find . ! -name '.gitkeep' -path '*/src/icons/*' -exec rm -rf {} +",
"typecheck": "tsc"
"typecheck": "tsc",
"imports-check": "attw $(npm pack)"
},
"dependencies": {
"@tabler/icons": "3.0.0"
Expand Down
5 changes: 4 additions & 1 deletion packages/icons-react-native/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const bundles = [
{
format: 'cjs',
inputs,
extension: 'cjs',
},
{
format: 'esm',
Expand All @@ -23,7 +24,9 @@ export default [
{
input: inputs[0],
output: [{
file: `dist/${outputFileName}.d.ts`, format: "es"
file: `dist/esm/${outputFileName}.d.ts`
}, {
file: `dist/cjs/${outputFileName}.d.cts`
}],
plugins: [dts()],
},
Expand Down
14 changes: 6 additions & 8 deletions packages/icons-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@
"url": "git+https://github.com/tabler/tabler-icons.git",
"directory": "packages/icons-react"
},
"type": "module",
"main": "dist/cjs/tabler-icons-react.js",
"main:umd": "dist/umd/tabler-icons-react.js",
"module": "dist/esm/tabler-icons-react.mjs",
"unpkg": "dist/umd/tabler-icons-react.min.js",
"typings": "dist/tabler-icons-react.d.ts",
"main": "./dist/cjs/tabler-icons-react.cjs",
"types": "./dist/esm/tabler-icons-react.d.ts",
"module": "./dist/esm/tabler-icons-react.mjs",
"sideEffects": false,
"files": [
"dist"
Expand All @@ -34,7 +31,8 @@
"copy:license": "cp ../../LICENSE ./LICENSE",
"clean": "rm -rf dist && find . ! -name '.gitkeep' -path '*/src/icons/*' -exec rm -rf {} +",
"test": "vitest run --typecheck",
"typecheck": "tsc"
"typecheck": "tsc",
"imports-check": "attw $(npm pack)"
},
"dependencies": {
"@tabler/icons": "3.0.0"
Expand All @@ -48,6 +46,6 @@
"react-test-renderer": "18.2.0"
},
"peerDependencies": {
"react": "^16.5.1 || ^17.0.0 || ^18.0.0"
"react": ">= 16"
}
}
15 changes: 5 additions & 10 deletions packages/icons-react/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,9 @@ const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'))
const outputFileName = 'tabler-icons-react';
const inputs = ['./src/tabler-icons-react.ts'];
const bundles = [
{
format: 'umd',
inputs,
minify: true,
},
{
format: 'umd',
inputs,
},
{
format: 'cjs',
extension: 'cjs',
inputs,
},
{
Expand All @@ -32,10 +24,13 @@ export default [
{
input: inputs[0],
output: [{
file: `dist/${outputFileName}.d.ts`, format: "es"
file: `dist/esm/${outputFileName}.d.ts`, format: 'esm'
}, {
file: `dist/cjs/${outputFileName}.d.cts`, format: 'cjs'
}],
plugins: [dts()],
},

...getRollupConfig(pkg, outputFileName, bundles, {
react: 'react'
})
Expand Down
20 changes: 5 additions & 15 deletions packages/icons-solidjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,21 @@
"url": "git+https://github.com/tabler/tabler-icons.git",
"directory": "packages/icons-solidjs"
},
"source": "src/tabler-icons-solidjs.ts",
"main": "dist/cjs/tabler-icons-solidjs.js",
"module": "dist/esm/tabler-icons-solidjs.mjs",
"types": "dist/types/tabler-icons-solidjs.d.ts",
"main": "./dist/cjs/tabler-icons-solidjs.cjs",
"module": "./dist/esm/tabler-icons-solidjs.mjs",
"types": "./dist/cjs/tabler-icons-solidjs.d.cts",
"files": [
"dist"
],
"exports": {
".": {
"types": "./dist/types/tabler-icons-solidjs.d.ts",
"solid": "./dist/source/tabler-icons-solidjs.js",
"import": "./dist/esm/tabler-icons-solidjs.js",
"browser": "./dist/esm/tabler-icons-solidjs.js",
"require": "./dist/cjs/tabler-icons-solidjs.js",
"node": "./dist/cjs/tabler-icons-solidjs.js"
}
},
"scripts": {
"build": "pnpm run clean && pnpm run copy:license && pnpm run build:icons && pnpm typecheck && pnpm run build:bundles",
"build:icons": "node build.mjs",
"build:bundles": "rollup -c ./rollup.config.mjs",
"copy:license": "cp ../../LICENSE ./LICENSE",
"clean": "rm -rf dist && find . ! -name '.gitkeep' -path '*/src/icons/*' -exec rm -rf {} +",
"test": "vitest run",
"typecheck": "tsc"
"typecheck": "tsc",
"imports-check": "attw $(npm pack)"
},
"dependencies": {
"@tabler/icons": "3.0.0"
Expand Down
14 changes: 4 additions & 10 deletions packages/icons-solidjs/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,9 @@ const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'))
const outputFileName = 'tabler-icons-solidjs';
const inputs = ['./src/tabler-icons-solidjs.ts'];
const bundles = [
{
format: 'umd',
inputs,
minify: true,
},
{
format: 'umd',
inputs,
},
{
format: 'cjs',
extension: 'cjs',
inputs,
},
{
Expand All @@ -32,7 +24,9 @@ export default [
{
input: inputs[0],
output: [{
file: `dist/${outputFileName}.d.ts`, format: "es"
file: `dist/esm/${outputFileName}.d.ts`
}, {
file: `dist/cjs/${outputFileName}.d.cts`
}],
plugins: [dts()],
},
Expand Down
32 changes: 32 additions & 0 deletions packages/icons-svelte/build.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
#!/usr/bin/env node

import { buildJsIcons } from '../../.build/build-icons.mjs'
import { readFileSync, writeFileSync } from 'fs'
import { getAllIcons, toPascalCase } from '../../.build/helpers.mjs'

const updatePackageJson = () => {
let packageJson = JSON.parse(readFileSync('package.json', 'utf-8'))

if (packageJson.exports) {
for (const key in packageJson.exports) {
if (key.match(/^\.\/[^\.]+\.svelte$/)) {
delete packageJson.exports[key]
}
}
}

const allIcons = getAllIcons(false, false)

Object.entries(allIcons).forEach(([type, icons]) => {
icons.forEach((icon, i) => {
const iconName = `${icon.name}${type !== 'outline' ? `-${type}` : ''}`,
iconNamePascal = `${icon.namePascal}${type !== 'outline' ? toPascalCase(type) : ''}`

packageJson.exports[`./${iconNamePascal}.svelte`] = {
types: `./dist/icons/${iconName}.svelte.d.ts`,
svelte: `./dist/icons/${iconName}.svelte`
}
})
})

writeFileSync('package.json', JSON.stringify(packageJson, null, 2))
}

const componentTemplate = ({
type,
Expand Down Expand Up @@ -40,3 +70,5 @@ buildJsIcons({
indexFile: 'index.ts',
pascalName: false,
})

updatePackageJson()
Loading

0 comments on commit ceed535

Please sign in to comment.