Skip to content

Commit

Permalink
test: chdir before build
Browse files Browse the repository at this point in the history
  • Loading branch information
fi3ework committed Jul 16, 2024
1 parent a230db5 commit 8eb3fa4
Show file tree
Hide file tree
Showing 17 changed files with 124 additions and 196 deletions.
8 changes: 4 additions & 4 deletions e2e/cases/alias/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

exports[`source.alias 1`] = `
"
;// CONCATENATED MODULE: ./e2e/cases/alias/src/a.ts
;// CONCATENATED MODULE: ./src/a.ts
const a = 'hello world';
;// CONCATENATED MODULE: ./e2e/cases/alias/src/index.ts
;// CONCATENATED MODULE: ./src/index.ts
console.info(a);
Expand All @@ -18,10 +18,10 @@ exports[`source.alias 2`] = `
"use strict";
var __webpack_exports__ = {};
;// CONCATENATED MODULE: ./e2e/cases/alias/src/a.ts
;// CONCATENATED MODULE: ./src/a.ts
const a = 'hello world';
;// CONCATENATED MODULE: ./e2e/cases/alias/src/index.ts
;// CONCATENATED MODULE: ./src/index.ts
console.info(a);
Expand Down
5 changes: 2 additions & 3 deletions e2e/cases/alias/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { join } from 'node:path';
import { defineConfig } from '@rslib/core';
import { generateBundleCjsConfig, generateBundleEsmConfig } from '#shared';

export default defineConfig({
lib: [generateBundleEsmConfig(__dirname), generateBundleCjsConfig(__dirname)],
source: {
entry: {
main: join(__dirname, 'src/index.ts'),
main: './src/index.ts',
},
alias: {
'@src': join(__dirname, 'src'),
'@src': 'src',
},
},
});
3 changes: 1 addition & 2 deletions e2e/cases/autoExtension/type-commonjs/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { join } from 'node:path';
import { defineConfig } from '@rslib/core';
import {
generateBundleCjsConfig,
Expand All @@ -16,7 +15,7 @@ export default defineConfig({
],
source: {
entry: {
main: join(__dirname, 'src/index.ts'),
main: './src/index.ts',
},
},
});
3 changes: 1 addition & 2 deletions e2e/cases/autoExtension/type-module/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { join } from 'node:path';
import { defineConfig } from '@rslib/core';
import {
generateBundleCjsConfig,
Expand All @@ -16,7 +15,7 @@ export default defineConfig({
],
source: {
entry: {
main: join(__dirname, 'src/index.ts'),
main: './src/index.ts',
},
},
});
3 changes: 1 addition & 2 deletions e2e/cases/define/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { join } from 'node:path';
import { defineConfig } from '@rslib/core';
import { generateBundleCjsConfig, generateBundleEsmConfig } from '#shared';

