Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🩹 fix(patch): fix emotion plugin resolution (@roots/bud-emotion) #2416

Merged
merged 1 commit into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 43 additions & 29 deletions sources/@roots/bud-cache/test/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ describe(`@roots/bud-cache`, () => {
expect(cache.register).toBeInstanceOf(Function)
})


it(`should have a buildDependencies accessor interface`, async () => {
expect(cache.buildDependencies).toBeDefined()
expect(cache.buildDependencies).toBeInstanceOf(Object)
Expand All @@ -43,33 +42,48 @@ describe(`@roots/bud-cache`, () => {
await cache.register?.(bud)
await cache.boot?.(bud)
expect(cache.configuration).toBeDefined()
expect(cache.configuration).toMatchInlineSnapshot(`
{
"allowCollectingMemory": true,
"buildDependencies": {
"bud": [
"${bud.path(`package.json`)}",
"${bud.path(`tsconfig.json`)}",
"${bud.path(`config/bud.config.js`)}",
],
"tailwind": [
"${bud.path(`config/tailwind.config.js`)}",
],
},
"cacheDirectory": "${bud.context.paths?.[`os-cache`]}/@tests/project/cache",
"compression": "brotli",
"hashAlgorithm": "xxhash64",
"idleTimeout": 100,
"idleTimeoutForInitialStore": 0,
"managedPaths": [
"${bud.context.paths?.[`os-cache`]}/@tests/project/cache",
"${bud.path(`@modules`)}",
],
"name": "production",
"profile": false,
"store": "pack",
"type": "filesystem",
}
`)
expect(cache.configuration).toBeInstanceOf(Object)

// @ts-ignore
expect(cache.configuration?.allowCollectingMemory).toEqual(true)
// @ts-ignore
expect(cache.configuration?.buildDependencies?.bud).toEqual(
expect.arrayContaining([
bud.path(`package.json`),
bud.path(`config/bud.config.js`),
bud.path(`tsconfig.json`),
]),
)
// @ts-ignore
expect(cache.configuration?.buildDependencies?.tailwind).toEqual(
expect.arrayContaining([bud.path(`config/tailwind.config.js`)]),
)
// @ts-ignore
expect(cache.configuration?.cacheDirectory).toMatch(
/@tests\/project\/cache$/,
)
// @ts-ignore
expect(cache.configuration?.compression).toEqual(`brotli`)
// @ts-ignore
expect(cache.configuration?.hashAlgorithm).toEqual(`xxhash64`)
// @ts-ignore
expect(cache.configuration?.idleTimeout).toEqual(100)
// @ts-ignore
expect(cache.configuration?.idleTimeoutForInitialStore).toEqual(0)
// @ts-ignore
expect(cache.configuration?.managedPaths).toEqual(
expect.arrayContaining([
bud.context.paths?.[`os-cache`] + `/@tests/project/cache`,
bud.path(`@modules`),
]),
)
// @ts-ignore
expect(cache.configuration?.name).toEqual(`production`)
// @ts-ignore
expect(cache.configuration?.profile).toEqual(false)
// @ts-ignore
expect(cache.configuration?.store).toEqual(`pack`)
// @ts-ignore
expect(cache.configuration?.type).toEqual(`filesystem`)
})
})
16 changes: 9 additions & 7 deletions sources/@roots/bud-emotion/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@ export class BudEmotion extends Extension<{}, null> {
@bind
public override async boot(bud: Bud) {
if (`babel` in bud) {
const babelPlugin = await this.resolve(`@emotion/babel-plugin`)
bud.babel.setPlugin(`@emotion/babel-plugin`, babelPlugin)
const babelPlugin = await this.resolve(`@emotion/babel-plugin`, import.meta.url)
if (typeof babelPlugin === `string`)
bud.babel.setPlugin(`@emotion/babel-plugin`, babelPlugin)
}

if (`swc` in bud) {
const swcPlugin = await this.resolve(`@swc/plugin-emotion`)
bud.swc.setExperimentalPlugins((plugins = []) => [
...plugins,
[swcPlugin, {}],
])
const swcPlugin = await this.resolve(`@swc/plugin-emotion`, import.meta.url)
if (typeof swcPlugin === `string`)
bud.swc.setPlugins((plugins = []) => [
...plugins,
[swcPlugin, {}],
])
}
}
}
4 changes: 2 additions & 2 deletions sources/@roots/bud-framework/src/extension/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ export class Extension<
@bind
public async import<T = any>(
signifier: string,
context?: string,
context: string,
options: {bustCache?: boolean; raw?: boolean} = {
bustCache: false,
raw: false,
Expand Down Expand Up @@ -464,7 +464,7 @@ export class Extension<
@bind
public async resolve(
signifier: string,
context?: string,
context: string,
): Promise<string> {
try {
return await this.app.module.resolve(signifier, context)
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15449,9 +15449,9 @@ __metadata:
linkType: hard

"caniuse-lite@npm:^1.0.0, caniuse-lite@npm:^1.0.30001464, caniuse-lite@npm:^1.0.30001503, caniuse-lite@npm:^1.0.30001517":
version: 1.0.30001520
resolution: "caniuse-lite@npm:1.0.30001520"
checksum: 59991ad8f36cf282f81abbcc6074c3097c21914cdd54bd2b3f73ac9462f57fc74e90371cd22bcdff4d085d09da42a07dcea384cb81e4ac260496e1bd79e1fe7c
version: 1.0.30001521
resolution: "caniuse-lite@npm:1.0.30001521"
checksum: be2a2b2cd3be03401887aaa31b89f3e7c6230289e6ef704e224268389cc136480fca502ac9e5001a65ff1e50459d3d95f8c4b2d39f878ab9843af3d6f372c8bb
languageName: node
linkType: hard

Expand Down
Loading