Skip to content

Commit

Permalink
refactor: avoid [require-resolve-not-external] warning
Browse files Browse the repository at this point in the history
  • Loading branch information
zqianem committed Aug 18, 2022
1 parent 9c7aad4 commit c680387
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions playground/transform-plugin/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
const { normalizePath } = require('vite')
const { resolve } = require('path')

let transformCount = 1

const transformPlugin = {
name: 'transform',
transform(code, id) {
if (id === normalizePath(require.resolve('./index.js'))) {
if (id === normalizePath(resolve(__dirname, 'index.js'))) {
// Ensure `index.js` is reevaluated if 'plugin-dep.js' is changed
this.addWatchFile(require.resolve('./plugin-dep.js'))
this.addWatchFile('./plugin-dep.js')

return `
// Inject TRANSFORM_COUNT
Expand Down

0 comments on commit c680387

Please sign in to comment.