export default defineConfig({
lib: [generateBundleEsmConfig(__dirname), generateBundleCjsConfig(__dirname)],
source: {
entry: {
main: join(__dirname, 'src/index.ts'),
main: './src/index.ts',
},
define: {
VERSION: JSON.stringify('1.0.0'),
Expand Down
3 changes: 1 addition & 2 deletions e2e/cases/externals/browser/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { join } from 'node:path';
import { defineConfig } from '@rslib/core';
import { generateBundleCjsConfig, generateBundleEsmConfig } from '#shared';

export default defineConfig({
lib: [generateBundleEsmConfig(__dirname), generateBundleCjsConfig(__dirname)],
source: {
entry: {
main: join(__dirname, 'src/index.ts'),
main: './src/index.ts',
},
},
output: {
Expand Down
3 changes: 1 addition & 2 deletions e2e/cases/externals/node/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { join } from 'node:path';
import { defineConfig } from '@rslib/core';
import { generateBundleCjsConfig, generateBundleEsmConfig } from '#shared';

Expand All @@ -9,7 +8,7 @@ export default defineConfig({
],
source: {
entry: {
main: join(__dirname, 'src/index.ts'),
main: './src/index.ts',
},
},
output: {
Expand Down
10 changes: 5 additions & 5 deletions e2e/cases/syntax/config/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

exports[`should downgrade class private method by default 1`] = `
"
;// CONCATENATED MODULE: ./node_modules/.pnpm/@[email protected]/node_modules/@swc/helpers/esm/_class_private_method_get.js
;// CONCATENATED MODULE: ../../../../node_modules/.pnpm/@[email protected]/node_modules/@swc/helpers/esm/_class_private_method_get.js
function _class_private_method_get(receiver, privateSet, fn) {
if (!privateSet.has(receiver)) throw new TypeError("attempted to get private field on non-instance");
return fn;
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/@[email protected]/node_modules/@swc/helpers/esm/_check_private_redeclaration.js
;// CONCATENATED MODULE: ../../../../node_modules/.pnpm/@[email protected]/node_modules/@swc/helpers/esm/_check_private_redeclaration.js
function _check_private_redeclaration(obj, privateCollection) {
if (privateCollection.has(obj)) {
throw new TypeError("Cannot initialize the same private elements twice on an object");
}
}
;// CONCATENATED MODULE: ./node_modules/.pnpm/@[email protected]/node_modules/@swc/helpers/esm/_class_private_method_init.js
;// CONCATENATED MODULE: ../../../../node_modules/.pnpm/@[email protected]/node_modules/@swc/helpers/esm/_class_private_method_init.js
function _class_private_method_init(obj, privateSet) {
Expand All @@ -27,7 +27,7 @@ function _class_private_method_init(obj, privateSet) {
}
;// CONCATENATED MODULE: ./e2e/cases/syntax/config/src/foo.ts
;// CONCATENATED MODULE: ./src/foo.ts
var _bar = new WeakSet();
Expand All @@ -40,7 +40,7 @@ class Foo {
function bar() {}
/*#__PURE__*/
;// CONCATENATED MODULE: ./e2e/cases/syntax/config/src/index.ts
;// CONCATENATED MODULE: ./src/index.ts
export { Foo };
Expand Down
3 changes: 1 addition & 2 deletions e2e/cases/syntax/config/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { join } from 'node:path';
import { defineConfig } from '@rslib/core';
import { generateBundleCjsConfig, generateBundleEsmConfig } from '#shared';

Expand All @@ -17,7 +16,7 @@ export default defineConfig({
],
source: {
entry: {
main: join(__dirname, 'src/index.ts'),
main: './src/index.ts',
},
},
});
4 changes: 2 additions & 2 deletions e2e/cases/syntax/default/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`should downgrade class private method by default 1`] = `
"
;// CONCATENATED MODULE: ./e2e/cases/syntax/default/src/foo.ts
;// CONCATENATED MODULE: ./src/foo.ts
class Foo {
constructor(){
this.#bar();
Expand All @@ -11,7 +11,7 @@ class Foo {
}
;// CONCATENATED MODULE: ./e2e/cases/syntax/default/src/index.ts
;// CONCATENATED MODULE: ./src/index.ts
export { Foo };
Expand Down
3 changes: 1 addition & 2 deletions e2e/cases/syntax/default/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { join } from 'node:path';
import { defineConfig } from '@rslib/core';
import { generateBundleCjsConfig, generateBundleEsmConfig } from '#shared';

export default defineConfig({
lib: [generateBundleEsmConfig(__dirname), generateBundleCjsConfig(__dirname)],
source: {
entry: {
main: join(__dirname, 'src/index.ts'),
main: './src/index.ts',
},
},
});
1 change: 1 addition & 0 deletions e2e/scripts/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export async function getEntryJsResults(rslibConfig: RslibConfig) {

export const buildAndGetEntryJsResults = async (fixturePath: string) => {
const rslibConfig = await loadConfig(join(fixturePath, 'rslib.config.ts'));
process.chdir(fixturePath);
await build(rslibConfig);
const results = await getEntryJsResults(rslibConfig);
return {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"prettier-plugin-packagejson": "^2.5.0",
"simple-git-hooks": "^2.11.1",
"typescript": "^5.5.3",
"vitest": "^1.6.0"
"vitest": "^2.0.1"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
Loading

0 comments on commit 8eb3fa4

Please sign in to comment.