Skip to content

Commit

Permalink
fix: migrate create-app and create-theme to ESM, close #1166
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Oct 28, 2023
1 parent 34b57ce commit c620d3a
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 22 deletions.
23 changes: 14 additions & 9 deletions packages/create-app/index.js → packages/create-app/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@
/* eslint-disable no-console */

// @ts-check
const process = require('node:process')
const fs = require('node:fs')
const path = require('node:path')
const argv = require('minimist')(process.argv.slice(2))
const prompts = require('prompts')
const execa = require('execa')
const { cyan, blue, yellow, bold, dim, green } = require('kolorist')
const { version } = require('./package.json')

import process from 'node:process'
import fs from 'node:fs'
import path from 'node:path'
import { createRequire } from 'node:module'
import { fileURLToPath } from 'node:url'
import minimist from 'minimist'
import prompts from 'prompts'
import { execa } from 'execa'
import { blue, bold, cyan, dim, green, yellow } from 'kolorist'

const argv = minimist(process.argv.slice(2))
const cwd = process.cwd()
const require = createRequire(import.meta.url)
const __dirname = fileURLToPath(new URL('.', import.meta.url))
const { version } = require('./package.json')

const renameFiles = {
_gitignore: '.gitignore',
Expand Down
5 changes: 3 additions & 2 deletions packages/create-app/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "create-slidev",
"type": "module",
"version": "0.43.11",
"description": "Create starter template for Slidev",
"author": "antfu <[email protected]>",
Expand All @@ -11,9 +12,9 @@
"url": "https://github.com/slidevjs/slidev"
},
"bugs": "https://github.com/slidevjs/slidev/issues",
"main": "index.js",
"main": "index.mjs",
"bin": {
"create-slidev": "index.js"
"create-slidev": "index.mjs"
},
"engines": {
"node": ">=18.0.0"
Expand Down
21 changes: 13 additions & 8 deletions packages/create-theme/index.js → packages/create-theme/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@
/* eslint-disable no-console */

// @ts-check
const process = require('node:process')
const fs = require('node:fs')
const path = require('node:path')
const argv = require('minimist')(process.argv.slice(2))
const prompts = require('prompts')
const { cyan, blue, yellow, bold, dim, green } = require('kolorist')
const { version } = require('./package.json')

import process from 'node:process'
import fs from 'node:fs'
import path from 'node:path'
import { createRequire } from 'node:module'
import { fileURLToPath } from 'node:url'
import minimist from 'minimist'
import prompts from 'prompts'
import { blue, bold, cyan, dim, green, yellow } from 'kolorist'

const argv = minimist(process.argv.slice(2))
const cwd = process.cwd()
const require = createRequire(import.meta.url)
const __dirname = fileURLToPath(new URL('.', import.meta.url))
const { version } = require('./package.json')

const renameFiles = {
_gitignore: '.gitignore',
Expand Down
5 changes: 3 additions & 2 deletions packages/create-theme/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "create-slidev-theme",
"type": "module",
"version": "0.43.11",
"description": "Create starter theme template for Slidev",
"author": "antfu <[email protected]>",
Expand All @@ -11,9 +12,9 @@
"url": "https://github.com/slidevjs/slidev"
},
"bugs": "https://github.com/slidevjs/slidev/issues",
"main": "index.js",
"main": "index.mjs",
"bin": {
"create-slidev-theme": "index.js"
"create-slidev-theme": "index.mjs"
},
"engines": {
"node": ">=18.0.0"
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es2020",
"target": "es2022",
"jsx": "preserve",
"lib": ["DOM", "ESNext"],
"baseUrl": ".",
Expand Down

0 comments on commit c620d3a

Please sign in to comment.