Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

183
Visualizações
Rollup unexpectedly generates a file for reactive state

I'm kinda of new to rollup, and been having several issues with it over the last couple of weeks.

I'm currently using rollup to build Lit components to production. And for some unknown reason, when it generates a file which contains, what I believe is the reactive state for every component - query-assigned-elements-78bcb1b1.js. Every component that has reactive state then imports this file.

I need to do not output this file, and keep the state in the actual files, since the components needs to be used alone, without any dependencies and imports.

rollup-config.mjs:

...

export default (args) => {
  const isProd = args.prod ? true : false;
  const isDev = args.dev ? true : false;

  console.log(
    `Building ${
      isProd ? 'production' : isDev ? 'development' : 'local'
    } build..`
  );
  const distProd = 'dist';
  const distDev = 'dev/dist';
  const distLocal = 'dev/components';
  let envPath = isProd ? distProd : isDev ? distDev : distLocal;
  let build = [
    {
      input: ['src/**/[!_]*.ts'],
      output: {
        dir: envPath,
      },
      plugins: [
        resolve(),
        multiInput.default({
          relative: 'src/',
        }),
        commonjs(),
        typescript({
          compilerOptions: {
            outDir: envPath,
            sourceMap: false,
            declaration: false,
            declarationMap: false,
            inlineSources: false,
          },
        }),
        template(),
        terser({
          ecma: 2017,
          module: true,
          warnings: true,
        }),
        copy({
          patterns: '**/assets/*.{svg,png,jpg,gif,webp}',
          rootDir: './src',
        }),
      ],
      preserveEntrySignatures: 'strict',
    },
  ];
  return build;
};

Every component then has import{r as t,_ as e,e as o,n as i,s as r,$ as a}from"../query-assigned-elements-78bcb1b1.js";. Any suggestions would be greatly appreciated.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The issue appears to occur when the input of the rollup config is too broad:

input: ['src/**/[!_]*.ts']

If each individual lit element is placed in its own separate folder, rollup needs to be applied to each lit element individually. If rollup input is too broad (in the sense that it takes all elements as an input), it will see that the given dependency (query-assigned-elements) is used across all of the given elements, and instead of embedding it individually in each file, it creates a separate external file (query-assigned-elements-78bcb1b1.js) and references is in import.

Changing input to something like

 input: ['./src/<element-folder>/[!_]*.ts']

and running rollup for each element separately fixes the issue.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda