mirror of
https://github.com/pmndrs/zustand.git
synced 2025-12-08 19:45:52 +00:00
chore(rollup): migrate commonjs to esmodule (#2946)
* chore(rollup): migrate commonjs to esmodule * chore(package.json): change commonjs to esmodule style in 'patch-d-ts' script
This commit is contained in:
parent
3f9127f4eb
commit
524a7b5d55
@ -71,7 +71,7 @@
|
||||
"test:types": "tsc --noEmit",
|
||||
"test:lint": "eslint .",
|
||||
"test:spec": "vitest run",
|
||||
"patch-d-ts": "node -e \"var {entries}=require('./rollup.config.js');require('shelljs').find('dist/**/*.d.ts').forEach(f=>{entries.forEach(({find,replacement})=>require('shelljs').sed('-i',new RegExp(' from \\''+find.source.slice(0,-1)+'\\';$'),' from \\''+replacement+'\\';',f));require('shelljs').sed('-i',/ from '(\\.[^']+)\\.ts';$/,' from \\'\\$1\\';',f)})\"",
|
||||
"patch-d-ts": "node --input-type=module -e \"import { entries } from './rollup.config.mjs'; import shelljs from 'shelljs'; const { find, sed } = shelljs; find('dist/**/*.d.ts').forEach(f => { entries.forEach(({ find, replacement }) => sed('-i', new RegExp(' from \\'' + find.source.slice(0, -1) + '\\';$'), ' from \\'' + replacement + '\\';', f)); sed('-i', / from '(\\.[^']+)\\.ts';$/, ' from \\'\\$1\\';', f); });\"",
|
||||
"copy": "shx cp -r dist/src/* dist/esm && shx cp -r dist/src/* dist && shx rm -rf dist/src && shx rm -rf dist/{src,tests} && shx cp package.json readme.md LICENSE dist && json -I -f dist/package.json -e \"this.private=false; this.devDependencies=undefined; this.optionalDependencies=undefined; this.scripts=undefined; this.prettier=undefined;\"",
|
||||
"patch-old-ts": "shx touch dist/ts_version_4.5_and_above_is_required.d.ts",
|
||||
"patch-esm-ts": "node -e \"require('shelljs').find('dist/esm/**/*.d.ts').forEach(f=>{var f2=f.replace(/\\.ts$/,'.mts');require('fs').renameSync(f,f2);require('shelljs').sed('-i',/ from '(\\.[^']+)';$/,' from \\'\\$1.mjs\\';',f2);require('shelljs').sed('-i',/^declare module '(\\.[^']+)'/,'declare module \\'\\$1.mjs\\'',f2)})\""
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
/* eslint-disable no-undef */
|
||||
const path = require('path')
|
||||
const alias = require('@rollup/plugin-alias')
|
||||
const resolve = require('@rollup/plugin-node-resolve')
|
||||
const replace = require('@rollup/plugin-replace')
|
||||
const typescript = require('@rollup/plugin-typescript')
|
||||
const { default: esbuild } = require('rollup-plugin-esbuild')
|
||||
/* global process*/
|
||||
import path from 'path'
|
||||
import alias from '@rollup/plugin-alias'
|
||||
import resolve from '@rollup/plugin-node-resolve'
|
||||
import replace from '@rollup/plugin-replace'
|
||||
import typescript from '@rollup/plugin-typescript'
|
||||
import esbuild from 'rollup-plugin-esbuild'
|
||||
|
||||
const extensions = ['.js', '.ts', '.tsx']
|
||||
const { root } = path.parse(process.cwd())
|
||||
const entries = [
|
||||
export const entries = [
|
||||
{ find: /.*\/vanilla\/shallow\.ts$/, replacement: 'zustand/vanilla/shallow' },
|
||||
{ find: /.*\/react\/shallow\.ts$/, replacement: 'zustand/react/shallow' },
|
||||
{ find: /.*\/vanilla\.ts$/, replacement: 'zustand/vanilla' },
|
||||
@ -90,7 +90,7 @@ function createCommonJSConfig(input, output) {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function (args) {
|
||||
export default function (args) {
|
||||
let c = Object.keys(args).find((key) => key.startsWith('config-'))
|
||||
if (c) {
|
||||
c = c.slice('config-'.length).replace(/_/g, '/')
|
||||
@ -103,5 +103,3 @@ module.exports = function (args) {
|
||||
createESMConfig(`src/${c}.ts`, `dist/esm/${c}.mjs`),
|
||||
]
|
||||
}
|
||||
|
||||
module.exports.entries = entries
|
||||
Loading…
x
Reference in New Issue
Block a user