1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

auraフレームワークのToo many components

Posted at

確認したバージョン
https://github.com/forcedotcom/aura/tree/7fc7016ab808cbf21587940f939fbba79d23a80d

この例外が生成されている場所は

追加されたのは
https://github.com/forcedotcom/aura/commit/d690b578e7d30655689f3225fed8e64f0882cd65#diff-b9484b824eca9d4b5c617f2edfc89a7eR684

制限としては10000コンポーネントなので結構遠そうに見えるけど、
タグとテキストについてほぼ全部計上されるっぽく、割とすぐ到達する気がする。

例えば <div></div> は1コンポーネントだが、
<div>foo</div>は2コンポーネント
<div>foo<br />bar</div>は4コンポーネントになる。

以下のdeployタスクでループ回数を5000にするとエラーになった。


package.json

{
  "devDependencies": {
    "btoa": "^1.1.2",
    "gulp": "^3.9.0",
    "gulp-file": "^0.2.0",
    "gulp-jsforce-deploy": "^1.1.1",
    "gulp-zip": "^3.0.2",
    "salesforce-metadata-xml-builder": "^0.1.1",
    "through2": "^2.0.1"
  }
}

gulpfile.js

const gulp = require('gulp');
const through = require('through2');
const zip = require('gulp-zip');
const file = require('gulp-file');
const deploy = require('gulp-jsforce-deploy');
const metadata = require('salesforce-metadata-xml-builder');
const btoa = require('btoa');

const COMPONENT_NAME = 'TooManyComponents';
const API_VERSION = '36.0';
const SF_USERNAME = process.env.SF_USERNAME;
const SF_PASSWORD = process.env.SF_PASSWORD;

function makeComponentUrl(componentName) {
  var hash = btoa(JSON.stringify({
    componentDef: 'one:auraContainer',
    attributes: {
      values: {
        tag: 'c:' + componentName,
        t: Date.now()
      }
    }
  }));
  return '/one/one.app#' + hash;
}

gulp.task('deploy', () => {

  const html = Array.apply(null, new Array(4999)).map((_, i) => `<div>${i}</div>`).join('')
  const componentBody = `<aura:component>
    ${html}
  </aura:component>`;
  const packagexml = metadata.Package({ version: API_VERSION, types: [
    { name: 'AuraDefinitionBundle', members: ['*'] },
  ]});

  return through.obj()
    .pipe(file(`src/aura/${COMPONENT_NAME}/${COMPONENT_NAME}.cmp`, componentBody, {src: true}))
    .pipe(file('src/package.xml', packagexml))
    // .pipe(gulp.dest('./tmp'))
    .pipe(zip('pkg.zip'))
    .pipe(deploy({
      username: SF_USERNAME,
      password: SF_PASSWORD
    }))
    .on('end', () => {
      console.log('URL:' + makeComponentUrl(COMPONENT_NAME));
    });

});

また、別コンポーネントの呼び出しについても確認した。

gulp.task('deploy2', () => {

  const html = `<c:${COMPONENT_NAME}2 />`.repeat(3333);
  const componentBody = `<aura:component>
    ${html}
  </aura:component>`;
  const component2Body = `<aura:component>a</aura:component>`;
  const packagexml = metadata.Package({ version: API_VERSION, types: [
    { name: 'AuraDefinitionBundle', members: ['*'] },
  ]});

  return through.obj()
    .pipe(file(`src/aura/${COMPONENT_NAME}/${COMPONENT_NAME}.cmp`, componentBody, {src: true}))
    .pipe(file(`src/aura/${COMPONENT_NAME}2/${COMPONENT_NAME}2.cmp`, component2Body))
    .pipe(file('src/package.xml', packagexml))
    .pipe(zip('pkg.zip'))
    .pipe(deploy({
      username: SF_USERNAME,
      password: SF_PASSWORD
    }))
    .on('error', console.log.bind(console))
    .on('end', () => {
      console.log('URL:' + makeComponentUrl(COMPONENT_NAME));
    });

});

3334ループでエラーになったので、ループの中身は3コンポーネントとしてカウントされていることになる。
他コンポーネントの呼び出しか、子コンポーネントのaura:componentタグでも1カウントされているのだろうか。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?