PEt*_*ter 9 javascript code-splitting esbuild
我正在使用 esbuild 来使用 lit 构建我的 Web 组件。
我现在正在研究code splitting如何缩小我的包裹。
我生成了很多组件(~100),它们都具有相同的导入语句
import { LitElement, html, nothing } from "lit";
import { customElement, property } from 'lit/decorators.js';
Run Code Online (Sandbox Code Playgroud)
最终将 lit 中的代码导入到我的所有组件中。
添加
chunkNames: 'chunks/[name]-[hash]',
splitting: true,
format: 'esm',
Run Code Online (Sandbox Code Playgroud)
esbuild 配置使 esbuild 创建包含导入文件内容的“块”,并使每个包变得更小。正是我正在寻找的:)
但..
我导入的一些文件不在组件之间共享,只是将组件拆分为更多文件以使其更具可读性。
是否可以告诉 esbuild“不要创建此文件的块,只需将其捆绑到当前入口点”?
import { LitElement, html, nothing } from "lit"; //<-- Create a chunk of this
import { customElement, property } from 'lit/decorators.js';//<-- Create a chunk of this
import { ComponentViewModel } from './ViewModel'; //<--bundle this
import { ActiveKeysFromIndexTypeRESTApi } from './DataFromRESTApi'; //<--bundle this
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2758 次 |
| 最近记录: |