diff --git a/packages/cli/src/tests/transforms/__fixtures__/pkg-commonjs/main.ts b/packages/cli/src/tests/transforms/__fixtures__/pkg-commonjs/main.ts index 4cb18038b3..c0494e86b6 100644 --- a/packages/cli/src/tests/transforms/__fixtures__/pkg-commonjs/main.ts +++ b/packages/cli/src/tests/transforms/__fixtures__/pkg-commonjs/main.ts @@ -26,7 +26,7 @@ import { default as defaultA } from './a-default'; // import { default as defaultB } from './b-default'; import { default as defaultC } from './c-default'; -async function resolveAll(obj) { +async function resolveAll(obj): Promise { const val = await obj; if (typeof val !== 'object' || val === null) { return val; @@ -44,7 +44,7 @@ async function resolveAll(obj) { ); } -resolveAll({ +export const values = resolveAll({ depCommonJs, // depModule, depDefault, @@ -67,4 +67,4 @@ resolveAll({ defaultB: import('./b-default').then(m => m.default), defaultC: import('./c-default').then(m => m.default.default), }, -}).then(obj => console.log(JSON.stringify(obj, null, 2))); +}); diff --git a/packages/cli/src/tests/transforms/__fixtures__/pkg-commonjs/print.ts b/packages/cli/src/tests/transforms/__fixtures__/pkg-commonjs/print.ts new file mode 100644 index 0000000000..7c24f99f37 --- /dev/null +++ b/packages/cli/src/tests/transforms/__fixtures__/pkg-commonjs/print.ts @@ -0,0 +1,19 @@ +/* + * Copyright 2024 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { values } from './main'; + +values.then(obj => console.log(JSON.stringify(obj, null, 2))); diff --git a/packages/cli/src/tests/transforms/__fixtures__/pkg-default/main.ts b/packages/cli/src/tests/transforms/__fixtures__/pkg-default/main.ts index 4cb18038b3..c0494e86b6 100644 --- a/packages/cli/src/tests/transforms/__fixtures__/pkg-default/main.ts +++ b/packages/cli/src/tests/transforms/__fixtures__/pkg-default/main.ts @@ -26,7 +26,7 @@ import { default as defaultA } from './a-default'; // import { default as defaultB } from './b-default'; import { default as defaultC } from './c-default'; -async function resolveAll(obj) { +async function resolveAll(obj): Promise { const val = await obj; if (typeof val !== 'object' || val === null) { return val; @@ -44,7 +44,7 @@ async function resolveAll(obj) { ); } -resolveAll({ +export const values = resolveAll({ depCommonJs, // depModule, depDefault, @@ -67,4 +67,4 @@ resolveAll({ defaultB: import('./b-default').then(m => m.default), defaultC: import('./c-default').then(m => m.default.default), }, -}).then(obj => console.log(JSON.stringify(obj, null, 2))); +}); diff --git a/packages/cli/src/tests/transforms/__fixtures__/pkg-default/print.ts b/packages/cli/src/tests/transforms/__fixtures__/pkg-default/print.ts new file mode 100644 index 0000000000..7c24f99f37 --- /dev/null +++ b/packages/cli/src/tests/transforms/__fixtures__/pkg-default/print.ts @@ -0,0 +1,19 @@ +/* + * Copyright 2024 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { values } from './main'; + +values.then(obj => console.log(JSON.stringify(obj, null, 2))); diff --git a/packages/cli/src/tests/transforms/__fixtures__/pkg-module/main.ts b/packages/cli/src/tests/transforms/__fixtures__/pkg-module/main.ts index 4db74f0b86..7b40a259f6 100644 --- a/packages/cli/src/tests/transforms/__fixtures__/pkg-module/main.ts +++ b/packages/cli/src/tests/transforms/__fixtures__/pkg-module/main.ts @@ -29,7 +29,7 @@ import cDefault from './c-default'; const { default: defaultC } = cDefault; const { value: namedC } = cNamed; -async function resolveAll(obj) { +async function resolveAll(obj): Promise { const val = await obj; if (typeof val !== 'object' || val === null) { return val; @@ -47,7 +47,7 @@ async function resolveAll(obj) { ); } -resolveAll({ +export const values = resolveAll({ depCommonJs, depModule, depDefault, @@ -70,4 +70,4 @@ resolveAll({ defaultB: import('./b-default').then(m => m.default), defaultC: import('./c-default').then(m => m.default.default), }, -}).then(obj => console.log(JSON.stringify(obj, null, 2))); +}); diff --git a/packages/cli/src/tests/transforms/__fixtures__/pkg-module/print.ts b/packages/cli/src/tests/transforms/__fixtures__/pkg-module/print.ts new file mode 100644 index 0000000000..7c24f99f37 --- /dev/null +++ b/packages/cli/src/tests/transforms/__fixtures__/pkg-module/print.ts @@ -0,0 +1,19 @@ +/* + * Copyright 2024 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { values } from './main'; + +values.then(obj => console.log(JSON.stringify(obj, null, 2))); diff --git a/packages/cli/src/tests/transforms/transforms.test.ts b/packages/cli/src/tests/transforms/transforms.test.ts index b9180e69d6..83676d4136 100644 --- a/packages/cli/src/tests/transforms/transforms.test.ts +++ b/packages/cli/src/tests/transforms/transforms.test.ts @@ -65,7 +65,7 @@ function loadFixture(fixture: string) { describe('node runtime module transforms', () => { it('should load from commonjs format', async () => { - expect(loadFixture('pkg-commonjs/main.ts')).toEqual({ + expect(loadFixture('pkg-commonjs/print.ts')).toEqual({ depCommonJs: expectedExports.commonJs, depDefault: expectedExports.commonJs, dynCommonJs: expectedExports.commonJs, @@ -77,7 +77,7 @@ describe('node runtime module transforms', () => { }); it('should load from default format', async () => { - expect(loadFixture('pkg-default/main.ts')).toEqual({ + expect(loadFixture('pkg-default/print.ts')).toEqual({ depCommonJs: expectedExports.commonJs, depDefault: expectedExports.commonJs, dynCommonJs: expectedExports.commonJs, @@ -89,7 +89,7 @@ describe('node runtime module transforms', () => { }); it('should load from module format', async () => { - expect(loadFixture('pkg-module/main.ts')).toEqual({ + expect(loadFixture('pkg-module/print.ts')).toEqual({ depCommonJs: expectedExports.commonJs, depDefault: expectedExports.commonJs, depModule: expectedExports.module,