Skip to content

Commit

Permalink
feat(shared): initialize shared package
Browse files Browse the repository at this point in the history
  • Loading branch information
Timeless0911 committed Jun 4, 2024
1 parent c789ba8 commit f397bfb
Show file tree
Hide file tree
Showing 12 changed files with 165 additions and 30 deletions.
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
9 changes: 7 additions & 2 deletions packages/core/bin/rslib.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/usr/bin/env node
import { logger } from '@rslib/shared';
import { runCli } from '../dist/es/cli.js';

async function main() {
const { runCli } = require('../dist/cli');
runCli();
try {
runCli();
} catch (err) {
logger.error(err);
}
}

main();
19 changes: 19 additions & 0 deletions packages/core/modern.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@ export default defineConfig({
format: 'cjs',
autoExtension: true,
target: 'es2020',
outDir: './dist/lib',
dts: false,
},
{
input: ['src'],
buildType: 'bundleless',
format: 'esm',
autoExtension: true,
target: 'es2020',
dts: false,
outDir: './dist/es',
},
{
input: ['src'],
buildType: 'bundleless',
outDir: './dist/types',
dts: {
only: true,
},
},
],
});
13 changes: 8 additions & 5 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@
"directory": "packages/core"
},
"license": "MIT",
"type": "commonjs",
"type": "module",
"exports": {
".": {
"types": "./dist/main.d.ts",
"default": "./dist/main.js"
"types": "./dist/types/main.d.ts",
"import": "./dist/es/main.js",
"require": "./dist/lib/main.cjs"
},
"./package.json": "./package.json"
},
"main": "./dist/main.js",
"types": "./dist/main.d.ts",
"main": "./dist/lib/main.cjs",
"module": "./dist/es/main.js",
"types": "./dist/lib/main.d.ts",
"bin": {
"rslib": "./bin/rslib.js"
},
Expand All @@ -39,6 +41,7 @@
"commander": "^12.0.0"
},
"devDependencies": {
"@rslib/shared": "workspace:*",
"@rslib/tsconfig": "workspace:*",
"typescript": "^5.4.5"
},
Expand Down
6 changes: 6 additions & 0 deletions packages/shared/modern.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { defineConfig, moduleTools } from '@modern-js/module-tools';

export default defineConfig({
plugins: [moduleTools()],
buildPreset: 'npm-library',
});
47 changes: 47 additions & 0 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "@rslib/shared",
"version": "0.0.0",
"description": "The internal shared modules and dependencies of Rslib.",
"homepage": "https://rslib.dev",
"bugs": {
"url": "https://github.com/web-infra-dev/rslib/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/web-infra-dev/rslib",
"directory": "packages/shared"
},
"license": "MIT",
"type": "module",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"import": "./dist/es/index.js",
"require": "./dist/lib/index.js"
}
},
"main": "./dist/lib/index.js",
"module": "./dist/es/index.js",
"types": "./dist/types/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "modern build",
"dev": "modern build --watch"
},
"devDependencies": {
"@rslib/tsconfig": "workspace:*",
"@types/node": "18.x",
"rslog": "^1.2.2",
"typescript": "^5.4.5"
},
"engines": {
"node": ">=16.0.0"
},
"publishConfig": {
"access": "public",
"provenance": true,
"registry": "https://registry.npmjs.org/"
}
}
1 change: 1 addition & 0 deletions packages/shared/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './logger';
6 changes: 6 additions & 0 deletions packages/shared/src/logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { type Logger, logger } from 'rslog';

// TODO: add rslib related logging functions

export { logger };
export type { Logger };
9 changes: 9 additions & 0 deletions packages/shared/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "@rslib/tsconfig/base",
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "Bundler"
},
"include": ["src"],
"exclude": ["**/node_modules"]
}
Loading

0 comments on commit f397bfb

Please sign in to comment.