File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "name" : " @knighted/module" ,
3- "version" : " 1.0.0-alpha.5 " ,
3+ "version" : " 1.0.0-alpha.6 " ,
44 "description" : " Converts module differences in source files between ES and CommonJS." ,
55 "type" : " module" ,
66 "main" : " dist/module.js" ,
7575 "dependencies" : {
7676 "@babel/parser" : " ^7.27.0" ,
7777 "@babel/traverse" : " ^7.27.0" ,
78- "@knighted/specifier" : " ^2.0.0-rc.4" ,
79- "magic-string" : " ^0.30.10"
78+ "@knighted/specifier" : " ^2.0.1" ,
79+ "magic-string" : " ^0.30.10" ,
80+ "node-module-type" : " ^1.0.2"
8081 },
8182 "prettier" : {
8283 "arrowParens" : " avoid" ,
Original file line number Diff line number Diff line change 11import MagicString from 'magic-string'
22import _traverse from '@babel/traverse'
3+ import { moduleType } from 'node-module-type'
34
45import type { ParseResult } from '@babel/parser'
56import type { File } from '@babel/types'
@@ -9,7 +10,15 @@ import { identifier } from './formatters/identifier.js'
910import { metaProperty } from './formatters/metaProperty.js'
1011import { memberExpression } from './formatters/memberExpression.js'
1112
12- const traverse = _traverse . default
13+ /**
14+ * Runtime hack to prevent issues with babel's default interop while dual building with tsc.
15+ * @see https://github.com/babel/babel/discussions/13093#discussioncomment-12705927
16+ * Temporary fix until I switch to oxc-parser.
17+ */
18+ const type = moduleType ( )
19+ const traverse = (
20+ typeof _traverse === 'function' || type === 'commonjs' ? _traverse : _traverse . default
21+ ) as typeof _traverse . default
1322
1423/**
1524 * Note, there is no specific conversion for `import.meta.main` as it does not exist.
You can’t perform that action at this time.
0 commit comments