Skip to content

Commit

Permalink
refactor(next/telemetry): use basename for the absolute plugin path
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed Jul 9, 2022
1 parent 5155a88 commit 4c7d16f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/next/telemetry/events/swc-plugins.ts
@@ -1,4 +1,6 @@
import { existsSync } from 'fs'
import findUp from 'next/dist/compiled/find-up'
import path from 'path'
import type { NextConfig } from '../../server/config-shared'

const EVENT_SWC_PLUGIN_PRESENT = 'NEXT_SWC_PLUGIN_DETECTED'
Expand Down Expand Up @@ -30,11 +32,15 @@ export async function eventSwcPlugins(
(events: SwcPluginsEvent[], plugin: string): SwcPluginsEvent[] => {
// swc plugins can be non-npm pkgs with absolute path doesn't have version
const version = deps[plugin] ?? undefined
let pluginName = plugin
if (!version && existsSync(pluginName)) {
pluginName = path.basename(plugin, '.wasm')
}

events.push({
eventName: EVENT_SWC_PLUGIN_PRESENT,
payload: {
packageName: plugin,
packageName: pluginName,
packageVersion: version,
},
})
Expand Down

0 comments on commit 4c7d16f

Please sign in to comment.