Skip to content

Commit

Permalink
chore(core): modify bundle mode (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
Timeless0911 authored Jun 5, 2024
1 parent c789ba8 commit 83571b5
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 32 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ node_modules/
.eslintcache

dist/
dist-types/
coverage/
doc_build/
playwright-report/
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"search.exclude": {
"**/.git": true,
"**/dist": true,
"**/dist-types": true,
"**/coverage": true,
"**/compiled": true,
"**/doc_build": true,
Expand Down
1 change: 0 additions & 1 deletion e2e/cases/define/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { expect, test } from 'vitest';
import { globContentJSON } from '#helper';

test.fails('define', async () => {
// @ts-expect-error follow conventional
delete process.env.NODE_ENV;

const rslibConfig = {
Expand Down
2 changes: 1 addition & 1 deletion e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@rslib/core": "workspace:*",
"@rslib/tsconfig": "workspace:*",
"@types/fs-extra": "^11.0.4",
"@types/node": "16.x",
"@types/node": "18.x",
"fast-glob": "^3.3.2",
"fs-extra": "^11.2.0",
"typescript": "^5.4.5"
Expand Down
2 changes: 1 addition & 1 deletion packages/core/bin/rslib.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node
import { runCli } from '../dist/index.js';

async function main() {
const { runCli } = require('../dist/cli');
runCli();
}

Expand Down
18 changes: 16 additions & 2 deletions packages/core/modern.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,25 @@ export default defineConfig({
plugins: [moduleTools()],
buildConfig: [
{
input: ['src'],
buildType: 'bundleless',
format: 'cjs',
target: 'es2020',
buildType: 'bundle',
autoExtension: true,
dts: false,
},
{
format: 'esm',
target: 'es2020',
buildType: 'bundle',
autoExtension: true,
dts: false,
},
{
buildType: 'bundleless',
dts: {
distPath: '../dist-types',
only: true,
},
},
],
});
14 changes: 8 additions & 6 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,24 @@
"directory": "packages/core"
},
"license": "MIT",
"type": "commonjs",
"type": "module",
"exports": {
".": {
"types": "./dist/main.d.ts",
"default": "./dist/main.js"
"types": "./dist-types/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"./package.json": "./package.json"
},
"main": "./dist/main.js",
"types": "./dist/main.d.ts",
"main": "./dist/index.cjs",
"types": "./dist-types/index.d.ts",
"bin": {
"rslib": "./bin/rslib.js"
},
"files": [
"bin",
"dist"
"dist",
"dist-types"
],
"scripts": {
"build": "modern build",
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/main.ts → packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
*/

export { build } from './build';
export { runCli } from './cli';
export type { RslibConfig } from './types';
5 changes: 5 additions & 0 deletions packages/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"extends": "@rslib/tsconfig/base",
"compilerOptions": {
"outDir": "./dist",
"baseUrl": "./",
"rootDir": "src",
"declaration": true,
"declarationDir": "./dist-types",
"module": "ESNext",
"moduleResolution": "Bundler"
},
Expand Down
55 changes: 35 additions & 20 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion scripts/tsconfig/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"jsx": "preserve",
"resolveJsonModule": true,
"moduleResolution": "Bundler",
"useDefineForClassFields": true
"useDefineForClassFields": true,
"noPropertyAccessFromIndexSignature": false
},
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Base"
Expand Down

0 comments on commit 83571b5

Please sign in to comment.