Skip to content
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
17 changes: 14 additions & 3 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,12 @@ const traverseEntryQuery = (
export const appendEntryQuery = (entries: RsbuildConfigEntry): RsbuildEntry =>
traverseEntryQuery(entries, (item) => `${item}?${RSLIB_ENTRY_QUERY}`);

export const resolveEntryPath = (
entries: RsbuildConfigEntry,
root: string,
): RsbuildEntry =>
traverseEntryQuery(entries, (item) => path.resolve(root, item));

const composeEntryConfig = async (
rawEntry: RsbuildConfigEntry,
bundle: LibConfig['bundle'],
Expand Down Expand Up @@ -939,7 +945,7 @@ const composeEntryConfig = async (
return {
entryConfig: {
source: {
entry: appendEntryQuery(entries),
entry: appendEntryQuery(resolveEntryPath(entries, root)),
},
},
lcp: null,
Expand Down Expand Up @@ -1044,6 +1050,7 @@ const composeBundlelessExternalConfig = (
redirect: Redirect,
cssModulesAuto: CssLoaderOptionsAuto,
bundle: boolean,
rootPath: string,
): {
config: EnvironmentConfig;
resolvedJsRedirect?: DeepRequired<JsRedirect>;
Expand Down Expand Up @@ -1083,9 +1090,12 @@ const composeBundlelessExternalConfig = (
let resolvedRequest = request;
// use resolver to resolve the request
resolvedRequest = await resolver!(context!, resolvedRequest);
const isSubpath = resolvedRequest.startsWith(
rootPath + path.sep,
);

// only handle the request that is not in node_modules
if (!resolvedRequest.includes('node_modules')) {
// only handle the request that within the root path
if (isSubpath) {
resolvedRequest = normalizeSlash(
path.relative(path.dirname(issuer), resolvedRequest),
);
Expand Down Expand Up @@ -1359,6 +1369,7 @@ async function composeLibRsbuildConfig(
redirect,
cssModulesAuto,
bundle,
rootPath,
);
const {
config: targetConfig,
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions scripts/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ icss
idents
iife
imagex
importee
jfif
jiti
jscpuprofile
Expand Down
File renamed without changes
2 changes: 1 addition & 1 deletion tests/integration/asset/limit/src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import logo from '../../../../assets/logo.svg';
import logo from '../assets/logo.svg';

export default logo;
File renamed without changes
2 changes: 1 addition & 1 deletion tests/integration/asset/name/src/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import a from '../../../../assets/image.png';
import a from '../assets/image.png';

export default () => {
return <img src={a} alt="" />;
Expand Down
Binary file added tests/integration/asset/path/assets/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/integration/asset/path/src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import a from '../../../../assets/image.png';
import a from '../assets/image.png';

export default a;
7 changes: 7 additions & 0 deletions tests/integration/asset/public-path/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/integration/asset/public-path/src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import logo from '../../../../assets/logo.svg';
import logo from '../assets/logo.svg';

export default logo;
7 changes: 7 additions & 0 deletions tests/integration/asset/svgr/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/integration/asset/svgr/src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import logo from '../../../../assets/logo.svg?react';
import logo from '../assets/logo.svg?react';

console.log(logo);
2 changes: 1 addition & 1 deletion tests/integration/asset/svgr/src/namedExport.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { ReactComponent } from '../../../../assets/logo.svg';
import { ReactComponent } from '../assets/logo.svg';

console.log(ReactComponent);
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions tests/integration/bundle-false/asset/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions tests/integration/bundle-false/asset/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import image from '../../../../assets/image.png';
import logoURL from '../../../../assets/logo.svg';
import image from '../assets/image.png';
import logoURL from '../assets/logo.svg';

console.log(logoURL);
console.log(image);
15 changes: 15 additions & 0 deletions tests/integration/bundle-false/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,21 @@ test('basic', async () => {
`);
});

test('monorepo', async () => {
const fixturePath = join(__dirname, 'monorepo/importer');
const { contents } = await buildAndGetResults({ fixturePath });
expect(
queryContent(contents.esm, 'index.js', {
basename: true,
}).content,
).toMatchInlineSnapshot(`
"import * as __WEBPACK_EXTERNAL_MODULE_bundle_false_monorepo_importee_test_35ca595f__ from "bundle-false-monorepo-importee-test";
const src_rslib_entry_ = __WEBPACK_EXTERNAL_MODULE_bundle_false_monorepo_importee_test_35ca595f__["default"];
export { src_rslib_entry_ as default };
"
`);
});

test('single file', async () => {
const fixturePath = join(__dirname, 'single-file');
const { files } = await buildAndGetResults({ fixturePath });
Expand Down
1 change: 1 addition & 0 deletions tests/integration/bundle-false/monorepo/importee/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'importee';
7 changes: 7 additions & 0 deletions tests/integration/bundle-false/monorepo/importee/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "bundle-false-monorepo-importee-test",
"version": "1.0.0",
"private": true,
"type": "module",
"main": "./index.js"
}
9 changes: 9 additions & 0 deletions tests/integration/bundle-false/monorepo/importer/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "bundle-false-monorepo-importer-test",
"version": "1.0.0",
"private": true,
"type": "module",
"dependencies": {
"bundle-false-monorepo-importee-test": "workspace:*"
}
}
18 changes: 18 additions & 0 deletions tests/integration/bundle-false/monorepo/importer/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { defineConfig } from '@rslib/core';
import { generateBundleCjsConfig, generateBundleEsmConfig } from 'test-helper';

export default defineConfig({
lib: [
generateBundleEsmConfig({
bundle: false,
}),
generateBundleCjsConfig({
bundle: false,
}),
],
source: {
entry: {
index: ['./src/**'],
},
},
});
3 changes: 3 additions & 0 deletions tests/integration/bundle-false/monorepo/importer/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import importee from 'bundle-false-monorepo-importee-test';

export default importee;
7 changes: 7 additions & 0 deletions tests/integration/bundle-false/svgr/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/integration/bundle-false/svgr/src/index.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import Logo from '../../../../assets/logo.svg?react';
import Logo from '../assets/logo.svg?react';

export default Logo;
4 changes: 1 addition & 3 deletions tests/integration/redirect/js-not-resolve/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ import prettier from 'prettier';
import bar from './bar.js';
import foo from './foo';

console.log('prettier: ', prettier);

export default lodash.toUpper(foo + bar);
export default lodash.toUpper(foo + bar + prettier.version);
Loading
Loading