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)
- Errors being swallowed when `rollupTypes: true` HOT 2
- 【Regression】Library which use IterableIterator.entries() cause TS Error. HOT 2
- 升级 language-tools 到 2.0 HOT 1
- Wrong definition generations since 3.8.2 for
- feat: Add a way to get the TypeScript program instance
- 打包一个库的时候,defineProps问题 HOT 1
- 3.8.0+ Cannot build while excluding vite-env.d.ts
- Invalid imports in generated d.ts for project with tsconfig path alias defined for any module
- 【功能请求】希望可以增加一个像rollup一样可以自定义输出目录层级的功能 HOT 2
- Cannot find name'DefineComponent'
- [docs] The parameter explanation for the afterBuild option in README.md is incorrect.
- Keep comments of the variable in d.ts HOT 3
- Trigger declaration generation in vite build watch mode when non-ts file changes
- bug: tsconfig.json's "files" option is ignored HOT 1
- build fails when using yarn 4 with pnp and rollupTypes: true HOT 1
- All typescript errors are being swallowed HOT 1
- TS-Errors when building with Vite `v5.3.1` HOT 1
- DTS not compatible with latest React Vite tsconfig structure HOT 9
- `"type": "module"` with `rollupTypes: true` results in error HOT 1
- Feature: Support ${configDir} template variable in tsconfig.json (added in typescript 5.5)
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.