Skip to content

Commit

Permalink
feat(cjs): allow query in import specifier (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber committed Nov 9, 2023
1 parent ddf6fcc commit b32b135
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/cjs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ Object.defineProperty(extensions, '.mjs', {

const defaultResolveFilename = Module._resolveFilename.bind(Module);
Module._resolveFilename = (request, parent, isMain, options) => {
// Strip query string
const queryIndex = request.indexOf('?');
if (queryIndex !== -1) {
request = request.slice(0, queryIndex);
}

if (
tsconfigPathsMatcher

Expand Down
4 changes: 2 additions & 2 deletions tests/specs/smoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ export default testSuite(async ({ describe }, { tsx }: NodeApis) => {
// .js
import * as js from './js/index.js';
// import * as js from './js/index.js?query=123'; Support query
import './js/index.js?query=123';
import './js/index';
import './js/';
Expand Down Expand Up @@ -463,7 +463,7 @@ export default testSuite(async ({ describe }, { tsx }: NodeApis) => {
// .js
import * as js from './js/index.js';
// import * as js from './js/index.js?query=123'; TODO: Support query
import './js/index.js?query=123';
import './js/index';
import './js/';
Expand Down

0 comments on commit b32b135

Please sign in to comment.