From f25bfe941029da8be8cdb3b39213092c0f95ed2a Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Mon, 11 Jul 2022 07:04:57 +0200 Subject: [PATCH] Improve coverage --- docs/999-big-list-of-options.md | 18 ++++++++---------- .../_config.js | 18 ++++++++++++++++++ .../_expected/amd/a.js | 5 +++++ .../_expected/amd/emitted.js | 5 +++++ .../_expected/amd/main-entry.js | 5 +++++ .../_expected/cjs/a.js | 3 +++ .../_expected/cjs/emitted.js | 3 +++ .../_expected/cjs/main-entry.js | 5 +++++ .../_expected/es/a.js | 1 + .../_expected/es/emitted.js | 1 + .../_expected/es/main-entry.js | 3 +++ .../_expected/system/a.js | 10 ++++++++++ .../_expected/system/emitted.js | 10 ++++++++++ .../_expected/system/main-entry.js | 11 +++++++++++ .../preserve-modules-special-chunk-names/a.js | 1 + .../preserve-modules-special-chunk-names/b.js | 1 + .../main.js | 2 ++ 17 files changed, 92 insertions(+), 10 deletions(-) create mode 100644 test/chunking-form/samples/preserve-modules-special-chunk-names/_config.js create mode 100644 test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/amd/a.js create mode 100644 test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/amd/emitted.js create mode 100644 test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/amd/main-entry.js create mode 100644 test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/cjs/a.js create mode 100644 test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/cjs/emitted.js create mode 100644 test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/cjs/main-entry.js create mode 100644 test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/es/a.js create mode 100644 test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/es/emitted.js create mode 100644 test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/es/main-entry.js create mode 100644 test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/system/a.js create mode 100644 test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/system/emitted.js create mode 100644 test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/system/main-entry.js create mode 100644 test/chunking-form/samples/preserve-modules-special-chunk-names/a.js create mode 100644 test/chunking-form/samples/preserve-modules-special-chunk-names/b.js create mode 100644 test/chunking-form/samples/preserve-modules-special-chunk-names/main.js diff --git a/docs/999-big-list-of-options.md b/docs/999-big-list-of-options.md index c0ab1e0f7b0..8b7adde62c3 100755 --- a/docs/999-big-list-of-options.md +++ b/docs/999-big-list-of-options.md @@ -100,16 +100,14 @@ import { fileURLToPath } from 'url'; export default { input: Object.fromEntries( - glob - .sync('src/**/*.js') - .map(file => [ - // This remove `src/` as well as the file extension from each file, so e.g. - // src/nested/foo.js becomes nested/foo - path.relative('src', file.slice(0, file.length - path.extname(file).length)), - // This expands the relative paths to absolute paths, so e.g. - // src/nested/foo becomes /project/src/nested/foo.js - fileURLToPath(new URL(file, import.meta.url)) - ]) + glob.sync('src/**/*.js').map(file => [ + // This remove `src/` as well as the file extension from each file, so e.g. + // src/nested/foo.js becomes nested/foo + path.relative('src', file.slice(0, file.length - path.extname(file).length)), + // This expands the relative paths to absolute paths, so e.g. + // src/nested/foo becomes /project/src/nested/foo.js + fileURLToPath(new URL(file, import.meta.url)) + ]) ), output: { format: 'es', diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/_config.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/_config.js new file mode 100644 index 00000000000..9d8de66ce06 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/_config.js @@ -0,0 +1,18 @@ +const path = require('path'); + +module.exports = { + description: 'Supports chunk names from config when preserving modules', + options: { + input: { 'main-entry': 'main.js' }, + output: { + preserveModules: true + }, + plugins: [ + { + buildStart() { + this.emitFile({ type: 'chunk', id: path.join(__dirname, 'b.js'), name: 'emitted' }); + } + } + ] + } +}; diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/amd/a.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/amd/a.js new file mode 100644 index 00000000000..6d0638c63e4 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/amd/a.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('a'); + +})); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/amd/emitted.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/amd/emitted.js new file mode 100644 index 00000000000..b8ffc59b2da --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/amd/emitted.js @@ -0,0 +1,5 @@ +define((function () { 'use strict'; + + console.log('b'); + +})); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/amd/main-entry.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/amd/main-entry.js new file mode 100644 index 00000000000..1ca395ac358 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/amd/main-entry.js @@ -0,0 +1,5 @@ +define(['./a'], (function (a) { 'use strict'; + + console.log('main'); + +})); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/cjs/a.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/cjs/a.js new file mode 100644 index 00000000000..4151e09bdbf --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/cjs/a.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('a'); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/cjs/emitted.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/cjs/emitted.js new file mode 100644 index 00000000000..099afa3ff4c --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/cjs/emitted.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('b'); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/cjs/main-entry.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/cjs/main-entry.js new file mode 100644 index 00000000000..51fbee028ad --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/cjs/main-entry.js @@ -0,0 +1,5 @@ +'use strict'; + +require('./a.js'); + +console.log('main'); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/es/a.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/es/a.js new file mode 100644 index 00000000000..8609d075540 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/es/a.js @@ -0,0 +1 @@ +console.log('a'); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/es/emitted.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/es/emitted.js new file mode 100644 index 00000000000..eeb313a0347 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/es/emitted.js @@ -0,0 +1 @@ +console.log('b'); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/es/main-entry.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/es/main-entry.js new file mode 100644 index 00000000000..8874885af3b --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/es/main-entry.js @@ -0,0 +1,3 @@ +import './a.js'; + +console.log('main'); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/system/a.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/system/a.js new file mode 100644 index 00000000000..2859a1e855c --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/system/a.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('a'); + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/system/emitted.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/system/emitted.js new file mode 100644 index 00000000000..17b43387a91 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/system/emitted.js @@ -0,0 +1,10 @@ +System.register([], (function () { + 'use strict'; + return { + execute: (function () { + + console.log('b'); + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/system/main-entry.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/system/main-entry.js new file mode 100644 index 00000000000..03c140fd25e --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/_expected/system/main-entry.js @@ -0,0 +1,11 @@ +System.register(['./a.js'], (function () { + 'use strict'; + return { + setters: [function () {}], + execute: (function () { + + console.log('main'); + + }) + }; +})); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/a.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/a.js new file mode 100644 index 00000000000..8609d075540 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/a.js @@ -0,0 +1 @@ +console.log('a'); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/b.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/b.js new file mode 100644 index 00000000000..eeb313a0347 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/b.js @@ -0,0 +1 @@ +console.log('b'); diff --git a/test/chunking-form/samples/preserve-modules-special-chunk-names/main.js b/test/chunking-form/samples/preserve-modules-special-chunk-names/main.js new file mode 100644 index 00000000000..0cf5c3a5a53 --- /dev/null +++ b/test/chunking-form/samples/preserve-modules-special-chunk-names/main.js @@ -0,0 +1,2 @@ +import './a.js'; +console.log('main');