-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix regression with loading .ts in .mjs config (#5431)
* Fix regression with loading .ts in .mjs config * Account for directories
- Loading branch information
Showing
5 changed files
with
80 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Fix regression with loading .ts in .mjs config |
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
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,41 @@ | ||
import { expect } from 'chai'; | ||
import * as cheerio from 'cheerio'; | ||
import { fileURLToPath } from 'url'; | ||
|
||
import { | ||
runInContainer, | ||
} from '../../../dist/core/dev/index.js'; | ||
import { openConfig, createSettings } from '../../../dist/core/config/index.js'; | ||
import { createFs } from '../test-utils.js'; | ||
import { defaultLogging } from '../../test-utils.js'; | ||
|
||
const root = new URL('../../fixtures/tailwindcss-ts/', import.meta.url); | ||
|
||
describe('Astro config formats', () => { | ||
it('An mjs config can import TypeScript modules', async () => { | ||
const fs = createFs( | ||
{ | ||
'/src/pages/index.astro': ``, | ||
'/src/stuff.ts': `export default 'works';`, | ||
'/astro.config.mjs': ` | ||
import stuff from './src/stuff.ts'; | ||
export default {} | ||
`, | ||
}, | ||
root | ||
); | ||
|
||
const { astroConfig } = await openConfig({ | ||
cwd: root, | ||
flags: {}, | ||
cmd: 'dev', | ||
logging: defaultLogging, | ||
fsMod: fs | ||
}); | ||
const settings = createSettings(astroConfig); | ||
|
||
await runInContainer({ fs, root, settings }, () => { | ||
expect(true).to.equal(true, 'We were able to get into the container which means the config loaded.'); | ||
}); | ||
}); | ||
}); |