Skip to content

Commit

Permalink
fix: bin file cannot start
Browse files Browse the repository at this point in the history
  • Loading branch information
sanyuan0704 committed Sep 1, 2022
1 parent 3ac15c5 commit c5bdec7
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ module.exports = {
'prettier/prettier': 'error',
quotes: ['error', 'single'],
semi: ['error', 'always'],
'react/react-in-jsx-scope': 'off'
'react/react-in-jsx-scope': 'off',
'@typescript-eslint/no-non-null-assertion': 'off'
},
settings: {
react: {
Expand Down
2 changes: 1 addition & 1 deletion bin/island.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env node
import('../dist/node/cli');
import('../dist/node/cli.js');
5 changes: 2 additions & 3 deletions src/node/config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { join } from 'path';
import { loadConfigFromFile } from 'vite';
import { SiteData, UserConfig } from '../shared/types/types';
import { SiteData } from '../shared/types/types';

export async function resolveConfig(root: string): Promise<SiteData> {
const userConfig = { root };
// const userConfig = { root };
// 1. TODO: 解析用户配置文件
// 2. 与默认配置合并
const siteData: SiteData = {
Expand Down
7 changes: 3 additions & 4 deletions src/node/dev.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { createServer as createViteDevServer } from 'vite';
import { resolveConfig } from './config';
// import { resolveConfig } from './config';
import { createIslandPlugins } from './plugin';

export async function createDevServer(root = process.cwd()) {
const config = await resolveConfig(root);
// const config = await resolveConfig(root);
return createViteDevServer({
root,
base: '/',
plugins: [createIslandPlugins()],
config
plugins: [createIslandPlugins()]
});
}
11 changes: 5 additions & 6 deletions src/node/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Plugin } from 'vite';
import reactPlugin from '@vitejs/plugin-react';
import fs from 'fs-extra';
import mdx from 'vite-plugin-mdx';
import { SiteData } from '../shared/types/types';
import {
CLIENT_ENTRY_PATH,
CLIENT_PATH,
Expand All @@ -11,11 +10,11 @@ import {
THEME_PATH
} from './constants';

function siteDataPlugin(): Plugin {
return {
name: 'internal:site-data'
};
}
// function siteDataPlugin(): Plugin {
// return {
// name: 'internal:site-data'
// };
// }

export function createIslandPlugins() {
const islandPlugin: Plugin = {
Expand Down
2 changes: 1 addition & 1 deletion src/node/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"compilerOptions": {
"target": "ES2022",
"module": "commonjs",
"outDir": "../../dist/node"
"outDir": "../../dist/"
}
}

0 comments on commit c5bdec7

Please sign in to comment.