Skip to content

Commit

Permalink
fix!: use .js extension for files in runtime/ directory
Browse files Browse the repository at this point in the history
danielroe committed May 22, 2024

Verified

This commit was signed with the committer’s verified signature.
danielroe Daniel Roe
1 parent afc4374 commit dbd05bb
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/commands/build.ts
Original file line number Diff line number Diff line change
@@ -54,7 +54,8 @@ export default defineCommand({
{
input: 'src/runtime/',
outDir: `${outDir}/runtime`,
ext: 'mjs',
addRelativeDeclarationExtensions: true,
ext: 'js',
esbuild: {
jsxImportSource: 'vue',
jsx: 'automatic',
File renamed without changes.
6 changes: 3 additions & 3 deletions test/build.spec.ts
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ describe('module builder', () => {
expect(runtime).toMatchInlineSnapshot(`
[
"plugin.d.ts",
"plugin.mjs",
"plugin.js",
]
`)
})
@@ -109,10 +109,10 @@ describe('module builder', () => {

it('should handle JSX correctly', async () => {
const [component, declaration] = await Promise.all([
readFile(join(distDir, 'runtime/components/JsxComponent.mjs'), 'utf-8'),
readFile(join(distDir, 'runtime/components/JsxComponent.js'), 'utf-8'),
readFile(join(distDir, 'runtime/components/JsxComponent.d.ts'), 'utf-8'),
])
expect(component).toMatchFileSnapshot('__snapshots__/JsxComponent.mjs')
expect(component).toMatchFileSnapshot('__snapshots__/JsxComponent.js')
expect(declaration).toMatchFileSnapshot('__snapshots__/JsxComponent.d.ts')
})
})

3 comments on commit dbd05bb

@ineshbose
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may I know what were the issues being faced without this?

@danielroe
Copy link
Member Author

@danielroe danielroe commented on dbd05bb Jun 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is about defaulting to type: module, and this way .d.ts matches the .js extension - you can opt back to .mjs if you want. Is it causing issues?

@ineshbose
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! I haven’t tested it for issues yet - just had build failing in the tailwind module after update, but I’m also concerned about the CJS nature of Tailwind configs that use our MJS code, and also support for Nuxt 2. Let me configure the build config for this.

Please sign in to comment.