Skip to content

Commit

Permalink
fix(dynamic-import-vars): parameter types for dynamicImportToGlob (#1166
Browse files Browse the repository at this point in the history
)

* fix: error types for dynamic-import-vars

* feat: test
  • Loading branch information
poyoho committed Apr 19, 2022
1 parent 7184945 commit f1e1f0a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 10 additions & 2 deletions packages/dynamic-import-vars/test/types.ts
@@ -1,6 +1,6 @@
import { RollupOptions } from 'rollup';

import dynamicImportVars from '..';
import dynamicImportVars, { dynamicImportToGlob } from '../src';

const config: RollupOptions = {
input: 'main.js',
Expand All @@ -13,7 +13,15 @@ const config: RollupOptions = {
include: 'node_modules/**',
exclude: ['node_modules/foo/**', 'node_modules/bar/**'],
warnOnError: true
})
}),
{
name: 'test:dynamicImportToGlob',
buildStart() {
const code = `import("./foo.js")`;
const node = this.parse(code);
dynamicImportToGlob(node, code);
}
}
]
};

Expand Down
6 changes: 4 additions & 2 deletions packages/dynamic-import-vars/types/index.d.ts
@@ -1,5 +1,4 @@
import { FilterPattern } from '@rollup/pluginutils';
import { walk } from 'estree-walker';
import { Plugin } from 'rollup';

interface RollupDynamicImportVariablesOptions {
Expand All @@ -25,7 +24,10 @@ interface RollupDynamicImportVariablesOptions {

export class VariableDynamicImportError extends Error {}

export function dynamicImportToGlob(...params: Parameters<typeof walk>): null | string;
export function dynamicImportToGlob(
node: import('estree').BaseNode,
sourceString: string
): null | string;

/**
* Support variables in dynamic imports in Rollup.
Expand Down

0 comments on commit f1e1f0a

Please sign in to comment.