Skip to content

Commit

Permalink
feat: migrate to pure esm
Browse files Browse the repository at this point in the history
  • Loading branch information
sanyuan0704 committed Sep 7, 2022
1 parent 6b76055 commit 0e68c86
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion bin/island.js
@@ -1,2 +1,2 @@
#!/usr/bin/env node
import('../dist/node/cli.js');
import('../dist/cli.js');
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"dev:tsup": "tsup src/node/cli.ts --watch --dts --format esm",
"dev": "tsc -w",
Expand Down
6 changes: 2 additions & 4 deletions playground/.island/config.ts
@@ -1,6 +1,4 @@
import { defineConfig } from '../../dist/node/index';

export default defineConfig({
export default {
lang: 'zh-CN',
themeConfig: {
nav: [
Expand All @@ -19,7 +17,7 @@ export default defineConfig({
'/': getArchSidebar()
}
}
});
};

function getArchSidebar() {
return [
Expand Down
4 changes: 2 additions & 2 deletions src/node/constants/index.ts
@@ -1,8 +1,8 @@
import { join } from 'path';

import { fileURLToPath } from 'url';
export const isProduction = () => process.env.NODE_ENV === 'production';

export const PACKAGE_ROOT_PATH = join(import.meta.url, '../../');
export const PACKAGE_ROOT_PATH = join(fileURLToPath(import.meta.url), '../..');

export const CLIENT_PATH = join(PACKAGE_ROOT_PATH, 'src/client/app');

Expand Down
7 changes: 4 additions & 3 deletions tsconfig.json
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"module": "CommonJS",
"target": "esnext",
"module": "ESNext",
"target": "ESNext",
"baseUrl": "src",
"moduleResolution": "node",
"esModuleInterop": true,
Expand All @@ -20,6 +20,7 @@
"**/node_modules/**",
"**/dist/**",
"**/client/**",
"**/playground/**"
"**/playground/**",
"tsup.config.ts"
]
}
11 changes: 11 additions & 0 deletions tsup.config.ts
@@ -0,0 +1,11 @@
import { defineConfig } from 'tsup';

export default defineConfig({
platform: 'node',
format: 'esm',
banner() {
return {
js: `import { createRequire } from 'module';const require = createRequire(import.meta.url);`
};
}
});

0 comments on commit 0e68c86

Please sign in to comment.