web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.2 KiB

  1. # dynamic imports require a leading comment with a webpackChunkName (dynamic-import-chunkname)
  2. This rule reports any dynamic imports without a webpackChunkName specified in a leading block comment in the proper format.
  3. This rule enforces naming of webpack chunks in dynamic imports. When you don't explicitly name chunks, webpack will autogenerate chunk names that are not consistent across builds, which prevents long-term browser caching.
  4. ## Rule Details
  5. This rule runs against `import()` by default, but can be configured to also run against an alternative dynamic-import function, e.g. 'dynamicImport.'
  6. You can also configure the regex format you'd like to accept for the webpackChunkName - for example, if we don't want the number 6 to show up in our chunk names:
  7. ```javascript
  8. {
  9. "dynamic-import-chunkname": [2, {
  10. importFunctions: ["dynamicImport"],
  11. webpackChunknameFormat: "[a-zA-Z0-57-9-/_]+"
  12. }]
  13. }
  14. ```
  15. ### invalid
  16. The following patterns are invalid:
  17. ```javascript
  18. // no leading comment
  19. import('someModule');
  20. // incorrectly formatted comment
  21. import(
  22. /*webpackChunkName:"someModule"*/
  23. 'someModule',
  24. );
  25. import(
  26. /* webpackChunkName : "someModule" */
  27. 'someModule',
  28. );
  29. // chunkname contains a 6 (forbidden by rule config)
  30. import(
  31. /* webpackChunkName: "someModule6" */
  32. 'someModule',
  33. );
  34. // invalid syntax for webpack comment
  35. import(
  36. /* totally not webpackChunkName: "someModule" */
  37. 'someModule',
  38. );
  39. // single-line comment, not a block-style comment
  40. import(
  41. // webpackChunkName: "someModule"
  42. 'someModule',
  43. );
  44. ```
  45. ### valid
  46. The following patterns are valid:
  47. ```javascript
  48. import(
  49. /* webpackChunkName: "someModule" */
  50. 'someModule',
  51. );
  52. import(
  53. /* webpackChunkName: "someOtherModule12345789" */
  54. 'someModule',
  55. );
  56. import(
  57. /* webpackChunkName: "someModule" */
  58. /* webpackPrefetch: true */
  59. 'someModule',
  60. );
  61. import(
  62. /* webpackChunkName: "someModule", webpackPrefetch: true */
  63. 'someModule',
  64. );
  65. // using single quotes instead of double quotes
  66. import(
  67. /* webpackChunkName: 'someModule' */
  68. 'someModule',
  69. );
  70. ```
  71. ## When Not To Use It
  72. If you don't care that webpack will autogenerate chunk names and may blow up browser caches and bundle size reports.