Skip to content

Commit

Permalink
chore: 修复构建中的错误报错,发布 2.0.0-alpha.0
Browse files Browse the repository at this point in the history
  • Loading branch information
oasis-cloud committed Apr 19, 2023
1 parent 57dde10 commit d86dd87
Show file tree
Hide file tree
Showing 18 changed files with 121 additions and 51 deletions.
17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nutui/nutui-react-taro",
"version": "1.4.13",
"version": "2.0.0-alpha.0",
"style": "dist/style.css",
"main": "dist/nutui.react.umd.js",
"module": "dist/esm/nutui-react.es.js",
Expand Down Expand Up @@ -32,17 +32,18 @@
"type": "git",
"url": "https://github.com/jdf2e/nutui-react.git"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},

"files": [
"dist",
"README.md",
"package.json",
"LICENSE",
"CHANGELOG.md"
],
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"scripts": {
"add": "node scripts/createComponentMode.js",
"generate:file": "node scripts/generate-nutui.js",
Expand Down Expand Up @@ -79,10 +80,12 @@
"dev:taro:weapp:jmapp": "npm run checked:taro && VITE_APP_PROJECT_ID=jmapp npm run generate:file:taro:pages && cd ./src/sites/mobile-taro && npm run dev:weapp:jmapp",
"replace:taro:types": "node scripts/taro/replace-taro-types-alias.js",
"build:taro": "npm run checked:taro && vite build --config vite.config.build.taro.ts && npm run build:taro:es && npm run build:css && npm run build:loader-style && npm --taro run build:dts && npm run build:locales",
"build:taro:es": "vite build --config vite.config.build.disperse.taro.ts",
"build:taro:es": "npx rollup -c rollup.config.taro.es.js --bundleConfigAsCjs",
"build:taro:jmapp": "npm run checked:taro && vite build --config vite.config.build.taro.ts && npm run build:taro:es && VITE_APP_PROJECT_ID=jmapp npm run build:css && VITE_APP_PROJECT_ID=jmapp npm run build:loader-style && npm --taro run build:dts && npm run build:locales",
"build:taro:weapp": "npm run checked:taro && vite build --config vite.config.build.taro.ts && npm run generate:file:taro:pages && cd ./src/sites/mobile-taro && npm run build:weapp",
"add:taro:config": "node scripts/taro/generate-taro-route.js"
"add:taro:config": "node scripts/taro/generate-taro-route.js",
"prepublishOnly": "node scripts/prepublish.js",
"postpublish": "node scripts/postpublish.js"
},
"lint-staged": {
"*.md": "prettier --write",
Expand Down
50 changes: 50 additions & 0 deletions rollup.config.taro.es.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import commonjs from '@rollup/plugin-commonjs'
import typescript from '@rollup/plugin-typescript'

const path = require('path')
const config = require('./src/config.json')

const entries = {
'nutui-react.es': path.join(
__dirname,
`./src/packages/nutui.taro.react.build.ts`
),
}
const outputEntries = {}

config.nav.map((item) => {
item.packages.forEach((element) => {
const { name, show, type, exportEmpty } = element
if (show || exportEmpty) {
outputEntries[`./${name.toLowerCase()}`] = `./${name}`
entries[name] = path.join(
__dirname,
`./src/packages/${name.toLowerCase()}/index.taro.ts`
)
}
})
})

export default {
input: entries,
external: (id, parent) => {
;/^react/.test(id) ||
/^react-dom/.test(id) ||
/^classnames/.test(id) ||
/^@use-gesture/.test(id) ||
/^@react-spring/.test(id) ||
/^@bem-react/.test(id) ||
(/^@\/packages\/\w+$/.test(id) && !!parent)
},
output: {
format: 'esm',
dir: './dist/esm',
name: '[entryName].js',
paths: (id) => {
return /@\/packages/.test(id)
? `${outputEntries[id.replace('@/packages/', './')]}.js`
: id
},
},
plugins: [commonjs(), typescript()],
}
4 changes: 2 additions & 2 deletions scripts/generate-themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ const path = require('path')
const fs = require('fs-extra')
const glob = require('glob')

let fileStr = `@import '../theme-default.scss';\n@import '../variables.scss';\n@import '../../styles/font/iconfont.css';\n`
let fileStr = `@import '../theme-default.scss';\n@import '../variables.scss';\n`
const projectID = process.env.VITE_APP_PROJECT_ID
if (projectID) {
fileStr = `@import '../theme-default.scss';\n@import '../variables-${projectID}.scss';\n@import '../../styles/font-${projectID}/iconfont.css';\n`
fileStr = `@import '../theme-default.scss';\n@import '../variables-${projectID}.scss';\n`
}
let tasks = []
const componentsScss = glob.sync('./src/packages/**/*.scss')
Expand Down
10 changes: 10 additions & 0 deletions scripts/postpublish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const path = require('path')
const fsExtra = require('fs-extra')

fsExtra.copySync(
path.join(process.cwd(), '.cache/package.json.bk'),
path.join(process.cwd(), 'package.json'),
{ overwrite: true }
)

fsExtra.removeSync(path.join(process.cwd(), '.cache/package.json.bk'))
29 changes: 29 additions & 0 deletions scripts/prepublish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const path = require('path')
const fsExtra = require('fs-extra')
const packageData = require('../package.json')

const cachePath = path.join(process.cwd(), '.cache/')
if (!fsExtra.ensureDirSync(cachePath)) {
fsExtra.mkdirpSync(cachePath)
}

fsExtra.copySync(
path.join(process.cwd(), 'package.json'),
path.join(cachePath, 'package.json.bk'),
{ overwrite: true }
)

if (packageData.name.indexOf('-taro') > -1) {
delete packageData.dependencies['@nutui/icons-react']
} else {
delete packageData.dependencies['@nutui/icons-react-taro']
}

delete packageData.devDependencies
packageData.scripts = {}

packageData.scripts['postpublish'] = 'node scripts/postpublish.js'

fsExtra.writeJsonSync(path.join(process.cwd(), 'package.json'), packageData, {
spaces: 2,
})
15 changes: 0 additions & 15 deletions scripts/taro/postpublish.js

This file was deleted.

16 changes: 0 additions & 16 deletions scripts/taro/prepublish.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/packages/address/address.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React, {
CSSProperties,
} from 'react'
import { Left, Location2, Check, CircleClose } from '@nutui/icons-react-taro'
import Popup from '@/packages/popup'
import Popup from '@/packages/popup/index.taro'
import bem from '@/utils/bem'
import { ExistRender } from './existRender'
import { CustomRender } from './customRender.taro'
Expand Down
2 changes: 1 addition & 1 deletion src/packages/address/customRender.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createSelectorQuery } from '@tarojs/taro'
import { Check } from '@nutui/icons-react-taro'
import bem from '@/utils/bem'
import Elevator from '@/packages/elevator/index.taro'
import { useConfig } from '@/packages/configprovider'
import { useConfig } from '@/packages/configprovider/index.taro'
import { SelectedRegionObj, RegionData, NextListObj } from './type'

interface CustomRegionData {
Expand Down
2 changes: 1 addition & 1 deletion src/packages/address/demo.taro.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react'
import { Heart1, HeartFill, Left, Close } from '@nutui/icons-react'
import { Heart1, HeartFill, Left, Close } from '@nutui/icons-react-taro'
import Taro from '@tarojs/taro'
import { Address, Cell } from '@/packages/nutui.react.taro'
import Header from '@/sites/components/header'
Expand Down
2 changes: 1 addition & 1 deletion src/packages/audio/audio.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import React, {
} from 'react'

import { createInnerAudioContext, InnerAudioContext } from '@tarojs/taro'
import { Service } from '@nutui/icons-react'
import { Service } from '@nutui/icons-react-taro'
import Range from '@/packages/range/index.taro'
import Button from '@/packages/button/index.taro'
import bem from '@/utils/bem'
Expand Down
8 changes: 7 additions & 1 deletion src/packages/configprovider/index.taro.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { ConfigProvider } from './configprovider.taro'
import {
ConfigProvider,
useConfig,
setDefaultConfig,
getDefaultConfig,
} from './configprovider.taro'

export { useConfig, setDefaultConfig, getDefaultConfig }
export default ConfigProvider
2 changes: 1 addition & 1 deletion src/packages/datepicker/datepicker.taro.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { FunctionComponent, useState, useEffect, useRef } from 'react'
import Picker from '@/packages/picker/index.taro'
import { useConfig } from '@/packages/configprovider'
import { useConfig } from '@/packages/configprovider/index.taro'
import { View } from '@tarojs/components'

export interface PickerOption {
Expand Down
2 changes: 1 addition & 1 deletion src/packages/griditem/griditem.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React, {
useContext,
} from 'react'
import classNames from 'classnames'
import { useConfig } from '@/packages/configprovider'
import { useConfig } from '@/packages/configprovider/index.taro'
import GridContext from '../grid/grid.taro.context'
import { BasicComponent } from '@/utils/typings'
import { pxCheck } from '@/utils/px-check'
Expand Down
2 changes: 1 addition & 1 deletion src/packages/pagination/pagination.taro.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { FunctionComponent, useMemo, ReactNode } from 'react'
import classNames from 'classnames'
import { useConfig } from '@/packages/configprovider'
import { useConfig } from '@/packages/configprovider/index.taro'
import { usePropsValue } from '@/utils/use-props-value'
import { BasicComponent, ComponentDefaults } from '@/utils/typings'

Expand Down
2 changes: 1 addition & 1 deletion src/packages/tag/demo.taro.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import Taro from '@tarojs/taro'
import { CircleClose } from '@nutui/icons-react'
import { CircleClose } from '@nutui/icons-react-taro'
import { CellGroup, Cell, Tag } from '@/packages/nutui.react.taro'
import Header from '@/sites/components/header'
import { useTranslate } from '@/sites/assets/locale/taro'
Expand Down
2 changes: 1 addition & 1 deletion src/packages/watermark/watermark.taro.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState, useEffect, FunctionComponent } from 'react'
import { getSystemInfo, createOffscreenCanvas } from '@tarojs/taro'
import classNames from 'classnames'
import { useConfig } from '@/packages/configprovider'
import { useConfig } from '@/packages/configprovider/index.taro'
import bem from '@/utils/bem'

export interface WaterMarkProps {
Expand Down
5 changes: 4 additions & 1 deletion vite.config.build.disperse.taro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { defineConfig } from 'vite'
import reactRefresh from '@vitejs/plugin-react'
import path from 'path'
import config from './src/config.json'
import commonjs from '@rollup/plugin-commonjs'
import typescript from '@rollup/plugin-typescript'

const entries: any = {
'nutui-react.es': path.join(
Expand Down Expand Up @@ -57,8 +59,9 @@ export default defineConfig({
},
dir: path.resolve(__dirname, './dist/esm'),
entryFileNames: '[name].js',
chunkFileNames: '[name].js',
chunkFileNames: '[name]-[hash].js',
},
plugins: [commonjs(), typescript()],
},
emptyOutDir: false,
},
Expand Down

0 comments on commit d86dd87

Please sign in to comment.