vite-plugin-iso-import
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -32,7 +32,11 @@ 'use strict'; | ||
}, | ||
async transform(code, id, ssr) { | ||
async transform(code, id, opts) { | ||
// Support breaking change in Vite 2.7 | ||
// The third argument now contains an object with ssr property, instead of just the ssr boolean | ||
const ssr = opts === true || opts?.ssr; | ||
await esModuleLexer.init; | ||
let _s; | ||
const s = () => _s || (_s = new MagicString__default['default'](code)); | ||
const s = () => _s || (_s = new MagicString__default["default"](code)); | ||
const [imports] = esModuleLexer.parse(code); | ||
@@ -164,3 +168,3 @@ | ||
exports['default'] = tsPlugin; | ||
exports["default"] = tsPlugin; | ||
exports.isoImport = isoImport; |
{ | ||
"name": "vite-plugin-iso-import", | ||
"description": "Import modules isomorphically", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"author": "Bjorn Lu", | ||
@@ -39,6 +39,2 @@ "license": "MIT", | ||
"build": "rollup -c", | ||
"test-dev": "vite --debug", | ||
"test-build": "pnpm test-build:client && pnpm test-build:server", | ||
"test-build:client": "vite build --debug --outDir test-dist/client", | ||
"test-build:server": "vite build --debug --outDir test-dist/server --ssr test/main.js", | ||
"why-ts-plugin": "node scripts/createFacadeTsPlugin.js", | ||
@@ -48,11 +44,11 @@ "prepublishOnly": "pnpm build" | ||
"dependencies": { | ||
"es-module-lexer": "^0.7.1", | ||
"es-module-lexer": "^0.9.3", | ||
"magic-string": "^0.25.7" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^16.4.12", | ||
"rollup": "^2.56.0", | ||
"typescript": "^4.3.5", | ||
"vite": "^2.4.4" | ||
"@types/node": "^17.0.2", | ||
"rollup": "^2.61.1", | ||
"typescript": "^4.5.4", | ||
"vite": "^2.7.6" | ||
} | ||
} |
@@ -67,7 +67,19 @@ # vite-plugin-iso-import | ||
```ts | ||
// global.d.ts (are any ambient dts file) | ||
declare module 'lodash-es?client' { | ||
// global.d.ts (or any ambient dts file) | ||
// default export | ||
declare module 'camelcase?client' { | ||
import all from 'camelcase' | ||
export = all | ||
} | ||
// named export | ||
declare module 'lodash-es?server' { | ||
import * as all from 'lodash-es' | ||
export = all | ||
} | ||
// fallback | ||
declare module '*?client' | ||
declare module '*?server' | ||
``` | ||
@@ -74,0 +86,0 @@ |
Sorry, the diff of this file is not supported yet
14745
292
89
+ Addedes-module-lexer@0.9.3(transitive)
- Removedes-module-lexer@0.7.1(transitive)
Updatedes-module-lexer@^0.9.3