diff --git a/core/src/index.ts b/core/src/index.ts index 2f602a2..8d88f8a 100644 --- a/core/src/index.ts +++ b/core/src/index.ts @@ -11,7 +11,7 @@ import { overridePaths } from 'kkt/lib/overrides/paths'; import { sync as gzipSize } from 'gzip-size'; import filesize from 'filesize'; import './overrides'; -import { filterPlugins, removeLoaders, solveCjsLoaders, hasTypeModule } from './utils'; +import { filterPlugins, removeLoaders, hasTypeModule } from './utils'; function help() { const { version } = require('../package.json'); @@ -212,7 +212,7 @@ process.on('exit', (code) => { const oPaths = { appBuild: outDir, appIndexJs: inputFile, appPublic: publicFolder }; const isWeb = /^(web|browserslist)$/.test(argvs.target); - const target = isWeb ? argvs.target : argvs.target ? ['node14', argvs.target] : 'node14'; + const target = isWeb ? argvs.target : argvs.target ? ['node16', argvs.target] : 'node16'; fs.ensureDirSync(outDir); overridePaths(undefined, { ...oPaths }); argvs.overridesWebpack = (conf, env, options) => { @@ -221,7 +221,7 @@ process.on('exit', (code) => { if (isWeb) { conf = removeLoaders(conf); } else { - conf = solveCjsLoaders(conf); + conf.module.rules = []; } conf.entry = inputFile; if (argvs.sourceMap) { diff --git a/core/src/utils.ts b/core/src/utils.ts index 7b03de6..4fe85d4 100644 --- a/core/src/utils.ts +++ b/core/src/utils.ts @@ -61,29 +61,6 @@ export function removeLoaders(conf: WebpackConfiguration) { return conf; } -/** Solve cjs issue */ -export function solveCjsLoaders(conf: WebpackConfiguration) { - conf.module.rules = conf.module.rules.map((rule) => { - if (typeof rule === 'object' && rule.oneOf) { - rule.oneOf = rule.oneOf - .map((item) => - item && - item.exclude && - /@babel(?:\/|\\{1,2})runtime/.toString() === item.exclude.toString() && - item.test.toString() === /\.(js|mjs)$/.toString() - ? { - ...item, - test: /\.(js|cjs|mjs)$/, - } - : item, - ) - .filter(Boolean); - } - return rule; - }); - return conf; -} - export function hasTypeModule(path: string) { while (path !== (path = PATH.resolve(path, '..'))) { try { diff --git a/examples/github-action/README.md b/examples/github-action/README.md new file mode 100644 index 0000000..7930bc3 --- /dev/null +++ b/examples/github-action/README.md @@ -0,0 +1,2 @@ +Basic Example for github-actions +=== diff --git a/examples/github-action/package.json b/examples/github-action/package.json new file mode 100644 index 0000000..63481d1 --- /dev/null +++ b/examples/github-action/package.json @@ -0,0 +1,18 @@ +{ + "name": "@template/github-actions", + "version": "1.0.15", + "private": true, + "scripts": { + "build": "npm run bundle && npm run bundle:min", + "bundle": "ncc build src/action.ts", + "watch": "ncc watch src/action.ts", + "bundle:min": "ncc build src/action.ts -m" + }, + "engines": { + "node": ">=16" + }, + "dependencies": { + "@actions/core": "~1.10.0", + "markdown-to-html-cli": "^4.0.0" + } +} diff --git a/examples/github-action/src/action.ts b/examples/github-action/src/action.ts new file mode 100644 index 0000000..90b50c2 --- /dev/null +++ b/examples/github-action/src/action.ts @@ -0,0 +1,13 @@ +import fs from 'fs'; +import path from 'path'; +import { RunArgvs, formatConfig, create } from 'markdown-to-html-cli'; + +(async () => { + try { + const outputPath = path.resolve('output'); + const htmlStr = create({}); + fs.writeFileSync(outputPath, htmlStr); + } catch (error) { + console.log('error::', error); + } +})(); diff --git a/examples/github-action/tsconfig.json b/examples/github-action/tsconfig.json new file mode 100644 index 0000000..a4776c2 --- /dev/null +++ b/examples/github-action/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "esModuleInterop": true, + "declaration": true, + "target": "es2017", + "noImplicitAny": true, + "resolveJsonModule": true, + "moduleResolution": "node", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "sourceMap": false, + "strict": false, + "skipLibCheck": true, + "outDir": "lib", + "allowJs": true, + "baseUrl": "." + }, + "include": ["src/**/*"] +} diff --git a/package.json b/package.json index 9ec4a44..5c975e9 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "-----↓↓↓↓↓↓↓↓↓↓↓↓↓↓-----": "----------", "build:bundle": "lerna exec \"npm run build:bundle\" --scope @template/bundle", "build:bundle:node": "lerna exec \"npm run build\" --scope @template/bundle-node", + "build:bundle:action": "lerna exec \"npm run bundle\" --scope @template/github-actions", "-----↑↑↑↑↑↑↑↑↑↑↑↑↑↑-----": "----------", "watch": "lerna exec \"tsbb watch\" --scope @kkt/ncc", "build": "lerna exec \"tsbb build\" --scope @kkt/ncc",