misc: convert all internal scripts to ESM (#6286)

* misc: convert all internal scripts to ESM

* fixes

* fix

* fixes

* fix!

* complete eslint

* more move

* fix!

* This looks better?

* Final ones
This commit is contained in:
Joshua Chen 2022-01-08 12:59:28 +08:00 committed by GitHub
parent bcc05e243f
commit 4fad1ce0cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
66 changed files with 412 additions and 374 deletions

View file

@ -1,4 +1,4 @@
copyUntypedFiles.js
copyUntypedFiles.mjs
.tsbuildinfo
tsconfig*
__tests__

View file

@ -5,15 +5,15 @@
* LICENSE file in the root directory of this source tree.
*/
const path = require('path');
const fs = require('fs-extra');
import fs from 'fs-extra';
import {fileURLToPath} from 'url';
/**
* Copy all untyped and static assets files to lib.
*/
const srcDir = path.resolve(__dirname, 'src');
const libDir = path.resolve(__dirname, 'lib');
fs.copySync(srcDir, libDir, {
const srcDir = fileURLToPath(new URL('src', import.meta.url));
const libDir = fileURLToPath(new URL('lib', import.meta.url));
await fs.copy(srcDir, libDir, {
filter(filepath) {
return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath);
},

View file

@ -5,8 +5,8 @@
"main": "lib/index.js",
"types": "src/plugin-debug.d.ts",
"scripts": {
"build": "tsc && node copyUntypedFiles.js",
"watch": "node copyUntypedFiles.js && tsc --watch"
"build": "tsc && node copyUntypedFiles.mjs",
"watch": "node copyUntypedFiles.mjs && tsc --watch"
},
"publishConfig": {
"access": "public"