Skip to content

Commit

Permalink
Merge pull request #2 from dulnan/feature/vite-support
Browse files Browse the repository at this point in the history
Rework using siroc and vite compatibility
  • Loading branch information
dulnan authored Oct 8, 2021
2 parents 32e9239 + a4c9717 commit 92b902e
Show file tree
Hide file tree
Showing 19 changed files with 26,205 additions and 5,865 deletions.
12 changes: 0 additions & 12 deletions .eslintrc

This file was deleted.

4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: ['@nuxtjs', '@nuxtjs/eslint-config-typescript', 'prettier'],
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
lib
dist
node_modules
temp
.idea
41 changes: 41 additions & 0 deletions build-plugins/conditional-fsevents-import.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import MagicString from 'magic-string'
import { Plugin } from 'rollup'

const FSEVENTS_REQUIRE = "require('fsevents')"
const REPLACEMENT =
"require('../../../src/watch/fsevents-importer').getFsEvents()"

export default function conditionalFsEventsImport(): Plugin {
let transformed = false
return {
buildEnd(error) {
if (!(error || transformed)) {
throw new Error(
'Could not find "fsevents-handler.js", was the file renamed?'
)
}
},
name: 'conditional-fs-events-import',
transform(code, id) {
if (id.endsWith('fsevents-handler.js')) {
transformed = true
const requireStatementPos = code.indexOf(FSEVENTS_REQUIRE)
if (requireStatementPos < 0) {
throw new Error(
`Could not find expected fsevents import "${FSEVENTS_REQUIRE}"`
)
}
const magicString = new MagicString(code)
magicString.overwrite(
requireStatementPos,
requireStatementPos + FSEVENTS_REQUIRE.length,
REPLACEMENT
)
return {
code: magicString.toString(),
map: magicString.generateMap({ hires: true }),
}
}
},
}
}
Loading

0 comments on commit 92b902e

Please sign in to comment.