-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #286 from dcastil/feature/283/add-es5-bundle
Add ES5 bundle
- Loading branch information
Showing
12 changed files
with
1,363 additions
and
4,185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
[ | ||
{ | ||
"path": "dist/tailwind-merge.mjs", | ||
"path": "dist/bundle-mjs.mjs", | ||
"limit": "10 KB" | ||
}, | ||
{ | ||
"path": "dist/tailwind-merge.cjs.production.min.js", | ||
"path": "dist/bundle-cjs.js", | ||
"limit": "10 KB" | ||
}, | ||
{ | ||
"path": "dist/es5/bundle-mjs.mjs", | ||
"limit": "20 KB" | ||
}, | ||
{ | ||
"path": "dist/es5/bundle-cjs.js", | ||
"limit": "20 KB" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
// eslint-disable-next-line import/no-default-export | ||
export default { | ||
rootDir: '..', | ||
preset: 'ts-jest', | ||
testMatch: ['<rootDir>/@(src|tests)/**/?(*.)test.ts'], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
// @ts-check | ||
|
||
import { getBabelOutputPlugin } from '@rollup/plugin-babel' | ||
import { nodeResolve } from '@rollup/plugin-node-resolve' | ||
import typescript from '@rollup/plugin-typescript' | ||
import { defineConfig } from 'rollup' | ||
import del from 'rollup-plugin-delete' | ||
import { dts } from 'rollup-plugin-dts' | ||
|
||
import pkg from '../package.json' assert { type: 'json' } | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default defineConfig([ | ||
// Default entry point | ||
{ | ||
input: pkg.source, | ||
output: [ | ||
getOutputConfig({ | ||
file: pkg.exports['.'].import, | ||
format: 'esm', | ||
targets: 'supports es5', | ||
// To be enabled in https://github.com/dcastil/tailwind-merge/issues/126 | ||
// targets: '> 0.5%, last 2 versions, Firefox ESR, not dead, maintained node versions', | ||
}), | ||
getOutputConfig({ | ||
file: pkg.exports['.'].require, | ||
format: 'cjs', | ||
targets: 'supports es5', | ||
// To be enabled in https://github.com/dcastil/tailwind-merge/issues/126 | ||
// targets: '> 0.5%, last 2 versions, Firefox ESR, not dead, maintained node versions', | ||
}), | ||
], | ||
external: /node_modules/, | ||
plugins: [ | ||
del({ targets: 'dist/*' }), | ||
nodeResolve(), | ||
typescript({ | ||
compilerOptions: { | ||
noEmitOnError: true, | ||
}, | ||
}), | ||
], | ||
}, | ||
|
||
// es5 entry point | ||
{ | ||
input: pkg.source, | ||
output: [ | ||
getOutputConfig({ | ||
file: pkg.exports['./es5'].import, | ||
format: 'esm', | ||
targets: 'supports es5', | ||
}), | ||
getOutputConfig({ | ||
file: pkg.exports['./es5'].require, | ||
format: 'cjs', | ||
targets: 'supports es5', | ||
}), | ||
], | ||
external: /node_modules/, | ||
plugins: [ | ||
nodeResolve(), | ||
typescript({ | ||
compilerOptions: { | ||
noEmitOnError: true, | ||
// We don't want to emit declaration files more than once | ||
declaration: false, | ||
declarationMap: false, | ||
}, | ||
}), | ||
], | ||
}, | ||
|
||
// Type declarations of default and es5 entry points | ||
{ | ||
input: 'dist/types/index.d.ts', | ||
output: { | ||
file: pkg.exports['.'].types, | ||
format: 'esm', | ||
}, | ||
plugins: [ | ||
dts(), | ||
del({ | ||
targets: 'dist/types', | ||
hook: 'buildEnd', | ||
runOnce: true, | ||
}), | ||
], | ||
}, | ||
]) | ||
|
||
/** | ||
* | ||
* @param {{ file: string; format: 'esm' | 'cjs'; targets: string}} param0 | ||
* @returns | ||
*/ | ||
function getOutputConfig({ file, format, targets }) { | ||
/** @satisfies {import('rollup').OutputOptions} */ | ||
const config = { | ||
file, | ||
format, | ||
sourcemap: true, | ||
freeze: false, | ||
generatedCode: 'es2015', | ||
plugins: [ | ||
getBabelOutputPlugin({ | ||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
loose: true, | ||
bugfixes: true, | ||
modules: false, | ||
targets, | ||
}, | ||
], | ||
], | ||
plugins: [ | ||
'babel-plugin-annotate-pure-calls', | ||
['@babel/plugin-transform-runtime', { useESModules: format === 'esm' }], | ||
['babel-plugin-polyfill-regenerator', { method: 'usage-pure' }], | ||
], | ||
}), | ||
], | ||
} | ||
|
||
return config | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.