@rollup/pluginutils
Advanced tools
+19
-4
@@ -306,2 +306,6 @@ 'use strict'; | ||
| } | ||
| // Matches the ECMAScript `IdentifierName` grammar, which (unlike a binding | ||
| // identifier) also accepts reserved words such as `switch`/`await`. Such names | ||
| // can be re-exported with the `export { _x as switch }` form, valid since ES2015. | ||
| const identifierNameRE = /^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u; | ||
| const dataToEsm = function dataToEsm(data, options = {}) { | ||
@@ -344,6 +348,17 @@ var _a, _b; | ||
| defaultExportRows.push(`${stringify(key)}:${_}${serialize(value, options.compact ? null : t, '')}`); | ||
| if (options.includeArbitraryNames && isWellFormedString(key)) { | ||
| const variableName = `${arbitraryNamePrefix}${arbitraryNameExportRows.length}`; | ||
| namedExportCode += `${declarationType} ${variableName}${_}=${_}${serialize(value, options.compact ? null : t, '')};${n}`; | ||
| arbitraryNameExportRows.push(`${variableName} as ${JSON.stringify(key)}`); | ||
| // A `default` key is exposed only through the default export object: a | ||
| // `... as default` re-export would clash with the trailing `export default` | ||
| // and produce a duplicate default export (a SyntaxError). | ||
| if (key !== 'default') { | ||
| // A valid `IdentifierName` that is not a legal binding identifier (a | ||
| // reserved word or global, e.g. `switch`, `await`) is re-exported with the | ||
| // unquoted `export { _x as switch }` form, valid since ES2015. Any other | ||
| // key needs the quoted arbitrary-namespace form (ES2022+), which remains | ||
| // opt-in via `includeArbitraryNames`. | ||
| const isIdentifierName = identifierNameRE.test(key); | ||
| if (isIdentifierName || (options.includeArbitraryNames && isWellFormedString(key))) { | ||
| const variableName = `${arbitraryNamePrefix}${arbitraryNameExportRows.length}`; | ||
| namedExportCode += `${declarationType} ${variableName}${_}=${_}${serialize(value, options.compact ? null : t, '')};${n}`; | ||
| arbitraryNameExportRows.push(`${variableName} as ${isIdentifierName ? key : JSON.stringify(key)}`); | ||
| } | ||
| } | ||
@@ -350,0 +365,0 @@ } |
+19
-4
@@ -306,2 +306,6 @@ 'use strict'; | ||
| } | ||
| // Matches the ECMAScript `IdentifierName` grammar, which (unlike a binding | ||
| // identifier) also accepts reserved words such as `switch`/`await`. Such names | ||
| // can be re-exported with the `export { _x as switch }` form, valid since ES2015. | ||
| const identifierNameRE = /^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u; | ||
| const dataToEsm = function dataToEsm(data, options = {}) { | ||
@@ -344,6 +348,17 @@ var _a, _b; | ||
| defaultExportRows.push(`${stringify(key)}:${_}${serialize(value, options.compact ? null : t, '')}`); | ||
| if (options.includeArbitraryNames && isWellFormedString(key)) { | ||
| const variableName = `${arbitraryNamePrefix}${arbitraryNameExportRows.length}`; | ||
| namedExportCode += `${declarationType} ${variableName}${_}=${_}${serialize(value, options.compact ? null : t, '')};${n}`; | ||
| arbitraryNameExportRows.push(`${variableName} as ${JSON.stringify(key)}`); | ||
| // A `default` key is exposed only through the default export object: a | ||
| // `... as default` re-export would clash with the trailing `export default` | ||
| // and produce a duplicate default export (a SyntaxError). | ||
| if (key !== 'default') { | ||
| // A valid `IdentifierName` that is not a legal binding identifier (a | ||
| // reserved word or global, e.g. `switch`, `await`) is re-exported with the | ||
| // unquoted `export { _x as switch }` form, valid since ES2015. Any other | ||
| // key needs the quoted arbitrary-namespace form (ES2022+), which remains | ||
| // opt-in via `includeArbitraryNames`. | ||
| const isIdentifierName = identifierNameRE.test(key); | ||
| if (isIdentifierName || (options.includeArbitraryNames && isWellFormedString(key))) { | ||
| const variableName = `${arbitraryNamePrefix}${arbitraryNameExportRows.length}`; | ||
| namedExportCode += `${declarationType} ${variableName}${_}=${_}${serialize(value, options.compact ? null : t, '')};${n}`; | ||
| arbitraryNameExportRows.push(`${variableName} as ${isIdentifierName ? key : JSON.stringify(key)}`); | ||
| } | ||
| } | ||
@@ -350,0 +365,0 @@ } |
+19
-4
@@ -302,2 +302,6 @@ import { extname, win32, posix, isAbsolute, resolve } from 'path'; | ||
| } | ||
| // Matches the ECMAScript `IdentifierName` grammar, which (unlike a binding | ||
| // identifier) also accepts reserved words such as `switch`/`await`. Such names | ||
| // can be re-exported with the `export { _x as switch }` form, valid since ES2015. | ||
| const identifierNameRE = /^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u; | ||
| const dataToEsm = function dataToEsm(data, options = {}) { | ||
@@ -340,6 +344,17 @@ var _a, _b; | ||
| defaultExportRows.push(`${stringify(key)}:${_}${serialize(value, options.compact ? null : t, '')}`); | ||
| if (options.includeArbitraryNames && isWellFormedString(key)) { | ||
| const variableName = `${arbitraryNamePrefix}${arbitraryNameExportRows.length}`; | ||
| namedExportCode += `${declarationType} ${variableName}${_}=${_}${serialize(value, options.compact ? null : t, '')};${n}`; | ||
| arbitraryNameExportRows.push(`${variableName} as ${JSON.stringify(key)}`); | ||
| // A `default` key is exposed only through the default export object: a | ||
| // `... as default` re-export would clash with the trailing `export default` | ||
| // and produce a duplicate default export (a SyntaxError). | ||
| if (key !== 'default') { | ||
| // A valid `IdentifierName` that is not a legal binding identifier (a | ||
| // reserved word or global, e.g. `switch`, `await`) is re-exported with the | ||
| // unquoted `export { _x as switch }` form, valid since ES2015. Any other | ||
| // key needs the quoted arbitrary-namespace form (ES2022+), which remains | ||
| // opt-in via `includeArbitraryNames`. | ||
| const isIdentifierName = identifierNameRE.test(key); | ||
| if (isIdentifierName || (options.includeArbitraryNames && isWellFormedString(key))) { | ||
| const variableName = `${arbitraryNamePrefix}${arbitraryNameExportRows.length}`; | ||
| namedExportCode += `${declarationType} ${variableName}${_}=${_}${serialize(value, options.compact ? null : t, '')};${n}`; | ||
| arbitraryNameExportRows.push(`${variableName} as ${isIdentifierName ? key : JSON.stringify(key)}`); | ||
| } | ||
| } | ||
@@ -346,0 +361,0 @@ } |
+3
-18
| { | ||
| "name": "@rollup/pluginutils", | ||
| "version": "5.3.0", | ||
| "version": "5.4.0", | ||
| "publishConfig": { | ||
@@ -65,17 +65,2 @@ "access": "public" | ||
| "types": "./types/index.d.ts", | ||
| "ava": { | ||
| "extensions": [ | ||
| "ts" | ||
| ], | ||
| "require": [ | ||
| "ts-node/register" | ||
| ], | ||
| "workerThreads": false, | ||
| "files": [ | ||
| "!**/fixtures/**", | ||
| "!**/helpers/**", | ||
| "!**/recipes/**", | ||
| "!**/types.ts" | ||
| ] | ||
| }, | ||
| "nyc": { | ||
@@ -92,3 +77,3 @@ "extension": [ | ||
| "ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}", | ||
| "ci:test": "pnpm test -- --verbose", | ||
| "ci:test": "pnpm test -- --reporter=verbose", | ||
| "prebuild": "del-cli dist", | ||
@@ -98,5 +83,5 @@ "prerelease": "pnpm build", | ||
| "release": "pnpm --workspace-root package:release $(pwd)", | ||
| "test": "ava", | ||
| "test": "vitest --config ../../.config/vitest.config.mts run", | ||
| "test:ts": "tsc --noEmit" | ||
| } | ||
| } |
66345
5.23%1330
3.5%