Skip to content

Commit

Permalink
fix: resolved the package entry path error
Browse files Browse the repository at this point in the history
  • Loading branch information
anlyyao committed Jul 16, 2024
1 parent c30a1ce commit 921a9e6
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 23 deletions.
13 changes: 4 additions & 9 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
{
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
],
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
"editor.formatOnSave": true,
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
Expand All @@ -22,9 +17,9 @@
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[markdown]": {
"editor.formatOnSave": false,
"editor.formatOnSave": false
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
}
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"build:tsc": "concurrently \"npm:build:tsc-*\"",
"build:tsc-es": "tsc --emitDeclarationOnly -d --outDir es/",
"build:tsc-esm": "tsc --emitDeclarationOnly -d --outDir esm/",
"build:tsc-lib": "tsc --emitDeclarationOnly -d --outDir lib/"
"build:tsc-lib": "tsc --emitDeclarationOnly -d --outDir lib/",
"build:tsc-cjs": "tsc --emitDeclarationOnly -d --outDir cjs/"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/"
Expand Down
29 changes: 26 additions & 3 deletions script/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,28 @@ const esmConfig = {
},
};

/** @type {import('rollup').RollupOptions} */
// 按需加载组件 不带 css 样式
const libConfig = {
input: inputList.concat('!src/index-lib.ts'),
external: externalDeps.concat(externalPeerDeps),
plugins: [multiInput()].concat(getPlugins({ extractMultiCss: true })),
output: {
banner,
dir: 'lib/',
format: 'esm',
sourcemap: true,
chunkFileNames: '_chunks/dep-[hash].js',
},
};

// commonjs 导出规范,不带 css 样式
const cjsConfig = {
input: inputList,
external: externalDeps.concat(externalPeerDeps),
plugins: [multiInput()].concat(getPlugins()),
output: {
banner,
dir: 'lib/',
dir: 'cjs/',
format: 'cjs',
sourcemap: true,
exports: 'named',
Expand Down Expand Up @@ -227,4 +241,13 @@ const umdMinConfig = {
},
};

export default [cssConfig, libConfig, esConfig, esmConfig, umdConfig, umdMinConfig];
// 单独导出 reset.css 到 dist 目录,兼容旧版本样式
const resetCss = {
input: 'src/_common/style/mobile/_reset.less',
output: {
file: 'dist/reset.css',
},
plugins: [postcss({ extract: true })],
};

export default [cssConfig, esConfig, esmConfig, libConfig, cjsConfig, umdConfig, umdMinConfig, resetCss];
15 changes: 5 additions & 10 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
"outDir": "lib",
"declaration": true,
"sourceMap": true,
"lib": [
"esnext",
"dom"
],
"lib": ["esnext", "dom"],
"importHelpers": true,
"allowSyntheticDefaultImports": true,
"suppressImplicitAnyIndexErrors": true,
Expand All @@ -20,26 +17,24 @@
"tdesign-mobile-react": ["src"],
"tdesign-mobile-react/*": ["src/*"],
"@test/utils": ["test/utils"],
"@common/*": ["src/_common/*"],
"@common/*": ["src/_common/*"]
},
"allowJs": true,
"checkJs": true,
"downlevelIteration": true,
"esModuleInterop": true
},
"include": [
"./src",
"./global.d.ts"
],
"include": ["./src", "./global.d.ts"],
"exclude": [
"**/**/__tests__/*",
"**/**/_example/*",
"node_modules",
"src/_common",
"dist",
"lib",
"cjs",
"esm",
"es"
],
"compileOnSave": false
}
}

0 comments on commit 921a9e6

Please sign in to comment.