Skip to content

Commit

Permalink
test: asset.name
Browse files Browse the repository at this point in the history
  • Loading branch information
Timeless0911 committed Sep 19, 2024
1 parent 3131e71 commit 7356978
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 36 deletions.
72 changes: 36 additions & 36 deletions e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,39 @@ Rslib will try to cover the common scenarios in the [integration test cases of M
| --------- | ----------------- | ------------ | ---------------- |
| 🟢 | 🟡 | ⚪️ | ⚫️ |

| Feature | Status | Note |
| --------------- | ------ | ---------------------------------------------------------------------------------------------------- |
| alias | 🟢 | |
| asset | ⚪️ | |
| autoExtension | 🟢 | |
| autoExternal | 🟢 | |
| banner-footer | 🟢 | |
| buildType | 🟢 | |
| copy | 🟢 | |
| decorator | 🟢 | |
| define | 🟢 | |
| dts | 🟢 | |
| dts-composite | ⚪️ | |
| esbuildOptions | ⚫️ | |
| externals | 🟢 | |
| format | 🟡 | Support `cjs` and `esm`, `umd` still need to be tested |
| input | 🟢 | |
| jsx | ⚪️ | |
| metafile | ⚫️ | |
| minify | 🟢 | |
| platform | 🟢 | |
| redirect | ⚪️ | |
| resolve | 🟢 | |
| shims | 🟡 | Support shims `__filename` and `__dirname` in esm</br> `import.meta.url` in cjs need to be supported |
| sideEffects | ⚪️ | |
| sourceDir | 🟢 | |
| sourceMap | 🟢 | |
| splitting | ⚪️ | |
| style | ⚪️ | |
| target | 🟢 | |
| transformImport | 🟢 | |
| transformLodash | 🟢 | |
| tsconfig | 🟢 | |
| tsconfigExtends | 🟢 | |
| umdGlobals | ⚪️ | |
| umdModuleName | ⚪️ | |
| Feature | Status | Note |
| --------------- | ------ | ------------------------------------------------------ |
| alias | 🟢 | |
| asset | ⚪️ | |
| autoExtension | 🟢 | |
| autoExternal | 🟢 | |
| banner-footer | 🟢 | |
| buildType | 🟢 | |
| copy | 🟢 | |
| decorator | 🟢 | |
| define | 🟢 | |
| dts | 🟢 | |
| dts-composite | ⚪️ | |
| esbuildOptions | ⚫️ | |
| externals | 🟢 | |
| format | 🟡 | Support `cjs` and `esm`, `umd` still need to be tested |
| input | 🟢 | |
| jsx | ⚪️ | |
| metafile | ⚫️ | |
| minify | 🟢 | |
| platform | 🟢 | |
| redirect | ⚪️ | |
| resolve | 🟢 | |
| shims | 🟢 | |
| sideEffects | ⚪️ | |
| sourceDir | 🟢 | |
| sourceMap | 🟢 | |
| splitting | ⚪️ | |
| style | ⚪️ | |
| target | 🟢 | |
| transformImport | 🟢 | |
| transformLodash | 🟢 | |
| tsconfig | 🟢 | |
| tsconfigExtends | 🟢 | |
| umdGlobals | ⚪️ | |
| umdModuleName | ⚪️ | |
14 changes: 14 additions & 0 deletions e2e/cases/asset/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,18 @@ test('should be able to set the size threshold to inline static assets', async (
expect(entries.esm1).toContain(
'const logo_namespaceObject = __webpack_require__.p + "static/svg/logo.svg";',
);

// TODO: bundleless
});

test('should be able to set the assets name', async () => {
const fixturePath = join(__dirname, 'name');
const { entries } = await buildAndGetResults(fixturePath);

// bundle
expect(entries.esm).toContain(
'const a_namespaceObject = __webpack_require__.p + "static/image/a.36140d29.png";',
);

// TODO: bundleless
});
12 changes: 12 additions & 0 deletions e2e/cases/asset/name/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "asset-name-test",
"version": "1.0.0",
"private": true,
"type": "module",
"dependencies": {
"react": "^18.3.1"
},
"devDependencies": {
"@rsbuild/plugin-react": "^1.0.2"
}
}
24 changes: 24 additions & 0 deletions e2e/cases/asset/name/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { generateBundleEsmConfig } from '@e2e/helper';
import { pluginReact } from '@rsbuild/plugin-react';
import { defineConfig } from '@rslib/core';

export default defineConfig({
lib: [
generateBundleEsmConfig({
output: {
distPath: {
root: './dist/esm/bundle',
},
filename: {
image: '[name].[contenthash:8][ext]',
},
},
}),
],
source: {
entry: {
index: './src/index.jsx',
},
},
plugins: [pluginReact()],
});
Binary file added e2e/cases/asset/name/src/a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions e2e/cases/asset/name/src/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import a from './a.png';

export default () => {
return <img src={a} alt="" />;
};
10 changes: 10 additions & 0 deletions pnpm-lock.yaml

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

0 comments on commit 7356978

Please sign in to comment.