Comments (6)
commonjsHelpers.js
是 Vite 中生成的一个虚拟文件名,本身就不存在,看有没有办法直接判断一下这个文件名,将它忽略掉
from vite-plugin-dts.
Would you provide a test project to reproduce this issue?
from vite-plugin-dts.
`import { encrypt, decrypt } from 'crypto-js/aes';
import UTF8, { parse } from 'crypto-js/enc-utf8';
import pkcs7 from 'crypto-js/pad-pkcs7';
import ECB from 'crypto-js/mode-ecb';
import md5 from 'crypto-js/md5';
// import UTF8 from 'crypto-js/enc-utf8';
import Base64 from 'crypto-js/enc-base64';
import type WordArray from 'crypto-js/lib-typedarrays';
import type crypto from 'crypto-js';
type CipherParams = crypto.lib.CipherParams;
// type WordArray = lib.WordArray;
// aes encryption key
export const cacheCipher = {
key: '11111000001111@',
iv: '@11111000001111',
};
// 加密参数
export interface EncryptionParams {
key: string;
iv: string;
}
interface Format {
stringify: (cipherParams: CipherParams) => string;
parse: (str: string) => CipherParams;
}
interface CipherOption {
iv?: WordArray | undefined;
format?: Format | undefined;
[key: string]: any;
}
// interface CipherOptionCopy {
// /**
// * The IV to use for this operation.
// */
// iv?: WordArray | undefined;
// format?: Format | undefined;
// [key: string]: any;
// }
// export interface CipherOptions {
// mode: typeof ECB;
// padding: typeof pkcs7;
// key: WordArray | null;
// iv: WordArray | null;
// }
// JSON.stringify()
// JSON.parse()
// usage const encryption = new AesEncryption({ key, iv });
// const stringifyValue = this.hasEncrypt
// ? this.encryption.encryptByAES(stringData)
// : stringData;
// const decVal = this.hasEncrypt ? this.encryption.decryptByAES(val) : val;
// const data = JSON.parse(decVal);
//
// aes加密器
export class AesEncryption {
private readonly key: WordArray | undefined = undefined;
private readonly iv: WordArray | undefined = undefined;
public constructor(opt: Partial = {}) {
const { key, iv } = opt;
if (!key || !iv) {
throw new Error('the key or iv can not be empty!');
} else if ([key.length, iv.length].some((item) => item !== 16)) {
throw new Error('the key or iv must be 16 bits!');
}
if (key) {
this.key = parse(key);
}
if (iv) {
this.iv = parse(iv);
}
}
public get getOptions(): CipherOption {
return {
mode: ECB,
padding: pkcs7,
key: this.key,
iv: this.iv,
};
}
// 加密
public encryptByAES(cipherText: string) {
return encrypt(cipherText, this.key as WordArray, this.getOptions).toString();
}
// 解密
public decryptByAES(cipherText: string) {
return decrypt(cipherText, this.key as WordArray, this.getOptions).toString(UTF8);
}
}
export function encryptByBase64(cipherText: string) {
return UTF8.parse(cipherText).toString(Base64);
}
export function decodeByBase64(cipherText: string) {
return Base64.parse(cipherText).toString(UTF8);
}
export function encryptByMd5(password: string) {
return md5(password).toString();
}
`
index.ts:
export * from '@/cipher';
dependency
"crypto-js": "^4.1.1",
from vite-plugin-dts.
@qmhc I think this problem is because crypto-js is a umd package.
I'm trying rewrite crypto-js to ts project.
but I think if there are common solution is good
from vite-plugin-dts.
commonjsHelpers.js
是 Vite 中生成的一个虚拟文件名,本身就不存在,看有没有办法直接判断一下这个文件名,将它忽略掉
from vite-plugin-dts.
@luozhihua 没有继续深挖这个问题,目前用 tsup 和 tsc 进行 type 的打包。由于 type 实际只存在于运行态,目前我计划后续研究下 esbuild 在这方面的问题。依赖 rollup 进行对 ts 的类型打包有一些问题,尤其因为我还用了 pnpm,尤其麻烦。只好先作罢了。
from vite-plugin-dts.
Related Issues (20)
- Feature: Support ${configDir} template variable in tsconfig.json (added in typescript 5.5)
- Error: "Cannot find module 'vue'" after updating to 3.8.0 or up HOT 1
- 大神,我生成的类型文件是源文件的结构,这种模式下导入组件的时候 package.json 中 types 该如何指定 HOT 1
- Issue while installing the plugin HOT 7
- Modify .tsx files during the build process to include additional TypeScript interfaces HOT 2
- namespace declaration exports two times HOT 3
- Can the index file under the file be searched by default And How to handle getResolvedModule errors HOT 1
- Volar generated type been added HOT 3
- Vue vulnerability HOT 4
- Declaration map d.ts.map files do not match transformed d.ts files HOT 1
- [vite:dts] Internal Error when re-exporting types from index.js HOT 6
- Upgrade @microsoft/[email protected] to latest so latest typescript version can be used HOT 3
- Adds many unrelated vue dependencies to the project HOT 1
- error during build: [vite:dts] Internal Error: Unable to determine module for: E:/develop/useBitable/dist/index.d.ts
- Bogus typescript errors related to default imports during since 4.x HOT 1
- Missing Dependency "lru-cache@^6.0.0"
- Type error: File 'index.d.ts' is not a module since 4.0 HOT 1
- The new version (4.0.2) is unable to follow symbol for "Record" HOT 2
- Win11 - Internal Error with Vite and TypeScript - "Unable to follow symbol for 'Promise'" Description HOT 2
- Unable to follow symbol for "Omit" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vite-plugin-dts.