From ffd7c85ebc595894ca149806c97a1b93ddeb8189 Mon Sep 17 00:00:00 2001 From: Asuka Minato Date: Sun, 18 Aug 2024 22:21:21 +0900 Subject: [PATCH 1/3] try add Promise --- DOWNLOAD_STATS.md | 1 + create.ts | 3 ++- package.json | 2 ++ packages/data/es-shim-like/src/es6-promise.ts | 3 +++ packages/generated/es6-promise/auto.js | 2 ++ packages/generated/es6-promise/entry.js | 2 ++ .../generated/es6-promise/implementation.js | 2 ++ packages/generated/es6-promise/index.js | 2 ++ packages/generated/es6-promise/package.json | 21 +++++++++++++++++++ packages/generated/es6-promise/polyfill.js | 2 ++ packages/generated/es6-promise/shim.js | 2 ++ packages/tools/cli/src/all-packages.ts | 1 + pnpm-lock.yaml | 7 +++++++ 13 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 packages/data/es-shim-like/src/es6-promise.ts create mode 100644 packages/generated/es6-promise/auto.js create mode 100644 packages/generated/es6-promise/entry.js create mode 100644 packages/generated/es6-promise/implementation.js create mode 100644 packages/generated/es6-promise/index.js create mode 100644 packages/generated/es6-promise/package.json create mode 100644 packages/generated/es6-promise/polyfill.js create mode 100644 packages/generated/es6-promise/shim.js diff --git a/DOWNLOAD_STATS.md b/DOWNLOAD_STATS.md index 43d0a4bf..f6eb5714 100644 --- a/DOWNLOAD_STATS.md +++ b/DOWNLOAD_STATS.md @@ -31,6 +31,7 @@ | `@nolyfill/es-iterator-helpers` | [![npm](https://img.shields.io/npm/dt/@nolyfill/es-iterator-helpers.svg?style=flat-square&logo=npm&logoColor=white&label=total%20downloads&color=333)](https://www.npmjs.com/package/@nolyfill/es-iterator-helpers) | | `@nolyfill/es-set-tostringtag` | [![npm](https://img.shields.io/npm/dt/@nolyfill/es-set-tostringtag.svg?style=flat-square&logo=npm&logoColor=white&label=total%20downloads&color=333)](https://www.npmjs.com/package/@nolyfill/es-set-tostringtag) | | `@nolyfill/es6-object-assign` | [![npm](https://img.shields.io/npm/dt/@nolyfill/es6-object-assign.svg?style=flat-square&logo=npm&logoColor=white&label=total%20downloads&color=333)](https://www.npmjs.com/package/@nolyfill/es6-object-assign) | +| `@nolyfill/es6-promise` | [![npm](https://img.shields.io/npm/dt/@nolyfill/es6-promise.svg?style=flat-square&logo=npm&logoColor=white&label=total%20downloads&color=333)](https://www.npmjs.com/package/@nolyfill/es6-promise) | | `@nolyfill/function-bind` | [![npm](https://img.shields.io/npm/dt/@nolyfill/function-bind.svg?style=flat-square&logo=npm&logoColor=white&label=total%20downloads&color=333)](https://www.npmjs.com/package/@nolyfill/function-bind) | | `@nolyfill/function.prototype.name` | [![npm](https://img.shields.io/npm/dt/@nolyfill/function.prototype.name.svg?style=flat-square&logo=npm&logoColor=white&label=total%20downloads&color=333)](https://www.npmjs.com/package/@nolyfill/function.prototype.name) | | `@nolyfill/get-symbol-description` | [![npm](https://img.shields.io/npm/dt/@nolyfill/get-symbol-description.svg?style=flat-square&logo=npm&logoColor=white&label=total%20downloads&color=333)](https://www.npmjs.com/package/@nolyfill/get-symbol-description) | diff --git a/create.ts b/create.ts index 28658de1..93324baa 100644 --- a/create.ts +++ b/create.ts @@ -88,7 +88,8 @@ const autoGeneratedPackagesList = [ ['promise.allsettled'], ['array.prototype.toreversed'], ['util.promisify', { '@nolyfill/safe-array-concat': 'workspace:*' }, '>=12.4.0'], - ['typedarray.prototype.slice'] + ['typedarray.prototype.slice'], + ['es6-promise'] ] as const; const singleFilePackagesList = [ diff --git a/package.json b/package.json index bd01cf9a..b7bfb538 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,7 @@ "es-iterator-helpers": "workspace:@nolyfill/es-iterator-helpers@*", "es-set-tostringtag": "workspace:@nolyfill/es-set-tostringtag@*", "es6-object-assign": "workspace:@nolyfill/es6-object-assign@*", + "es6-promise": "workspace:@nolyfill/es6-promise@*", "function-bind": "workspace:@nolyfill/function-bind@*", "function.prototype.name": "workspace:@nolyfill/function.prototype.name@*", "get-symbol-description": "workspace:@nolyfill/get-symbol-description@*", @@ -183,6 +184,7 @@ "es-iterator-helpers": "npm:@nolyfill/es-iterator-helpers@^1.0", "es-set-tostringtag": "npm:@nolyfill/es-set-tostringtag@^1.0", "es6-object-assign": "npm:@nolyfill/es6-object-assign@^1.0", + "es6-promise": "npm:@nolyfill/es6-promise@^1.0", "function-bind": "npm:@nolyfill/function-bind@^1.0", "function.prototype.name": "npm:@nolyfill/function.prototype.name@^1.0", "get-symbol-description": "npm:@nolyfill/get-symbol-description@^1.0", diff --git a/packages/data/es-shim-like/src/es6-promise.ts b/packages/data/es-shim-like/src/es6-promise.ts new file mode 100644 index 00000000..64f0871c --- /dev/null +++ b/packages/data/es-shim-like/src/es6-promise.ts @@ -0,0 +1,3 @@ +import { defineEsShim } from '@nolyfill/shared'; + +export default defineEsShim(Promise); diff --git a/packages/generated/es6-promise/auto.js b/packages/generated/es6-promise/auto.js new file mode 100644 index 00000000..318c0bb9 --- /dev/null +++ b/packages/generated/es6-promise/auto.js @@ -0,0 +1,2 @@ +'use strict'; +/* noop */ diff --git a/packages/generated/es6-promise/entry.js b/packages/generated/es6-promise/entry.js new file mode 100644 index 00000000..9425df66 --- /dev/null +++ b/packages/generated/es6-promise/entry.js @@ -0,0 +1,2 @@ +"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return e}});const e=(0,require("@nolyfill/shared").defineEsShim)(Promise); +Object.assign(exports.default, exports); module.exports = exports.default; diff --git a/packages/generated/es6-promise/implementation.js b/packages/generated/es6-promise/implementation.js new file mode 100644 index 00000000..34019673 --- /dev/null +++ b/packages/generated/es6-promise/implementation.js @@ -0,0 +1,2 @@ +'use strict'; +module.exports = require('./entry.js').implementation; diff --git a/packages/generated/es6-promise/index.js b/packages/generated/es6-promise/index.js new file mode 100644 index 00000000..563021d7 --- /dev/null +++ b/packages/generated/es6-promise/index.js @@ -0,0 +1,2 @@ +'use strict'; +module.exports = require('./entry.js').index(); diff --git a/packages/generated/es6-promise/package.json b/packages/generated/es6-promise/package.json new file mode 100644 index 00000000..112f16da --- /dev/null +++ b/packages/generated/es6-promise/package.json @@ -0,0 +1,21 @@ +{ + "name": "@nolyfill/es6-promise", + "version": "1.0.40", + "repository": { + "type": "git", + "url": "https://github.com/SukkaW/nolyfill", + "directory": "packages/generated/es6-promise" + }, + "main": "./index.js", + "license": "MIT", + "files": [ + "*.js" + ], + "scripts": {}, + "dependencies": { + "@nolyfill/shared": "workspace:*" + }, + "engines": { + "node": ">=12.4.0" + } +} diff --git a/packages/generated/es6-promise/polyfill.js b/packages/generated/es6-promise/polyfill.js new file mode 100644 index 00000000..4166abf3 --- /dev/null +++ b/packages/generated/es6-promise/polyfill.js @@ -0,0 +1,2 @@ +'use strict'; +module.exports = require('./entry.js').polyfill; diff --git a/packages/generated/es6-promise/shim.js b/packages/generated/es6-promise/shim.js new file mode 100644 index 00000000..301a98bd --- /dev/null +++ b/packages/generated/es6-promise/shim.js @@ -0,0 +1,2 @@ +'use strict'; +module.exports = require('./entry.js').shim; diff --git a/packages/tools/cli/src/all-packages.ts b/packages/tools/cli/src/all-packages.ts index 00646ece..3ddc4f02 100644 --- a/packages/tools/cli/src/all-packages.ts +++ b/packages/tools/cli/src/all-packages.ts @@ -30,6 +30,7 @@ export const allPackages = [ "es-iterator-helpers", "es-set-tostringtag", "es6-object-assign", + "es6-promise", "function-bind", "function.prototype.name", "get-symbol-description", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 38c45d6d..279b5852 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -33,6 +33,7 @@ overrides: es-iterator-helpers: workspace:@nolyfill/es-iterator-helpers@* es-set-tostringtag: workspace:@nolyfill/es-set-tostringtag@* es6-object-assign: workspace:@nolyfill/es6-object-assign@* + es6-promise: workspace:@nolyfill/es6-promise@* function-bind: workspace:@nolyfill/function-bind@* function.prototype.name: workspace:@nolyfill/function.prototype.name@* get-symbol-description: workspace:@nolyfill/get-symbol-description@* @@ -433,6 +434,12 @@ importers: packages/generated/es6-object-assign: {} + packages/generated/es6-promise: + dependencies: + '@nolyfill/shared': + specifier: workspace:* + version: link:../../tools/shared + packages/generated/function.prototype.name: dependencies: '@nolyfill/shared': From 540785cd526092961be4032921b3644b7e74100b Mon Sep 17 00:00:00 2001 From: Asuka Minato Date: Mon, 21 Oct 2024 03:30:49 +0900 Subject: [PATCH 2/3] manual es6-promise --- README.md | 2 +- create.ts | 6 +++--- packages/data/es-shim-like/src/es6-promise.ts | 3 --- packages/manual/es6-promise/auto.js | 0 packages/manual/es6-promise/index.js | 4 ++++ 5 files changed, 8 insertions(+), 7 deletions(-) delete mode 100644 packages/data/es-shim-like/src/es6-promise.ts create mode 100644 packages/manual/es6-promise/auto.js create mode 100644 packages/manual/es6-promise/index.js diff --git a/README.md b/README.md index 29aecf24..9c217fb0 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Print the help message. ## Development -Add the definition in `packages/data/es-shim-like/src/` or `packages/data/single-file/src/` and `create.ts` , then `npm run codegen`. Notice that rarely used package will not be added, and some packages which are just sub-deps also won't be added. +Add the definition in `packages/data/es-shim-like/src/` or `packages/data/single-file/src/` or `packages/manual` and `create.ts` , then `npm run codegen`. Notice that rarely used package will not be added, and some packages which are just sub-deps also won't be added. ## Contributions diff --git a/create.ts b/create.ts index 64aa9e86..bde897b1 100644 --- a/create.ts +++ b/create.ts @@ -88,8 +88,7 @@ const autoGeneratedPackagesList = [ ['promise.allsettled'], ['array.prototype.toreversed'], ['util.promisify', { '@nolyfill/safe-array-concat': 'workspace:*' }, '>=12.4.0'], - ['typedarray.prototype.slice'], - ['es6-promise'] + ['typedarray.prototype.slice'] ] as const; const singleFilePackagesList = [ @@ -149,7 +148,8 @@ const manualPackagesList = [ 'es-iterator-helpers', // use rollup prebundle approach 'assert', // use rollup prebundle approach 'set-function-length', // two entries (index.js, env.js) - 'is-core-module' // bundle + 'is-core-module', // bundle + 'es6-promise' // two entries (index.js, auto.js) ] as const; const nonNolyfillPackagesList = [ diff --git a/packages/data/es-shim-like/src/es6-promise.ts b/packages/data/es-shim-like/src/es6-promise.ts deleted file mode 100644 index 64f0871c..00000000 --- a/packages/data/es-shim-like/src/es6-promise.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { defineEsShim } from '@nolyfill/shared'; - -export default defineEsShim(Promise); diff --git a/packages/manual/es6-promise/auto.js b/packages/manual/es6-promise/auto.js new file mode 100644 index 00000000..e69de29b diff --git a/packages/manual/es6-promise/index.js b/packages/manual/es6-promise/index.js new file mode 100644 index 00000000..f2ecc219 --- /dev/null +++ b/packages/manual/es6-promise/index.js @@ -0,0 +1,4 @@ +module.exports = { + polyfill() { }, + Promise +}; From c8138ba3eda9844a0075db3af707600627dc1b11 Mon Sep 17 00:00:00 2001 From: Asuka Minato Date: Mon, 21 Oct 2024 03:33:08 +0900 Subject: [PATCH 3/3] rm outdated file --- packages/generated/es6-promise/auto.js | 2 -- packages/generated/es6-promise/entry.js | 2 -- .../generated/es6-promise/implementation.js | 2 -- packages/generated/es6-promise/index.js | 2 -- packages/generated/es6-promise/package.json | 21 ------------------- packages/generated/es6-promise/polyfill.js | 2 -- packages/generated/es6-promise/shim.js | 2 -- 7 files changed, 33 deletions(-) delete mode 100644 packages/generated/es6-promise/auto.js delete mode 100644 packages/generated/es6-promise/entry.js delete mode 100644 packages/generated/es6-promise/implementation.js delete mode 100644 packages/generated/es6-promise/index.js delete mode 100644 packages/generated/es6-promise/package.json delete mode 100644 packages/generated/es6-promise/polyfill.js delete mode 100644 packages/generated/es6-promise/shim.js diff --git a/packages/generated/es6-promise/auto.js b/packages/generated/es6-promise/auto.js deleted file mode 100644 index 318c0bb9..00000000 --- a/packages/generated/es6-promise/auto.js +++ /dev/null @@ -1,2 +0,0 @@ -'use strict'; -/* noop */ diff --git a/packages/generated/es6-promise/entry.js b/packages/generated/es6-promise/entry.js deleted file mode 100644 index 9425df66..00000000 --- a/packages/generated/es6-promise/entry.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return e}});const e=(0,require("@nolyfill/shared").defineEsShim)(Promise); -Object.assign(exports.default, exports); module.exports = exports.default; diff --git a/packages/generated/es6-promise/implementation.js b/packages/generated/es6-promise/implementation.js deleted file mode 100644 index 34019673..00000000 --- a/packages/generated/es6-promise/implementation.js +++ /dev/null @@ -1,2 +0,0 @@ -'use strict'; -module.exports = require('./entry.js').implementation; diff --git a/packages/generated/es6-promise/index.js b/packages/generated/es6-promise/index.js deleted file mode 100644 index 563021d7..00000000 --- a/packages/generated/es6-promise/index.js +++ /dev/null @@ -1,2 +0,0 @@ -'use strict'; -module.exports = require('./entry.js').index(); diff --git a/packages/generated/es6-promise/package.json b/packages/generated/es6-promise/package.json deleted file mode 100644 index 112f16da..00000000 --- a/packages/generated/es6-promise/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "@nolyfill/es6-promise", - "version": "1.0.40", - "repository": { - "type": "git", - "url": "https://github.com/SukkaW/nolyfill", - "directory": "packages/generated/es6-promise" - }, - "main": "./index.js", - "license": "MIT", - "files": [ - "*.js" - ], - "scripts": {}, - "dependencies": { - "@nolyfill/shared": "workspace:*" - }, - "engines": { - "node": ">=12.4.0" - } -} diff --git a/packages/generated/es6-promise/polyfill.js b/packages/generated/es6-promise/polyfill.js deleted file mode 100644 index 4166abf3..00000000 --- a/packages/generated/es6-promise/polyfill.js +++ /dev/null @@ -1,2 +0,0 @@ -'use strict'; -module.exports = require('./entry.js').polyfill; diff --git a/packages/generated/es6-promise/shim.js b/packages/generated/es6-promise/shim.js deleted file mode 100644 index 301a98bd..00000000 --- a/packages/generated/es6-promise/shim.js +++ /dev/null @@ -1,2 +0,0 @@ -'use strict'; -module.exports = require('./entry.js').shim;