mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Add types/tests for webpack-virtual-modules (#37025)
* Add types/tests for webpack-virtual-modules * Set minimun typescript to match webpack's
This commit is contained in:
parent
fb3854f2c0
commit
2aceb916d9
28
types/webpack-virtual-modules/index.d.ts
vendored
Normal file
28
types/webpack-virtual-modules/index.d.ts
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
// Type definitions for webpack-virtual-modules 0.1
|
||||
// Project: https://github.com/sysgears/webpack-virtual-modules
|
||||
// Definitions by: Avi Vahl <https://github.com/AviVahl>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import webpack = require('webpack');
|
||||
|
||||
/**
|
||||
* Plugin that allows dynamic generation of in-memory virtual modules for JavaScript builds
|
||||
* created with webpack.
|
||||
*/
|
||||
declare class VirtualModulesPlugin {
|
||||
constructor(modules?: Record<string, string>);
|
||||
|
||||
/**
|
||||
* Attaches necessary hooks, in particular, `afterEnvironment`, `afterResolvers`, and `watchRun` hooks,
|
||||
* to ensure that the virtual files are added dynamically.
|
||||
*/
|
||||
apply(compiler: webpack.Compiler): void;
|
||||
|
||||
/**
|
||||
* Writes a static or dynamic virtual module to a path.
|
||||
*/
|
||||
writeModule(filePath: string, fileContents: string): void;
|
||||
}
|
||||
|
||||
export = VirtualModulesPlugin;
|
||||
23
types/webpack-virtual-modules/tsconfig.json
Normal file
23
types/webpack-virtual-modules/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"webpack-virtual-modules-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/webpack-virtual-modules/tslint.json
Normal file
1
types/webpack-virtual-modules/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@ -0,0 +1,13 @@
|
||||
import webpack = require('webpack');
|
||||
import VirtualModulesPlugin = require('webpack-virtual-modules');
|
||||
|
||||
const virtualModules = new VirtualModulesPlugin({
|
||||
'node_modules/module-foo.js': 'module.exports = { foo: "foo" };',
|
||||
'node_modules/module-bar.js': 'module.exports = { bar: "bar" };',
|
||||
});
|
||||
|
||||
virtualModules.writeModule('node_modules/module-foo.js', 'module.exports = { foo: "foo" };');
|
||||
|
||||
webpack({
|
||||
plugins: [virtualModules],
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user