This repository has been archived by the owner on Aug 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add .d.ts typings file * Add test file to check that types are set correctly * Move typings test file to root so its not run by mocha * Automate type tests
- Loading branch information
1 parent
ac791de
commit 6d3567e
Showing
6 changed files
with
141 additions
and
5 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
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,73 @@ | ||
import { Plugin } from 'rollup'; | ||
import { AsyncOpts } from 'resolve'; | ||
|
||
interface RollupNodeResolveOptions { | ||
/** | ||
* use "module" field for ES6 module if possible | ||
* @default true | ||
*/ | ||
module?: boolean; | ||
/** | ||
* use "jsnext:main" if possible | ||
* legacy field pointing to ES6 module in third-party libraries, | ||
* deprecated in favor of "pkg.module": | ||
* - see: https://github.com/rollup/rollup/wiki/pkg.module | ||
* @default false | ||
*/ | ||
jsnext?: boolean; | ||
/** | ||
* use "main" field or index.js, even if it's not an ES6 module | ||
* (needs to be converted from CommonJS to ES6) | ||
* – see https://github.com/rollup/rollup-plugin-commonjs | ||
* @default true | ||
*/ | ||
main?: boolean; | ||
/** | ||
* some package.json files have a `browser` field which | ||
* specifies alternative files to load for people bundling | ||
* for the browser. If that's you, use this option, otherwise | ||
* pkg.browser will be ignored | ||
* @default false | ||
*/ | ||
browser?: boolean; | ||
/** | ||
* not all files you want to resolve are .js files | ||
* @default [ '.mjs', '.js', '.json', '.node' ] | ||
*/ | ||
extensions?: ReadonlyArray<string>; | ||
/** | ||
* whether to prefer built-in modules (e.g. `fs`, `path`) or | ||
* local ones with the same names | ||
* @default true | ||
*/ | ||
preferBuiltins?: boolean; | ||
/** | ||
* Lock the module search in this path (like a chroot). Module defined | ||
* outside this path will be marked as external | ||
* @default '/' | ||
*/ | ||
jail?: string; | ||
/** | ||
* Set to an array of strings and/or regexps to lock the module search | ||
* to modules that match at least one entry. Modules not matching any | ||
* entry will be marked as external | ||
* @default null | ||
*/ | ||
only?: ReadonlyArray<string | RegExp> | null; | ||
/** | ||
* If true, inspect resolved files to check that they are | ||
* ES2015 modules | ||
* @default false | ||
*/ | ||
modulesOnly?: boolean; | ||
/** | ||
* Any additional options that should be passed through | ||
* to node-resolve | ||
*/ | ||
customResolveOptions?: AsyncOpts; | ||
} | ||
|
||
/** | ||
* Locate modules using the Node resolution algorithm, for using third party modules in node_modules | ||
*/ | ||
export default function nodeResolve(options?: RollupNodeResolveOptions): Plugin; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,16 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": [ | ||
"es6" | ||
], | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"strict": true, | ||
"noEmit": true, | ||
"allowJs": true | ||
}, | ||
"files": [ | ||
"index.d.ts", | ||
"typings-test.js" | ||
] | ||
} |
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,30 @@ | ||
// @ts-check | ||
import resolve from '.'; | ||
|
||
/** @type {import("rollup").RollupOptions} */ | ||
const config = { | ||
input: 'main.js', | ||
output: { | ||
file: 'bundle.js', | ||
format: 'iife', | ||
name: 'MyModule', | ||
}, | ||
plugins: [ | ||
resolve({ | ||
module: true, | ||
jsnext: true, | ||
main: true, | ||
browser: true, | ||
extensions: [ '.mjs', '.js', '.jsx', '.json' ], | ||
preferBuiltins: false, | ||
jail: '/my/jail/path', | ||
only: [ 'some_module', /^@some_scope\/.*$/ ], | ||
modulesOnly: true, | ||
customResolveOptions: { | ||
moduleDirectory: 'js_modules' | ||
} | ||
}) | ||
] | ||
}; | ||
|
||
export default config; |