New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-shopware-vite-meta-glob

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-shopware-vite-meta-glob - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

9

lib/index.js

@@ -75,2 +75,4 @@ "use strict";

const eagerOption = t.isObjectExpression(args[1]) && args[1].properties.filter(p => t.isObjectProperty(p) && t.isIdentifier(p.key) && p.key.name === 'eager');
const importOption = t.isObjectExpression(args[1]) && args[1].properties.filter(p => t.isObjectProperty(p) && t.isIdentifier(p.key) && p.key.name === 'import');
const useImportOption = !!importOption && importOption.length > 0 && t.isObjectProperty(importOption[0]) && t.isStringLiteral(importOption[0].value);
if (!eagerOption || eagerOption.length === 0 || !t.isObjectProperty(eagerOption[0]) || !t.isBooleanLiteral(eagerOption[0].value)) {

@@ -90,3 +92,8 @@ console.warn('Did not transform because eager option is not set');

const imports = globPaths.map((globPath, idx) => {
const modulePath = t.stringLiteral(globPath);
let modulePath = t.stringLiteral(globPath);
if (useImportOption) {
return t.variableDeclaration('const', [t.variableDeclarator(identifiers[idx], t.memberExpression(t.callExpression(t.identifier('require'), [modulePath]),
// @ts-ignore - We know it's a string literal
t.identifier(importOption[0].value.value)))]);
}
return t.variableDeclaration('const', [t.variableDeclarator(identifiers[idx], t.callExpression(t.identifier('require'), [modulePath]))]);

@@ -93,0 +100,0 @@ });

2

package.json
{
"name": "babel-plugin-shopware-vite-meta-glob",
"version": "0.0.1",
"version": "0.0.2",
"homepage": "https://github.com/shopware/babel-plugin-shopware-vite-meta-glob",

@@ -5,0 +5,0 @@ "bugs": {

@@ -24,2 +24,3 @@ # Babel Plugin Shopware Vite Meta Glob

- Supports `{ eager: true }` option for direct module imports
- Supports `{ import: 'default' }` **only in combination with eager: true**
- Handles file path normalization

@@ -34,4 +35,2 @@ - Works with both Windows and Unix-style file paths

eager false will not be transformed
- **Doesn't transform** `import.meta.glob('./dir1/*.js', { import: 'foo' })`
import option will be ignored
- **Doesn't transform** `import.meta.glob('./dir1/*.js', { query: 'foo' })`

@@ -38,0 +37,0 @@ query option will be ignored

@@ -23,2 +23,5 @@ import pluginTester from 'babel-plugin-tester'

),
'should transform glob with eager and import option': withFileName(
'const modules = import.meta.glob("./fixtures/**/*", { eager: true, import: "default" })',
),

@@ -36,3 +39,6 @@ // Negative tests

),
'should not transform glob with import option without eager': withFileName(
'const modules = import.meta.glob("./fixtures/**/*", { import: "default" })',
),
},
})

@@ -104,2 +104,12 @@ import nodePath from 'path'

)
const importOption =
t.isObjectExpression(args[1]) &&
args[1].properties.filter(
p =>
t.isObjectProperty(p) &&
t.isIdentifier(p.key) &&
p.key.name === 'import',
)
const useImportOption = !!importOption && importOption.length > 0 && t.isObjectProperty(importOption[0]) && t.isStringLiteral(importOption[0].value);

@@ -128,3 +138,17 @@ if (

const imports = globPaths.map((globPath, idx) => {
const modulePath = t.stringLiteral(globPath)
let modulePath = t.stringLiteral(globPath)
if (useImportOption) {
return t.variableDeclaration('const', [
t.variableDeclarator(
identifiers[idx],
t.memberExpression(
t.callExpression(t.identifier('require'), [modulePath]),
// @ts-ignore - We know it's a string literal
t.identifier(importOption[0].value.value),
),
),
])
}
return t.variableDeclaration('const', [

@@ -131,0 +155,0 @@ t.variableDeclarator(

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc