-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from dulnan/feature/vite-support
Rework using siroc and vite compatibility
- Loading branch information
Showing
19 changed files
with
26,205 additions
and
5,865 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
lib | ||
dist | ||
node_modules | ||
temp | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }), | ||
} | ||
} | ||
}, | ||
} | ||
} |
Oops, something went wrong.