'ModuleName' is not exported by
See original GitHub issueThis line causes the following error.
import { Database as Connection } from 'better-sqlite3';
> tsup index.ts --dts --bundle
Error: 'Database' is not exported by node_modules/@types/better-sqlite3/index.d.ts, imported by lib/drivers/sqlite.ts
at error (/Users/xo/code/scratchdb/database/node_modules/rollup/dist/shared/rollup.js:161:30)
at Module.error (/Users/xo/code/scratchdb/database/node_modules/rollup/dist/shared/rollup.js:15097:16)
at handleMissingExport (/Users/xo/code/scratchdb/database/node_modules/rollup/dist/shared/rollup.js:14994:28)
at Module.traceVariable (/Users/xo/code/scratchdb/database/node_modules/rollup/dist/shared/rollup.js:15478:24)
at ModuleScope.findVariable (/Users/xo/code/scratchdb/database/node_modules/rollup/dist/shared/rollup.js:14047:39)
at FunctionScope.findVariable (/Users/xo/code/scratchdb/database/node_modules/rollup/dist/shared/rollup.js:9527:38)
at Identifier$1.bind (/Users/xo/code/scratchdb/database/node_modules/rollup/dist/shared/rollup.js:9938:40)
at AssignmentPattern.bind (/Users/xo/code/scratchdb/database/node_modules/rollup/dist/shared/rollup.js:9571:23)
at AssignmentPattern.bind (/Users/xo/code/scratchdb/database/node_modules/rollup/dist/shared/rollup.js:11615:15)
at FunctionDeclaration.bind (/Users/xo/code/scratchdb/database/node_modules/rollup/dist/shared/rollup.js:9567:31)
This is the better-sqlite3
definition file it’s referencing.
// Type definitions for better-sqlite3 5.4
// Project: http://github.com/JoshuaWise/better-sqlite3
// Definitions by: Ben Davies <https://github.com/Morfent>
// Mathew Rumsey <https://github.com/matrumz>
// Santiago Aguilar <https://github.com/sant123>
// Alessandro Vergani <https://github.com/loghorn>
// Andrew Kaiser <https://github.com/andykais>
// Mark Stewart <https://github.com/mrkstwrt>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
import Integer = require("integer");
type VariableArgFunction = (...params: any[]) => any;
type ArgumentTypes<F extends VariableArgFunction> = F extends (...args: infer A) => any
? A
: never;
declare namespace BetterSqlite3 {
interface Statement<BindParameters extends any[]> {
database: Database;
source: string;
reader: boolean;
run(...params: BindParameters): Database.RunResult;
get(...params: BindParameters): any;
all(...params: BindParameters): any[];
iterate(...params: BindParameters): IterableIterator<any>;
pluck(toggleState?: boolean): this;
expand(toggleState?: boolean): this;
raw(toggleState?: boolean): this;
bind(...params: BindParameters): this;
columns(): ColumnDefinition[];
safeIntegers(toggleState?: boolean): this;
}
interface ColumnDefinition {
name: string;
column: string | null;
table: string | null;
database: string | null;
type: string | null;
}
interface Transaction<F extends VariableArgFunction> {
(...params: ArgumentTypes<F>): ReturnType<F>;
default(...params: ArgumentTypes<F>): ReturnType<F>;
deferred(...params: ArgumentTypes<F>): ReturnType<F>;
immediate(...params: ArgumentTypes<F>): ReturnType<F>;
exclusive(...params: ArgumentTypes<F>): ReturnType<F>;
}
interface Database {
memory: boolean;
readonly: boolean;
name: string;
open: boolean;
inTransaction: boolean;
// tslint:disable-next-line no-unnecessary-generics
prepare<BindParameters extends any[] | {} = any[]>(source: string): BindParameters extends any[]
? Statement<BindParameters>
: Statement<[BindParameters]>;
transaction<F extends VariableArgFunction>(fn: F): Transaction<F>;
exec(source: string): this;
pragma(source: string, options?: Database.PragmaOptions): any;
checkpoint(databaseName?: string): this;
function(name: string, cb: (...params: any[]) => any): this;
function(name: string, options: Database.RegistrationOptions, cb: (...params: any[]) => any): this;
aggregate(name: string, options: Database.AggregateOptions): this;
loadExtension(path: string): this;
close(): this;
defaultSafeIntegers(toggleState?: boolean): this;
backup(destinationFile: string, options?: Database.BackupOptions): Promise<Database.BackupMetadata>;
}
interface DatabaseConstructor {
new(filename: string, options?: Database.Options): Database;
(filename: string, options?: Database.Options): Database;
prototype: Database;
Integer: typeof Integer;
SqliteError: typeof SqliteError;
}
}
declare class SqliteError implements Error {
name: string;
message: string;
code: string;
constructor(message: string, code: string);
}
declare namespace Database {
interface RunResult {
changes: number;
lastInsertRowid: Integer.IntLike;
}
interface Options {
memory?: boolean;
readonly?: boolean;
fileMustExist?: boolean;
timeout?: number;
verbose?: (message?: any, ...additionalArgs: any[]) => void;
}
interface PragmaOptions {
simple?: boolean;
}
interface RegistrationOptions {
varargs?: boolean;
deterministic?: boolean;
safeIntegers?: boolean;
}
interface AggregateOptions extends RegistrationOptions {
start?: any;
step: (total: any, next: any) => any;
inverse?: (total: any, dropped: any) => any;
result?: (total: any) => any;
}
interface BackupMetadata {
totalPages: number;
remainingPages: number;
}
interface BackupOptions {
progress: (info: BackupMetadata) => number;
}
type Integer = typeof Integer;
type SqliteError = typeof SqliteError;
type Statement<BindParameters extends any[] | {} = any[]> = BindParameters extends any[]
? BetterSqlite3.Statement<BindParameters>
: BetterSqlite3.Statement<[BindParameters]>;
type ColumnDefinition = BetterSqlite3.ColumnDefinition;
type Transaction = BetterSqlite3.Transaction<VariableArgFunction>;
type Database = BetterSqlite3.Database;
}
declare const Database: BetterSqlite3.DatabaseConstructor;
export = Database;
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (4 by maintainers)
Top Results From Across the Web
Solving "NAME is not exported by MODULE" When Using ...
Now, when I run the build for this project, instead of pulling from the Github repository, it will just use my local directory...
Read more >Rollup says "[name] is not exported by [file]" while it clearly is
In a svelte component you will need to import your types by specifying that what you import is a type: import { Topic...
Read more >export - JavaScript - MDN Web Docs
This re-exports all named exports from mod as the named exports of the current module, but the default export of mod is not...
Read more >import - JavaScript - UDN Web Docs: MDN Backup
Name that will refer to the default export from the module. module-name: The module to import from. This is often a relative or...
Read more >The Haskell 98 Report: Modules
Modules are used for name-space control, and are not first class values. ... Here the module Queue uses the module name Stack in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Seems rollup-plugin-dts doesn’t support exportEqual namespace yet?:
This doesn’t work:
This actually works because TS uses structural typing. With nominal typing, you would have to re-export the actual thing from your external library, otherwise you wouldn’t be able to use that stuff. Anyway, I digress