-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: correct module systems by file extension. addresses microsoft/T…
- Loading branch information
1 parent
bfd59a9
commit 6f91a89
Showing
22 changed files
with
276 additions
and
31 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
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
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,18 @@ | ||
{ | ||
"version": "0.0.0", | ||
"type": "commonjs", | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./dist/mjs/index.d.mts", | ||
"default": "./dist/index.mjs" | ||
}, | ||
"require": { | ||
"types": "./dist/index.d.cts", | ||
"default": "./dist/index.cjs" | ||
}, | ||
"default": "./dist/index.cjs" | ||
}, | ||
"./package.json": "./package.json" | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
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,9 @@ | ||
interface ESM { | ||
esm: boolean; | ||
} | ||
|
||
export const esm: ESM = { | ||
esm: true | ||
} | ||
|
||
export type { ESM } |
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 |
---|---|---|
|
@@ -16,5 +16,5 @@ const mod: Mod = { | |
} | ||
} | ||
|
||
export { mod } | ||
export { mod, cjs } | ||
export type { Mod } |
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,39 @@ | ||
import { mod } from "./folder/module.js" | ||
import { cjs } from './cjs.cjs' | ||
|
||
import type { Mod } from "./folder/module.js" | ||
import type { CJS } from "./cjs.cjs" | ||
|
||
interface User { | ||
name: string; | ||
id: number; | ||
mod: Mod; | ||
esm: any; | ||
cjs: CJS; | ||
} | ||
|
||
class UserAccount { | ||
name: string; | ||
id: number; | ||
mod: Mod; | ||
esm: any; | ||
cjs: CJS; | ||
|
||
constructor(name: string, id: number, mod: Mod, esm: any, cjs: CJS) { | ||
this.name = name; | ||
this.id = id; | ||
this.mod = mod; | ||
this.esm = esm; | ||
this.cjs = cjs; | ||
} | ||
} | ||
|
||
const getUser = async () => { | ||
const { esm } = await import('./esm.mjs') | ||
|
||
return new UserAccount("Murphy", 1, mod, esm, cjs) | ||
} | ||
|
||
export type { User } | ||
|
||
export { getUser } |
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,12 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"module": "CommonJS", | ||
"moduleResolution": "Node", | ||
"declaration": true, | ||
"strict": false, | ||
"outDir": "dist", | ||
"lib": ["ES2015"] | ||
}, | ||
"include": ["src"] | ||
} |
File renamed without changes.
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,3 @@ | ||
//import * as cjs from './dist/cjs/cjs.cjs' | ||
|
||
require('./dist/cjs/cjs.cjs') |
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,39 @@ | ||
/* | ||
import type { ESM } from './esm.mjs' assert { 'resolution-mode': 'import' }; | ||
interface CJS { | ||
cjs: boolean, | ||
esm: ESM; | ||
} | ||
const func = async () => { | ||
const { esm } = await import('./esm.mjs') | ||
const cjs: CJS = { | ||
cjs: true, | ||
esm | ||
} | ||
return cjs | ||
} | ||
export { func } | ||
export type { CJS } | ||
*/ | ||
|
||
import MagicString from "magic-string" | ||
|
||
interface CJS { | ||
cjs: boolean; | ||
magic: MagicString; | ||
} | ||
|
||
const cjs: CJS = { | ||
cjs: true, | ||
magic: new MagicString('magic') | ||
} | ||
|
||
export { cjs } | ||
|
||
export type { CJS } |
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,9 @@ | ||
interface ESM { | ||
esm: boolean; | ||
} | ||
|
||
export const esm: ESM = { | ||
esm: true | ||
} | ||
|
||
export type { ESM } |
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,9 @@ | ||
interface ESM { | ||
esm: boolean; | ||
} | ||
|
||
export const esm: ESM = { | ||
esm: true | ||
} | ||
|
||
export type { ESM } |
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,20 @@ | ||
import MagicString from "magic-string"; | ||
import { cjs } from "../cjs.cjs"; | ||
|
||
import type { CJS } from "../cjs.cjs"; | ||
|
||
interface Mod { | ||
prop: string; | ||
cjs: CJS | ||
} | ||
|
||
const mod: Mod = { | ||
prop: 'foobar', | ||
cjs: { | ||
cjs: true, | ||
magic: new MagicString('module') | ||
} | ||
} | ||
|
||
export { mod, cjs } | ||
export type { Mod } |
File renamed without changes.
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 |
---|---|---|
|
@@ -8,5 +8,5 @@ | |
"outDir": "dist", | ||
"lib": ["ES2015"] | ||
}, | ||
"include": ["src/*.ts"] | ||
"include": ["src"] | ||
} |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.