@stylable/module-utils
Advanced tools
Comparing version 5.10.0 to 5.11.0
@@ -38,2 +38,3 @@ import type { StylableExports } from '@stylable/core/dist/index-internal'; | ||
from: string; | ||
defaultImport?: string; | ||
}>; | ||
@@ -40,0 +41,0 @@ /** |
@@ -36,4 +36,9 @@ "use strict"; | ||
function moduleRequest(moduleType) { | ||
return (moduleRequest) => { | ||
const request = JSON.stringify(moduleRequest.from); | ||
return ({ from, defaultImport }) => { | ||
const request = JSON.stringify(from); | ||
if (defaultImport) { | ||
return moduleType === 'esm' | ||
? `import ${defaultImport} from ${request};` | ||
: `const ${defaultImport} = require(${request});`; | ||
} | ||
return moduleType === 'esm' ? `import ${request};` : `require(${request});`; | ||
@@ -40,0 +45,0 @@ }; |
{ | ||
"name": "@stylable/module-utils", | ||
"version": "5.10.0", | ||
"version": "5.11.0", | ||
"description": "Stylable module creation utilities", | ||
@@ -10,3 +10,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@stylable/core": "^5.10.0", | ||
"@stylable/core": "^5.11.0", | ||
"@tokey/core": "^1.3.0", | ||
@@ -13,0 +13,0 @@ "vlq": "^2.0.4" |
@@ -38,3 +38,3 @@ import type { StylableExports } from '@stylable/core/dist/index-internal'; | ||
*/ | ||
imports?: Array<{ from: string }>; | ||
imports?: Array<{ from: string; defaultImport?: string }>; | ||
/** | ||
@@ -111,4 +111,9 @@ * Stylable transforms exports | ||
function moduleRequest(moduleType: 'esm' | 'cjs') { | ||
return (moduleRequest: { from: string }) => { | ||
const request = JSON.stringify(moduleRequest.from); | ||
return ({ from, defaultImport }: { from: string; defaultImport?: string }) => { | ||
const request = JSON.stringify(from); | ||
if (defaultImport) { | ||
return moduleType === 'esm' | ||
? `import ${defaultImport} from ${request};` | ||
: `const ${defaultImport} = require(${request});`; | ||
} | ||
return moduleType === 'esm' ? `import ${request};` : `require(${request});`; | ||
@@ -115,0 +120,0 @@ }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
110780
2000
Updated@stylable/core@^5.11.0