diff --git a/docs/05-plugin-development.md b/docs/05-plugin-development.md
index 2610c7f119c..a7b5da7cfde 100644
--- a/docs/05-plugin-development.md
+++ b/docs/05-plugin-development.md
@@ -236,12 +236,12 @@ Output generation hooks can provide information about a generated bundle and mod
The first hook of the output generation phase is [outputOptions](guide/en/#outputoptions), the last one is either [generateBundle](guide/en/#generatebundle) if the output was successfully generated via `bundle.generate(...)`, [writeBundle](guide/en/#writebundle) if the output was successfully generated via `bundle.write(...)`, or [renderError](guide/en/#rendererror) if an error occurred at any time during the output generation.
#### `augmentChunkHash`
-Type: `(preRenderedChunk: PreRenderedChunk) => string`
+Type: `(chunkInfo: ChunkInfo) => string`
Kind: `sync, sequential`
Previous Hook: [`renderDynamicImport`](guide/en/#renderdynamicimport) for each dynamic import expression.
Next Hook: [`resolveFileUrl`](guide/en/#resolvefileurl) for each use of `import.meta.ROLLUP_FILE_URL_referenceId` and [`resolveImportMeta`](guide/en/#resolveimportmeta) for all other accesses to `import.meta`.
-Can be used to augment the hash of individual chunks. Called for each Rollup output chunk. Returning a falsy value will not modify the hash. Truthy values will be passed to [`hash.update`](https://nodejs.org/dist/latest-v12.x/docs/api/crypto.html#crypto_hash_update_data_inputencoding).
+Can be used to augment the hash of individual chunks. Called for each Rollup output chunk. Returning a falsy value will not modify the hash. Truthy values will be passed to [`hash.update`](https://nodejs.org/dist/latest-v12.x/docs/api/crypto.html#crypto_hash_update_data_inputencoding). The `chunkInfo` is a reduced version of the one in [`generateBundle`](guide/en/#generatebundle) without properties that rely on file names.
The following plugin will invalidate the hash of chunk `foo` with the timestamp of the last build:
@@ -282,6 +282,7 @@ Called at the end of `bundle.generate()` or immediately before the files are wri
// AssetInfo
{
fileName: string,
+ name?: string,
source: string | Uint8Array,
type: 'asset',
}
diff --git a/docs/999-big-list-of-options.md b/docs/999-big-list-of-options.md
index 52870464e0d..371d715de3d 100755
--- a/docs/999-big-list-of-options.md
+++ b/docs/999-big-list-of-options.md
@@ -359,17 +359,19 @@ export default {
#### output.assetFileNames
-Type: `string`
+Type: `string | ((assetInfo: AssetInfo) => string)`
CLI: `--assetFileNames `
Default: `"assets/[name]-[hash][extname]"`
-The pattern to use for naming custom emitted assets to include in the build output. Pattern supports the following placeholders:
+The pattern to use for naming custom emitted assets to include in the build output, or a function that is called per asset to return such a pattern. Patterns support the following placeholders:
* `[extname]`: The file extension of the asset including a leading dot, e.g. `.css`.
* `[ext]`: The file extension without a leading dot, e.g. `css`.
* `[hash]`: A hash based on the name and content of the asset.
* `[name]`: The file name of the asset excluding any extension.
-Forward slashes `/` can be used to place files in sub-directories. See also [`output.chunkFileNames`](guide/en/#outputchunkfilenames), [`output.entryFileNames`](guide/en/#outputentryfilenames).
+Forward slashes `/` can be used to place files in sub-directories. When using a function, `assetInfo` is a reduced version of the one in [`generateBundle`](guide/en/#generatebundle) without the `fileName`. See also [`output.chunkFileNames`](guide/en/#outputchunkfilenames), [`output.entryFileNames`](guide/en/#outputentryfilenames).
+
+You can also supply a function that returns a pattern as string.
#### output.banner/output.footer
Type: `string | (() => string | Promise)`
@@ -392,16 +394,18 @@ export default {
See also [`output.intro/output.outro`](guide/en/#outputintrooutputoutro).
#### output.chunkFileNames
-Type: `string`
+Type: `string | ((chunkInfo: ChunkInfo) => string)`
CLI: `--chunkFileNames `
Default: `"[name]-[hash].js"`
-The pattern to use for naming shared chunks created when code-splitting. Pattern supports the following placeholders:
+The pattern to use for naming shared chunks created when code-splitting, or a function that is called per chunk to return such a pattern. Patterns support the following placeholders:
* `[format]`: The rendering format defined in the output options, e.g. `es` or `cjs`.
* `[hash]`: A hash based on the content of the chunk and the content of all its dependencies.
* `[name]`: The name of the chunk. This can be explicitly set via the [`output.manualChunks`](guide/en/#outputmanualchunks) option or when the chunk is created by a plugin via [`this.emitFile`](guide/en/#thisemitfileemittedfile-emittedchunk--emittedasset--string). Otherwise it will be derived from the chunk contents.
-Forward slashes `/` can be used to place files in sub-directories. See also [`output.assetFileNames`](guide/en/#outputassetfilenames), [`output.entryFileNames`](guide/en/#outputentryfilenames).
+Forward slashes `/` can be used to place files in sub-directories. When using a function, `chunkInfo` is a reduced version of the one in [`generateBundle`](guide/en/#generatebundle) without properties that depend on file names. See also [`output.assetFileNames`](guide/en/#outputassetfilenames), [`output.entryFileNames`](guide/en/#outputentryfilenames).
+
+You can also supply a function that returns a pattern as string.
#### output.compact
Type: `boolean`
@@ -411,16 +415,16 @@ Default: `false`
This will minify the wrapper code generated by rollup. Note that this does not affect code written by the user. This option is useful when bundling pre-minified code.
#### output.entryFileNames
-Type: `string`
+Type: `string | ((chunkInfo: ChunkInfo) => string)`
CLI: `--entryFileNames `
Default: `"[name].js"`
-The pattern to use for chunks created from entry points. Pattern supports the following placeholders:
+The pattern to use for chunks created from entry points, or a function that is called per entry chunk to return such a pattern. Patterns support the following placeholders:
* `[format]`: The rendering format defined in the output options, e.g. `es` or `cjs`.
* `[hash]`: A hash based on the content of the entry point and the content of all its dependencies.
* `[name]`: The file name (without extension) of the entry point, unless the object form of input was used to define a different name.
-Forward slashes `/` can be used to place files in sub-directories. See also [`output.assetFileNames`](guide/en/#outputassetfilenames), [`output.chunkFileNames`](guide/en/#outputchunkfilenames).
+Forward slashes `/` can be used to place files in sub-directories. When using a function, `chunkInfo` is a reduced version of the one in [`generateBundle`](guide/en/#generatebundle) without properties that depend on file names. See also [`output.assetFileNames`](guide/en/#outputassetfilenames), [`output.chunkFileNames`](guide/en/#outputchunkfilenames).
This pattern will also be used when using the [`output.preserveModules`](guide/en/#outputpreservemodules) option. Here there is a different set of placeholders available, though:
* `[format]`: The rendering format defined in the output options.
@@ -428,6 +432,8 @@ This pattern will also be used when using the [`output.preserveModules`](guide/e
* `[ext]`: The extension of the file.
* `[extname]`: The extension of the file, prefixed by `.` if it is not empty.
+You can also supply a function that returns a pattern as string.
+
#### output.extend
Type: `boolean`
CLI: `--extend`/`--no-extend`
diff --git a/src/Bundle.ts b/src/Bundle.ts
index d66eace0925..62e77270e01 100644
--- a/src/Bundle.ts
+++ b/src/Bundle.ts
@@ -84,7 +84,7 @@ export default class Bundle {
for (const chunk of chunks) {
const chunkDescription = (outputBundle[
chunk.id!
- ] = chunk.getPrerenderedChunk() as OutputChunk);
+ ] = chunk.getChunkInfoWithFileNames() as OutputChunk);
chunkDescription.fileName = chunk.id!;
}
await Promise.all(
diff --git a/src/Chunk.ts b/src/Chunk.ts
index dfa43a94543..05142fbe7be 100644
--- a/src/Chunk.ts
+++ b/src/Chunk.ts
@@ -387,19 +387,24 @@ export default class Chunk {
? [options.entryFileNames, 'output.entryFileNames']
: [options.chunkFileNames, 'output.chunkFileNames'];
return makeUnique(
- renderNamePattern(pattern, patternName, {
- format: () => options.format,
- hash: () =>
- includeHash
- ? this.computeContentHashWithDependencies(
- addons,
- options,
- existingNames,
- outputPluginDriver
- )
- : '[hash]',
- name: () => this.getChunkName()
- }),
+ renderNamePattern(
+ pattern,
+ patternName,
+ {
+ format: () => options.format,
+ hash: () =>
+ includeHash
+ ? this.computeContentHashWithDependencies(
+ addons,
+ options,
+ existingNames,
+ outputPluginDriver
+ )
+ : '[hash]',
+ name: () => this.getChunkName()
+ },
+ this.getChunkInfo.bind(this)
+ ),
existingNames
);
}
@@ -422,12 +427,17 @@ export default class Chunk {
: options.entryFileNames;
path = relative(
preserveModulesRelativeDir,
- `${dirname(sanitizedId)}/${renderNamePattern(pattern, 'output.entryFileNames', {
- ext: () => extension.substr(1),
- extname: () => extension,
- format: () => options.format as string,
- name: () => this.getChunkName()
- })}`
+ `${dirname(sanitizedId)}/${renderNamePattern(
+ pattern,
+ 'output.entryFileNames',
+ {
+ ext: () => extension.substr(1),
+ extname: () => extension,
+ format: () => options.format as string,
+ name: () => this.getChunkName()
+ },
+ this.getChunkInfo.bind(this)
+ )}`
);
} else {
path = `_virtual/${basename(sanitizedId)}`;
@@ -435,31 +445,15 @@ export default class Chunk {
return makeUnique(normalize(path), existingNames);
}
- getChunkName(): string {
- return this.name || (this.name = sanitizeFileName(this.getFallbackChunkName()));
- }
-
- getExportNames(): string[] {
- return (
- this.sortedExportNames || (this.sortedExportNames = Object.keys(this.exportsByName!).sort())
- );
- }
-
- getPrerenderedChunk(): PreRenderedChunk {
+ getChunkInfo(): PreRenderedChunk {
const facadeModule = this.facadeModule;
const getChunkName = this.getChunkName.bind(this);
return {
- code: undefined,
- dynamicImports: Array.from(this.dynamicDependencies, getId),
exports: this.getExportNames(),
facadeModuleId: facadeModule && facadeModule.id,
- fileName: undefined,
- implicitlyLoadedBefore: Array.from(this.implicitlyLoadedBefore, getId),
- imports: Array.from(this.dependencies, getId),
isDynamicEntry: this.dynamicEntryModules.length > 0,
isEntry: facadeModule !== null && facadeModule.isEntryPoint,
isImplicitEntry: this.implicitEntryModules.length > 0,
- map: undefined,
modules: this.renderedModules!,
get name() {
return getChunkName();
@@ -468,13 +462,34 @@ export default class Chunk {
};
}
+ getChunkInfoWithFileNames(): RenderedChunk {
+ return Object.assign(this.getChunkInfo(), {
+ code: undefined,
+ dynamicImports: Array.from(this.dynamicDependencies, getId),
+ fileName: this.id!,
+ implicitlyLoadedBefore: Array.from(this.implicitlyLoadedBefore, getId),
+ imports: Array.from(this.dependencies, getId),
+ map: undefined
+ });
+ }
+
+ getChunkName(): string {
+ return this.name || (this.name = sanitizeFileName(this.getFallbackChunkName()));
+ }
+
+ getExportNames(): string[] {
+ return (
+ this.sortedExportNames || (this.sortedExportNames = Object.keys(this.exportsByName!).sort())
+ );
+ }
+
getRenderedHash(outputPluginDriver: PluginDriver): string {
if (this.renderedHash) return this.renderedHash;
const hash = createHash();
const hashAugmentation = outputPluginDriver.hookReduceValueSync(
'augmentChunkHash',
'',
- [this.getPrerenderedChunk()],
+ [this.getChunkInfo()],
(hashAugmentation, pluginHash) => {
if (pluginHash) {
hashAugmentation += pluginHash;
diff --git a/src/rollup/types.d.ts b/src/rollup/types.d.ts
index f01ae76dc48..d89121a1f14 100644
--- a/src/rollup/types.d.ts
+++ b/src/rollup/types.d.ts
@@ -545,15 +545,15 @@ export interface OutputOptions {
define?: string;
id?: string;
};
- assetFileNames?: string;
+ assetFileNames?: string | ((chunkInfo: PreRenderedAsset) => string);
banner?: string | (() => string | Promise);
- chunkFileNames?: string;
+ chunkFileNames?: string | ((chunkInfo: PreRenderedChunk) => string);
compact?: boolean;
// only required for bundle.write
dir?: string;
/** @deprecated Use the "renderDynamicImport" plugin hook instead. */
dynamicImportFunction?: string;
- entryFileNames?: string;
+ entryFileNames?: string | ((chunkInfo: PreRenderedChunk) => string);
esModule?: boolean;
exports?: 'default' | 'named' | 'none' | 'auto';
extend?: boolean;
@@ -592,14 +592,14 @@ export interface NormalizedOutputOptions {
define: string;
id?: string;
};
- assetFileNames: string;
+ assetFileNames: string | ((chunkInfo: PreRenderedAsset) => string);
banner: () => string | Promise;
- chunkFileNames: string;
+ chunkFileNames: string | ((chunkInfo: PreRenderedChunk) => string);
compact: boolean;
dir: string | undefined;
/** @deprecated Use the "renderDynamicImport" plugin hook instead. */
dynamicImportFunction: string | undefined;
- entryFileNames: string;
+ entryFileNames: string | ((chunkInfo: PreRenderedChunk) => string);
esModule: boolean;
exports: 'default' | 'named' | 'none' | 'auto';
extend: boolean;
@@ -642,12 +642,16 @@ export interface SerializedTimings {
[label: string]: [number, number, number];
}
-export interface OutputAsset {
+export interface PreRenderedAsset {
+ name: string | undefined;
+ source: string | Uint8Array;
+ type: 'asset';
+}
+
+export interface OutputAsset extends PreRenderedAsset {
fileName: string;
/** @deprecated Accessing "isAsset" on files in the bundle is deprecated, please use "type === \'asset\'" instead */
isAsset: true;
- source: string | Uint8Array;
- type: 'asset';
}
export interface RenderedModule {
@@ -658,17 +662,11 @@ export interface RenderedModule {
}
export interface PreRenderedChunk {
- code?: string;
- dynamicImports: string[];
exports: string[];
facadeModuleId: string | null;
- fileName?: string;
- implicitlyLoadedBefore: string[];
- imports: string[];
isDynamicEntry: boolean;
isEntry: boolean;
isImplicitEntry: boolean;
- map?: SourceMap;
modules: {
[id: string]: RenderedModule;
};
@@ -677,13 +675,16 @@ export interface PreRenderedChunk {
}
export interface RenderedChunk extends PreRenderedChunk {
+ code?: string;
+ dynamicImports: string[];
fileName: string;
+ implicitlyLoadedBefore: string[];
+ imports: string[];
+ map?: SourceMap;
}
export interface OutputChunk extends RenderedChunk {
code: string;
- map?: SourceMap;
- type: 'chunk';
}
export interface SerializablePluginCache {
diff --git a/src/utils/FileEmitter.ts b/src/utils/FileEmitter.ts
index ac5f6204ff1..3c6fd1aa284 100644
--- a/src/utils/FileEmitter.ts
+++ b/src/utils/FileEmitter.ts
@@ -6,6 +6,7 @@ import {
FilePlaceholder,
NormalizedInputOptions,
OutputBundleWithPlaceholders,
+ PreRenderedAsset,
WarningHandler
} from '../rollup/types';
import { BuildPhase } from './buildPhase';
@@ -28,7 +29,7 @@ import { isPlainPathFragment } from './relativeId';
import { makeUnique, renderNamePattern } from './renderNamePattern';
interface OutputSpecificFileData {
- assetFileNames: string;
+ assetFileNames: string | ((assetInfo: PreRenderedAsset) => string);
bundle: OutputBundleWithPlaceholders;
}
@@ -39,18 +40,23 @@ function generateAssetFileName(
): string {
const emittedName = name || 'asset';
return makeUnique(
- renderNamePattern(output.assetFileNames, 'output.assetFileNames', {
- hash() {
- const hash = createHash();
- hash.update(emittedName);
- hash.update(':');
- hash.update(source);
- return hash.digest('hex').substr(0, 8);
+ renderNamePattern(
+ output.assetFileNames,
+ 'output.assetFileNames',
+ {
+ hash() {
+ const hash = createHash();
+ hash.update(emittedName);
+ hash.update(':');
+ hash.update(source);
+ return hash.digest('hex').substr(0, 8);
+ },
+ ext: () => extname(emittedName).substr(1),
+ extname: () => extname(emittedName),
+ name: () => emittedName.substr(0, emittedName.length - extname(emittedName).length)
},
- ext: () => extname(emittedName).substr(1),
- extname: () => extname(emittedName),
- name: () => emittedName.substr(0, emittedName.length - extname(emittedName).length)
- }),
+ () => ({ name, source, type: 'asset' })
+ ),
output.bundle
);
}
@@ -228,7 +234,7 @@ export class FileEmitter {
public setOutputBundle = (
outputBundle: OutputBundleWithPlaceholders,
- assetFileNames: string,
+ assetFileNames: string | ((assetInfo: PreRenderedAsset) => string),
facadeChunkByModule: Map
): void => {
this.output = {
@@ -334,6 +340,7 @@ export class FileEmitter {
const options = this.options;
output.bundle[fileName] = {
fileName,
+ name: consumedFile.name,
get isAsset(): true {
warnDeprecation(
'Accessing "isAsset" on files in the bundle is deprecated, please use "type === \'asset\'" instead',
diff --git a/src/utils/PluginDriver.ts b/src/utils/PluginDriver.ts
index 0444a4dd7a4..863a7a91ac1 100644
--- a/src/utils/PluginDriver.ts
+++ b/src/utils/PluginDriver.ts
@@ -14,6 +14,7 @@ import {
PluginContext,
PluginHooks,
PluginValueHooks,
+ PreRenderedAsset,
SequentialPluginHooks,
SerializablePluginCache,
SyncPluginHooks
@@ -70,7 +71,7 @@ export class PluginDriver {
public getFileName: (fileReferenceId: string) => string;
public setOutputBundle: (
outputBundle: OutputBundleWithPlaceholders,
- assetFileNames: string,
+ assetFileNames: string | ((assetInfo: PreRenderedAsset) => string),
facadeChunkByModule: Map
) => void;
diff --git a/src/utils/renderNamePattern.ts b/src/utils/renderNamePattern.ts
index 13690decc71..6dc62931b21 100644
--- a/src/utils/renderNamePattern.ts
+++ b/src/utils/renderNamePattern.ts
@@ -1,12 +1,18 @@
+import { PreRenderedAsset, PreRenderedChunk } from '../rollup/types';
import { errFailedValidation, error } from './error';
import { extname } from './path';
import { isPlainPathFragment } from './relativeId';
-export function renderNamePattern(
- pattern: string,
+export function renderNamePattern(
+ pattern: string | ((fileInfo: T) => string),
patternName: string,
- replacements: { [name: string]: () => string }
+ replacements: { [name: string]: () => string },
+ getFileInfo: () => T
) {
+ if (typeof pattern === 'function') {
+ pattern = pattern(getFileInfo());
+ }
+
if (!isPlainPathFragment(pattern))
return error(
errFailedValidation(
diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_config.js b/test/chunking-form/samples/emit-file/filenames-function-patterns/_config.js
new file mode 100644
index 00000000000..5fed7481d5a
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/filenames-function-patterns/_config.js
@@ -0,0 +1,70 @@
+const assert = require('assert');
+const path = require('path');
+
+const ID_MAIN = path.join(__dirname, 'main.js');
+const ID_DEB = path.join(__dirname, 'deb.js');
+
+module.exports = {
+ description: 'supports using a function that returns a pattern for FileNames',
+ options: {
+ input: ['main.js'],
+ plugins: {
+ transform() {
+ this.emitFile({ type: 'asset', name: 'test.txt', source: 'hello world' });
+ return null;
+ }
+ },
+ output: {
+ entryFileNames: fileInfo => {
+ // This is checked separately as deepStrictEqual is having some issues
+ assert.deepStrictEqual(Object.keys(fileInfo.modules), [ID_MAIN]);
+ delete fileInfo.modules;
+ assert.deepStrictEqual(
+ fileInfo,
+ {
+ exports: [],
+ facadeModuleId: ID_MAIN,
+ isDynamicEntry: false,
+ isEntry: true,
+ isImplicitEntry: false,
+ name: 'main',
+ type: 'chunk'
+ },
+ 'entry info'
+ );
+ return `entry-[name]-[hash]-[format].js`;
+ },
+ assetFileNames: fileInfo => {
+ assert.deepStrictEqual(
+ fileInfo,
+ {
+ name: 'test.txt',
+ source: 'hello world',
+ type: 'asset'
+ },
+ 'asset info'
+ );
+ return '[ext]/[hash]-[name][extname]';
+ },
+ chunkFileNames: fileInfo => {
+ // This is checked separately as deepStrictEqual is having some issues
+ assert.deepStrictEqual(Object.keys(fileInfo.modules), [ID_DEB]);
+ delete fileInfo.modules;
+ assert.deepStrictEqual(
+ fileInfo,
+ {
+ exports: ['default'],
+ facadeModuleId: ID_DEB,
+ isDynamicEntry: true,
+ isEntry: false,
+ isImplicitEntry: false,
+ name: 'deb',
+ type: 'chunk'
+ },
+ 'chunk info'
+ );
+ return 'chunk-[name]-[hash]-[format].js';
+ }
+ }
+ }
+};
diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/amd/chunk-deb-c542d45b-amd.js b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/amd/chunk-deb-c542d45b-amd.js
new file mode 100644
index 00000000000..1bc94d104bd
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/amd/chunk-deb-c542d45b-amd.js
@@ -0,0 +1,7 @@
+define(['exports'], function (exports) { 'use strict';
+
+ var deb = 'string';
+
+ exports.default = deb;
+
+});
diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/amd/entry-main-ed305cc7-amd.js b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/amd/entry-main-ed305cc7-amd.js
new file mode 100644
index 00000000000..2d7c204addb
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/amd/entry-main-ed305cc7-amd.js
@@ -0,0 +1,6 @@
+define(['require'], function (require) { 'use strict';
+
+ console.log('main');
+ new Promise(function (resolve, reject) { require(['./chunk-deb-c542d45b-amd'], resolve, reject) }).then(console.log);
+
+});
diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/amd/txt/7468331f-test.txt b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/amd/txt/7468331f-test.txt
new file mode 100644
index 00000000000..95d09f2b101
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/amd/txt/7468331f-test.txt
@@ -0,0 +1 @@
+hello world
\ No newline at end of file
diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/cjs/chunk-deb-19c947c3-cjs.js b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/cjs/chunk-deb-19c947c3-cjs.js
new file mode 100644
index 00000000000..f51dbd7a36a
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/cjs/chunk-deb-19c947c3-cjs.js
@@ -0,0 +1,5 @@
+'use strict';
+
+var deb = 'string';
+
+exports.default = deb;
diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/cjs/entry-main-9f49db65-cjs.js b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/cjs/entry-main-9f49db65-cjs.js
new file mode 100644
index 00000000000..6363af0ae9e
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/cjs/entry-main-9f49db65-cjs.js
@@ -0,0 +1,4 @@
+'use strict';
+
+console.log('main');
+Promise.resolve().then(function () { return require('./chunk-deb-19c947c3-cjs.js'); }).then(console.log);
diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/cjs/txt/7468331f-test.txt b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/cjs/txt/7468331f-test.txt
new file mode 100644
index 00000000000..95d09f2b101
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/cjs/txt/7468331f-test.txt
@@ -0,0 +1 @@
+hello world
\ No newline at end of file
diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/es/chunk-deb-607fe03f-es.js b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/es/chunk-deb-607fe03f-es.js
new file mode 100644
index 00000000000..77446c947a7
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/es/chunk-deb-607fe03f-es.js
@@ -0,0 +1,3 @@
+var deb = 'string';
+
+export default deb;
diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/es/entry-main-137667a0-es.js b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/es/entry-main-137667a0-es.js
new file mode 100644
index 00000000000..0896042fc2c
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/es/entry-main-137667a0-es.js
@@ -0,0 +1,2 @@
+console.log('main');
+import('./chunk-deb-607fe03f-es.js').then(console.log);
diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/es/txt/7468331f-test.txt b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/es/txt/7468331f-test.txt
new file mode 100644
index 00000000000..95d09f2b101
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/es/txt/7468331f-test.txt
@@ -0,0 +1 @@
+hello world
\ No newline at end of file
diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/system/chunk-deb-3a28869f-system.js b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/system/chunk-deb-3a28869f-system.js
new file mode 100644
index 00000000000..bf38b53fc6f
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/system/chunk-deb-3a28869f-system.js
@@ -0,0 +1,10 @@
+System.register([], function (exports) {
+ 'use strict';
+ return {
+ execute: function () {
+
+ var deb = exports('default', 'string');
+
+ }
+ };
+});
diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/system/entry-main-e573b571-system.js b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/system/entry-main-e573b571-system.js
new file mode 100644
index 00000000000..4d4ad703227
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/system/entry-main-e573b571-system.js
@@ -0,0 +1,11 @@
+System.register([], function (exports, module) {
+ 'use strict';
+ return {
+ execute: function () {
+
+ console.log('main');
+ module.import('./chunk-deb-3a28869f-system.js').then(console.log);
+
+ }
+ };
+});
diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/system/txt/7468331f-test.txt b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/system/txt/7468331f-test.txt
new file mode 100644
index 00000000000..95d09f2b101
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/filenames-function-patterns/_expected/system/txt/7468331f-test.txt
@@ -0,0 +1 @@
+hello world
\ No newline at end of file
diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/deb.js b/test/chunking-form/samples/emit-file/filenames-function-patterns/deb.js
new file mode 100644
index 00000000000..25d150df293
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/filenames-function-patterns/deb.js
@@ -0,0 +1 @@
+export default 'string';
diff --git a/test/chunking-form/samples/emit-file/filenames-function-patterns/main.js b/test/chunking-form/samples/emit-file/filenames-function-patterns/main.js
new file mode 100644
index 00000000000..d2ae8405fe6
--- /dev/null
+++ b/test/chunking-form/samples/emit-file/filenames-function-patterns/main.js
@@ -0,0 +1,2 @@
+console.log('main');
+import('./deb').then(console.log);