Upgrade to version 11.0.1 #1

Merged
steve merged 60 commits from v11.0.1 into main 2025-10-30 22:14:46 +00:00
Showing only changes of commit 6012bf1886 - Show all commits

View File

@@ -22,7 +22,10 @@ export function wordpressPlugin() {
function extractNamedImports(imports) { function extractNamedImports(imports) {
const match = imports.match(/{([^}]+)}/) const match = imports.match(/{([^}]+)}/)
if (!match) return [] if (!match) return []
return match[1].split(',').map((s) => s.trim()) return match[1]
.split(',')
.map((s) => s.trim())
.filter((s) => s !== '')
} }
function handleNamedReplacement(namedImports, external) { function handleNamedReplacement(namedImports, external) {
@@ -85,17 +88,19 @@ export function wordpressPlugin() {
} }
}, },
transform(code, id) { transform(code, id) {
if ((!id.endsWith('.js')) && !id.endsWith('.jsx')) return if ((!id.endsWith('.js')) && !id.endsWith('.jsx') && !id.endsWith('.ts') && !id.endsWith('.tsx')) return
const imports = [ const imports = [
...(code.match(/^import .+ from ['"]@wordpress\/[^'"]+['"]/gm) || []), ...(code.match(/^import[\s\n]+(?:[^;]+?)[\s\n]+from[\s\n]+['"]@wordpress\/[^'"]+['"]/gm) || []),
...(code.match(/^import ['"]@wordpress\/[^'"]+['"]/gm) || []), ...(code.match(/^import[\s\n]+['"]@wordpress\/[^'"]+['"]/gm) || []),
] ]
imports.forEach((statement) => { imports.forEach((statement) => {
const match = const match =
statement.match(/^import (.+) from ['"]@wordpress\/([^'"]+)['"]/) || statement
statement.match(/^import ['"]@wordpress\/([^'"]+)['"]/) .replace(/[\s\n]+/g, ' ')
.match(/^import (.+) from ['"]@wordpress\/([^'"]+)['"]/) ||
statement.match(/^import ['"]@wordpress\/([^'"]+)['"]/);
if (!match) return if (!match) return