From fc83a17db724aaefd7a1e05f22cea321f487782e Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Tue, 7 Mar 2023 21:39:00 -0800 Subject: [PATCH] fix: Fix assets paths not resolving to the correct location. (#187) * Test no bundle. * Test bundle. * Use absolute ID. * Update hashes. * Try resolve. * Hrmm. * Fix imports. --- .../src/rollup/plugins/copyAndRefAssets.ts | 9 +- .../tests/__snapshots__/outputs.test.ts.snap | 2774 ++++++++++++++--- packages/packemon/tests/helpers.ts | 14 +- packages/packemon/tests/outputs.test.ts | 74 +- 4 files changed, 2389 insertions(+), 482 deletions(-) diff --git a/packages/packemon/src/rollup/plugins/copyAndRefAssets.ts b/packages/packemon/src/rollup/plugins/copyAndRefAssets.ts index 807c12b68..db5500bd2 100644 --- a/packages/packemon/src/rollup/plugins/copyAndRefAssets.ts +++ b/packages/packemon/src/rollup/plugins/copyAndRefAssets.ts @@ -60,9 +60,14 @@ export function copyAndRefAssets({ dir }: CopyAssetsOptions): Plugin { }, // Find assets and mark as external - resolveId(source) { + resolveId(source, importer) { if (isAsset(source)) { - return { id: source, external: true }; + if (source.startsWith('.')) { + return { id: path.join(path.dirname(importer!), source), external: true }; + } + + // Ignore files coming from node modules + return false; } return null; diff --git a/packages/packemon/tests/__snapshots__/outputs.test.ts.snap b/packages/packemon/tests/__snapshots__/outputs.test.ts.snap index 47b6a430d..4c96f3586 100644 --- a/packages/packemon/tests/__snapshots__/outputs.test.ts.snap +++ b/packages/packemon/tests/__snapshots__/outputs.test.ts.snap @@ -281,29 +281,28 @@ exports[`Outputs (babel) bundle bundles all files into a single file with rollup ] `; -exports[`Outputs (babel) bundle with assets bundles all files and references assets 1`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (browser, esm) 1`] = ` [ - "lib/index.js", + "esm/index.js", "// Bundled with Packemon: https://packemon.dev -// Platform: node, Support: stable, Format: lib - -'use strict'; +// Platform: browser, Support: stable, Format: esm -require('../assets/globals-107ab52e.css'); -require('../assets/fonts-4e5dc96c.css'); -require('../assets/styles-a82c1676.css'); +import '../assets/globals-107ab52e.css'; +import '../assets/fonts-4e5dc96c.css'; +import '../assets/styles-b11c3a83.css'; function button() {} -exports.button = button; +export { button }; //# sourceMappingURL=index.js.map ", ] `; -exports[`Outputs (babel) bundle with assets bundles all files and references assets 2`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (browser, esm) 2`] = ` [ "package.json", { - "main": "./lib/index.js", + "main": "./esm/index.js", + "module": "./esm/index.js", "name": "project-assets", "packemon": { "bundle": true, @@ -313,85 +312,86 @@ exports[`Outputs (babel) bundle with assets bundles all files and references ass ] `; -exports[`Outputs (babel) bundle with assets bundles all files and references assets 3`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (browser, esm) 3`] = ` [ - "src/globals.css", - "assets/globals-107ab52e.css", + "src/button/styles.css", + "assets/styles-b11c3a83.css", ] `; -exports[`Outputs (babel) bundle with assets bundles all files and references assets 4`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (browser, esm) 4`] = ` [ - "src/shared/fonts.css", - "assets/fonts-4e5dc96c.css", + "src/globals.css", + "assets/globals-107ab52e.css", ] `; -exports[`Outputs (babel) bundle with assets bundles all files and references assets 5`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (browser, esm) 5`] = ` [ - "src/styles.css", - "assets/styles-a82c1676.css", + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", ] `; -exports[`Outputs (babel) bundle with assets uses same assets across multiple formats 1`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (browser, lib) 1`] = ` [ - "cjs/index.cjs", + "lib/index.js", "// Bundled with Packemon: https://packemon.dev -// Platform: node, Support: stable, Format: cjs +// Platform: browser, Support: stable, Format: lib 'use strict'; require('../assets/globals-107ab52e.css'); require('../assets/fonts-4e5dc96c.css'); -require('../assets/styles-a82c1676.css'); +require('../assets/styles-b11c3a83.css'); function button() {} exports.button = button; -//# sourceMappingURL=index.cjs.map +//# sourceMappingURL=index.js.map ", ] `; -exports[`Outputs (babel) bundle with assets uses same assets across multiple formats 2`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (browser, lib) 2`] = ` [ - "esm/index.js", - "// Bundled with Packemon: https://packemon.dev -// Platform: node, Support: stable, Format: esm - -import '../assets/globals-107ab52e.css'; -import '../assets/fonts-4e5dc96c.css'; -import '../assets/styles-a82c1676.css'; -function button() {} -export { button }; -//# sourceMappingURL=index.js.map -", + "package.json", + { + "main": "./lib/index.js", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, ] `; -exports[`Outputs (babel) bundle with assets uses same assets across multiple formats 3`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (browser, lib) 3`] = ` [ - "lib/index.js", - "// Bundled with Packemon: https://packemon.dev -// Platform: node, Support: stable, Format: lib + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; -'use strict'; +exports[`Outputs (babel) bundle with assets bundles all files and references assets (browser, lib) 4`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; -require('../assets/globals-107ab52e.css'); -require('../assets/fonts-4e5dc96c.css'); -require('../assets/styles-a82c1676.css'); -function button() {} -exports.button = button; -//# sourceMappingURL=index.js.map -", +exports[`Outputs (babel) bundle with assets bundles all files and references assets (browser, lib) 5`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", ] `; -exports[`Outputs (babel) bundle with assets uses same assets across multiple formats 4`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (browser, umd) 1`] = ` [ "package.json", { + "browser": "./umd/index.js", "main": "./lib/index.js", - "module": "./esm/index.js", "name": "project-assets", "packemon": { "bundle": true, @@ -401,113 +401,188 @@ exports[`Outputs (babel) bundle with assets uses same assets across multiple for ] `; -exports[`Outputs (babel) bundle with assets uses same assets across multiple formats 5`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (browser, umd) 2`] = ` [ - "src/globals.css", - "assets/globals-107ab52e.css", + "src/button/styles.css", + "assets/styles-b11c3a83.css", ] `; -exports[`Outputs (babel) bundle with assets uses same assets across multiple formats 6`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (browser, umd) 3`] = ` [ "src/globals.css", "assets/globals-107ab52e.css", ] `; -exports[`Outputs (babel) bundle with assets uses same assets across multiple formats 7`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (browser, umd) 4`] = ` [ - "src/globals.css", - "assets/globals-107ab52e.css", + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", ] `; -exports[`Outputs (babel) bundle with assets uses same assets across multiple formats 8`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (browser, umd) 5`] = ` [ - "src/shared/fonts.css", - "assets/fonts-4e5dc96c.css", + "umd/index.js", + "(function (global, factory) { + if (typeof define === "function" && define.amd) { + define(["exports", "../assets/globals-107ab52e.css", "../assets/fonts-4e5dc96c.css", "../assets/styles-b11c3a83.css"], factory); + } else if (typeof exports !== "undefined") { + factory(exports, require("../assets/globals-107ab52e.css"), require("../assets/fonts-4e5dc96c.css"), require("../assets/styles-b11c3a83.css")); + } else { + var mod = { + exports: {} + }; + factory(mod.exports, global.globals107ab52e, global.fonts4e5dc96c, global.stylesB11c3a83); + global.projectAssets = mod.exports; + } +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _globals107ab52e, _fonts4e5dc96c, _stylesB11c3a) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports.button = button; + // Bundled with Packemon: https://packemon.dev + // Platform: browser, Support: stable, Format: umd + + function button() {} +}); +//# sourceMappingURL=index.js.map +", ] `; -exports[`Outputs (babel) bundle with assets uses same assets across multiple formats 9`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (electron, esm) 1`] = ` [ - "src/shared/fonts.css", - "assets/fonts-4e5dc96c.css", + "esm/index.js", + "// Bundled with Packemon: https://packemon.dev +// Platform: electron, Support: stable, Format: esm + +import '../assets/globals-107ab52e.css'; +import '../assets/fonts-4e5dc96c.css'; +import '../assets/styles-b11c3a83.css'; +function button() {} +export { button }; +//# sourceMappingURL=index.js.map +", ] `; -exports[`Outputs (babel) bundle with assets uses same assets across multiple formats 10`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (electron, esm) 2`] = ` [ - "src/shared/fonts.css", - "assets/fonts-4e5dc96c.css", + "package.json", + { + "main": "./esm/index.js", + "module": "./esm/index.js", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, ] `; -exports[`Outputs (babel) bundle with assets uses same assets across multiple formats 11`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (electron, esm) 3`] = ` [ - "src/styles.css", - "assets/styles-a82c1676.css", + "src/button/styles.css", + "assets/styles-b11c3a83.css", ] `; -exports[`Outputs (babel) bundle with assets uses same assets across multiple formats 12`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (electron, esm) 4`] = ` [ - "src/styles.css", - "assets/styles-a82c1676.css", + "src/globals.css", + "assets/globals-107ab52e.css", ] `; -exports[`Outputs (babel) bundle with assets uses same assets across multiple formats 13`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (electron, esm) 5`] = ` [ - "src/styles.css", - "assets/styles-a82c1676.css", + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", ] `; -exports[`Outputs (babel) no bundle creates individual files for every source file 1`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (electron, lib) 1`] = ` [ "lib/index.js", - "'use strict'; + "// Bundled with Packemon: https://packemon.dev +// Platform: electron, Support: stable, Format: lib -const other = require('./other.js'); -function bar() {} -exports.foo = other.foo; -exports.bar = bar; +'use strict'; + +require('../assets/globals-107ab52e.css'); +require('../assets/fonts-4e5dc96c.css'); +require('../assets/styles-b11c3a83.css'); +function button() {} +exports.button = button; //# sourceMappingURL=index.js.map ", ] `; -exports[`Outputs (babel) no bundle creates individual files for every source file 2`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (electron, lib) 2`] = ` [ - "lib/not-imported.js", - "'use strict'; + "package.json", + { + "main": "./lib/index.js", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, +] +`; -function baz() {} -exports.baz = baz; -//# sourceMappingURL=not-imported.js.map -", +exports[`Outputs (babel) bundle with assets bundles all files and references assets (electron, lib) 3`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", ] `; -exports[`Outputs (babel) no bundle creates individual files for every source file 3`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (electron, lib) 4`] = ` [ - "lib/other.js", - "'use strict'; + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; -function foo() {} -exports.foo = foo; -//# sourceMappingURL=other.js.map +exports[`Outputs (babel) bundle with assets bundles all files and references assets (electron, lib) 5`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (babel) bundle with assets bundles all files and references assets (native, lib) 1`] = ` +[ + "lib/index.js", + "// Bundled with Packemon: https://packemon.dev +// Platform: native, Support: stable, Format: lib + +'use strict'; + +require('../assets/globals-107ab52e.css'); +require('../assets/fonts-4e5dc96c.css'); +require('../assets/styles-b11c3a83.css'); +function button() {} +exports.button = button; +//# sourceMappingURL=index.js.map ", ] `; -exports[`Outputs (babel) no bundle creates individual files for every source file 4`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (native, lib) 2`] = ` [ "package.json", { "main": "./lib/index.js", - "name": "project-bundle", + "name": "project-assets", "packemon": { "bundle": true, "platform": "node", @@ -516,38 +591,50 @@ exports[`Outputs (babel) no bundle creates individual files for every source fil ] `; -exports[`Outputs (babel) no bundle with assets creates individual files and references assets 1`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (native, lib) 3`] = ` [ - "lib/button/index.js", - "'use strict'; + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; -require('../../assets/styles-b11c3a83.css'); -function button() {} -exports.button = button; -//# sourceMappingURL=index.js.map -", +exports[`Outputs (babel) bundle with assets bundles all files and references assets (native, lib) 4`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", ] `; -exports[`Outputs (babel) no bundle with assets creates individual files and references assets 2`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (native, lib) 5`] = ` [ - "lib/index.js", - "'use strict'; + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (babel) bundle with assets bundles all files and references assets (node, cjs) 1`] = ` +[ + "cjs/index.cjs", + "// Bundled with Packemon: https://packemon.dev +// Platform: node, Support: stable, Format: cjs + +'use strict'; require('../assets/globals-107ab52e.css'); require('../assets/fonts-4e5dc96c.css'); -const index = require('./button/index.js'); -exports.button = index.button; -//# sourceMappingURL=index.js.map +require('../assets/styles-b11c3a83.css'); +function button() {} +exports.button = button; +//# sourceMappingURL=index.cjs.map ", ] `; -exports[`Outputs (babel) no bundle with assets creates individual files and references assets 3`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (node, cjs) 2`] = ` [ "package.json", { - "main": "./lib/index.js", + "main": "./cjs/index.cjs", "name": "project-assets", "packemon": { "bundle": true, @@ -557,300 +644,2092 @@ exports[`Outputs (babel) no bundle with assets creates individual files and refe ] `; -exports[`Outputs (babel) no bundle with assets creates individual files and references assets 4`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (node, cjs) 3`] = ` [ "src/button/styles.css", "assets/styles-b11c3a83.css", ] `; -exports[`Outputs (babel) no bundle with assets creates individual files and references assets 5`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (node, cjs) 4`] = ` [ "src/globals.css", "assets/globals-107ab52e.css", ] `; -exports[`Outputs (babel) no bundle with assets creates individual files and references assets 6`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (node, cjs) 5`] = ` [ "src/shared/fonts.css", "assets/fonts-4e5dc96c.css", ] `; -exports[`Outputs (swc) artifacts builds all the artifacts with rollup 1`] = ` +exports[`Outputs (babel) bundle with assets bundles all files and references assets (node, lib) 1`] = ` [ - "cjs/server.cjs", + "lib/index.js", "// Bundled with Packemon: https://packemon.dev -// Platform: node, Support: current, Format: cjs +// Platform: node, Support: stable, Format: lib 'use strict'; -const https = require('node:https'); -const _interopDefault = e => e && e.__esModule ? e : { - default: e -}; -const https__default = /*#__PURE__*/_interopDefault(https); -https__default.default.createServer((req, res) => { - res.writeHead(200, { - 'Content-Type': 'text/plain' - }); - res.write('Hello World!'); - res.end(); -}).listen(8080); -//# sourceMappingURL=server.cjs.map +require('../assets/globals-107ab52e.css'); +require('../assets/fonts-4e5dc96c.css'); +require('../assets/styles-b11c3a83.css'); +function button() {} +exports.button = button; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (babel) bundle with assets bundles all files and references assets (node, lib) 2`] = ` +[ + "package.json", + { + "main": "./lib/index.js", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, +] +`; + +exports[`Outputs (babel) bundle with assets bundles all files and references assets (node, lib) 3`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (babel) bundle with assets bundles all files and references assets (node, lib) 4`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (babel) bundle with assets bundles all files and references assets (node, lib) 5`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (babel) bundle with assets bundles all files and references assets (node, mjs) 1`] = ` +[ + "mjs/index.mjs", + "// Bundled with Packemon: https://packemon.dev +// Platform: node, Support: stable, Format: mjs + +import '../assets/globals-107ab52e.css'; +import '../assets/fonts-4e5dc96c.css'; +import '../assets/styles-b11c3a83.css'; +function button() {} +export { button }; +//# sourceMappingURL=index.mjs.map +", +] +`; + +exports[`Outputs (babel) bundle with assets bundles all files and references assets (node, mjs) 2`] = ` +[ + "package.json", + { + "main": "./mjs/index.mjs", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, +] +`; + +exports[`Outputs (babel) bundle with assets bundles all files and references assets (node, mjs) 3`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (babel) bundle with assets bundles all files and references assets (node, mjs) 4`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (babel) bundle with assets bundles all files and references assets (node, mjs) 5`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (babel) bundle with assets uses same assets across multiple formats 1`] = ` +[ + "cjs/index.cjs", + "// Bundled with Packemon: https://packemon.dev +// Platform: node, Support: stable, Format: cjs + +'use strict'; + +require('../assets/globals-107ab52e.css'); +require('../assets/fonts-4e5dc96c.css'); +require('../assets/styles-b11c3a83.css'); +function button() {} +exports.button = button; +//# sourceMappingURL=index.cjs.map +", +] +`; + +exports[`Outputs (babel) bundle with assets uses same assets across multiple formats 2`] = ` +[ + "esm/index.js", + "// Bundled with Packemon: https://packemon.dev +// Platform: node, Support: stable, Format: esm + +import '../assets/globals-107ab52e.css'; +import '../assets/fonts-4e5dc96c.css'; +import '../assets/styles-b11c3a83.css'; +function button() {} +export { button }; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (babel) bundle with assets uses same assets across multiple formats 3`] = ` +[ + "lib/index.js", + "// Bundled with Packemon: https://packemon.dev +// Platform: node, Support: stable, Format: lib + +'use strict'; + +require('../assets/globals-107ab52e.css'); +require('../assets/fonts-4e5dc96c.css'); +require('../assets/styles-b11c3a83.css'); +function button() {} +exports.button = button; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (babel) bundle with assets uses same assets across multiple formats 4`] = ` +[ + "package.json", + { + "main": "./lib/index.js", + "module": "./esm/index.js", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, +] +`; + +exports[`Outputs (babel) bundle with assets uses same assets across multiple formats 5`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (babel) bundle with assets uses same assets across multiple formats 6`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (babel) bundle with assets uses same assets across multiple formats 7`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (babel) bundle with assets uses same assets across multiple formats 8`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (babel) bundle with assets uses same assets across multiple formats 9`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (babel) bundle with assets uses same assets across multiple formats 10`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (babel) bundle with assets uses same assets across multiple formats 11`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (babel) bundle with assets uses same assets across multiple formats 12`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (babel) bundle with assets uses same assets across multiple formats 13`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (babel) no bundle creates individual files for every source file 1`] = ` +[ + "lib/index.js", + "'use strict'; + +const other = require('./other.js'); +function bar() {} +exports.foo = other.foo; +exports.bar = bar; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (babel) no bundle creates individual files for every source file 2`] = ` +[ + "lib/not-imported.js", + "'use strict'; + +function baz() {} +exports.baz = baz; +//# sourceMappingURL=not-imported.js.map +", +] +`; + +exports[`Outputs (babel) no bundle creates individual files for every source file 3`] = ` +[ + "lib/other.js", + "'use strict'; + +function foo() {} +exports.foo = foo; +//# sourceMappingURL=other.js.map +", +] +`; + +exports[`Outputs (babel) no bundle creates individual files for every source file 4`] = ` +[ + "package.json", + { + "main": "./lib/index.js", + "name": "project-bundle", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (browser, esm) 1`] = ` +[ + "esm/button/index.js", + "import '../../assets/styles-b11c3a83.css'; +function button() {} +export { button }; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (browser, esm) 2`] = ` +[ + "esm/index.js", + "import '../assets/globals-107ab52e.css'; +import '../assets/fonts-4e5dc96c.css'; +export { button } from './button/index.js'; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (browser, esm) 3`] = ` +[ + "package.json", + { + "main": "./esm/index.js", + "module": "./esm/index.js", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (browser, esm) 4`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (browser, esm) 5`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (browser, esm) 6`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (browser, lib) 1`] = ` +[ + "lib/button/index.js", + "'use strict'; + +require('../../assets/styles-b11c3a83.css'); +function button() {} +exports.button = button; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (browser, lib) 2`] = ` +[ + "lib/index.js", + "'use strict'; + +require('../assets/globals-107ab52e.css'); +require('../assets/fonts-4e5dc96c.css'); +const index = require('./button/index.js'); +exports.button = index.button; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (browser, lib) 3`] = ` +[ + "package.json", + { + "main": "./lib/index.js", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (browser, lib) 4`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (browser, lib) 5`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (browser, lib) 6`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (browser, umd) 1`] = ` +[ + "package.json", + { + "browser": "./umd/index.js", + "main": "./lib/index.js", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (browser, umd) 2`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (browser, umd) 3`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (browser, umd) 4`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (browser, umd) 5`] = ` +[ + "umd/button/index.js", + "(function (global, factory) { + if (typeof define === "function" && define.amd) { + define(["exports", "../../assets/styles-b11c3a83.css"], factory); + } else if (typeof exports !== "undefined") { + factory(exports, require("../../assets/styles-b11c3a83.css")); + } else { + var mod = { + exports: {} + }; + factory(mod.exports, global.stylesB11c3a83); + global.projectAssets = mod.exports; + } +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _stylesB11c3a) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports.button = button; + function button() {} +}); +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (browser, umd) 6`] = ` +[ + "umd/index.js", + "(function (global, factory) { + if (typeof define === "function" && define.amd) { + define(["exports", "../assets/globals-107ab52e.css", "../assets/fonts-4e5dc96c.css", "./button/index.js"], factory); + } else if (typeof exports !== "undefined") { + factory(exports, require("../assets/globals-107ab52e.css"), require("../assets/fonts-4e5dc96c.css"), require("./button/index.js")); + } else { + var mod = { + exports: {} + }; + factory(mod.exports, global.globals107ab52e, global.fonts4e5dc96c, global.index); + global.projectAssets = mod.exports; + } +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _globals107ab52e, _fonts4e5dc96c, _index) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + Object.defineProperty(_exports, "button", { + enumerable: true, + get: function () { + return _index.button; + } + }); +}); +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (electron, esm) 1`] = ` +[ + "esm/button/index.js", + "import '../../assets/styles-b11c3a83.css'; +function button() {} +export { button }; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (electron, esm) 2`] = ` +[ + "esm/index.js", + "import '../assets/globals-107ab52e.css'; +import '../assets/fonts-4e5dc96c.css'; +export { button } from './button/index.js'; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (electron, esm) 3`] = ` +[ + "package.json", + { + "main": "./esm/index.js", + "module": "./esm/index.js", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (electron, esm) 4`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (electron, esm) 5`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (electron, esm) 6`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (electron, lib) 1`] = ` +[ + "lib/button/index.js", + "'use strict'; + +require('../../assets/styles-b11c3a83.css'); +function button() {} +exports.button = button; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (electron, lib) 2`] = ` +[ + "lib/index.js", + "'use strict'; + +require('../assets/globals-107ab52e.css'); +require('../assets/fonts-4e5dc96c.css'); +const index = require('./button/index.js'); +exports.button = index.button; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (electron, lib) 3`] = ` +[ + "package.json", + { + "main": "./lib/index.js", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (electron, lib) 4`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (electron, lib) 5`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (electron, lib) 6`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (native, lib) 1`] = ` +[ + "lib/button/index.js", + "'use strict'; + +require('../../assets/styles-b11c3a83.css'); +function button() {} +exports.button = button; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (native, lib) 2`] = ` +[ + "lib/index.js", + "'use strict'; + +require('../assets/globals-107ab52e.css'); +require('../assets/fonts-4e5dc96c.css'); +const index = require('./button/index.js'); +exports.button = index.button; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (native, lib) 3`] = ` +[ + "package.json", + { + "main": "./lib/index.js", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (native, lib) 4`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (native, lib) 5`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (native, lib) 6`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (node, cjs) 1`] = ` +[ + "cjs/button/index.cjs", + "'use strict'; + +require('../../assets/styles-b11c3a83.css'); +function button() {} +exports.button = button; +//# sourceMappingURL=index.cjs.map +", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (node, cjs) 2`] = ` +[ + "cjs/index.cjs", + "'use strict'; + +require('../assets/globals-107ab52e.css'); +require('../assets/fonts-4e5dc96c.css'); +const index = require('./button/index.cjs'); +exports.button = index.button; +//# sourceMappingURL=index.cjs.map +", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (node, cjs) 3`] = ` +[ + "package.json", + { + "main": "./cjs/index.cjs", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (node, cjs) 4`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (node, cjs) 5`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (node, cjs) 6`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (node, lib) 1`] = ` +[ + "lib/button/index.js", + "'use strict'; + +require('../../assets/styles-b11c3a83.css'); +function button() {} +exports.button = button; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (node, lib) 2`] = ` +[ + "lib/index.js", + "'use strict'; + +require('../assets/globals-107ab52e.css'); +require('../assets/fonts-4e5dc96c.css'); +const index = require('./button/index.js'); +exports.button = index.button; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (node, lib) 3`] = ` +[ + "package.json", + { + "main": "./lib/index.js", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (node, lib) 4`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (node, lib) 5`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (node, lib) 6`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (node, mjs) 1`] = ` +[ + "mjs/button/index.mjs", + "import '../../assets/styles-b11c3a83.css'; +function button() {} +export { button }; +//# sourceMappingURL=index.mjs.map +", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (node, mjs) 2`] = ` +[ + "mjs/index.mjs", + "import '../assets/globals-107ab52e.css'; +import '../assets/fonts-4e5dc96c.css'; +export { button } from './button/index.mjs'; +//# sourceMappingURL=index.mjs.map +", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (node, mjs) 3`] = ` +[ + "package.json", + { + "main": "./mjs/index.mjs", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (node, mjs) 4`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (node, mjs) 5`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (babel) no bundle with assets creates individual files and references assets (node, mjs) 6`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (swc) artifacts builds all the artifacts with rollup 1`] = ` +[ + "cjs/server.cjs", + "// Bundled with Packemon: https://packemon.dev +// Platform: node, Support: current, Format: cjs + +'use strict'; + +const https = require('node:https'); +const _interopDefault = e => e && e.__esModule ? e : { + default: e +}; +const https__default = /*#__PURE__*/_interopDefault(https); +https__default.default.createServer((req, res) => { + res.writeHead(200, { + 'Content-Type': 'text/plain' + }); + res.write('Hello World!'); + res.end(); +}).listen(8080); +//# sourceMappingURL=server.cjs.map +", +] +`; + +exports[`Outputs (swc) artifacts builds all the artifacts with rollup 2`] = ` +[ + "esm/client.js", + "function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } +function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } +function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } +// Bundled with Packemon: https://packemon.dev +// Platform: browser, Support: legacy, Format: esm +var Client = /*#__PURE__*/_createClass(function Client() { + _classCallCheck(this, Client); + _defineProperty(this, "prop", 123); +}); +function* gen() {} +async function wait() {} +async function createClient() { + await wait(); + var _iterator = _createForOfIteratorHelper(gen()), + _step; + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var iterator = _step.value; + console.log(iterator); + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + return new Client(); +} +export { createClient }; +//# sourceMappingURL=client.js.map +", +] +`; + +exports[`Outputs (swc) artifacts builds all the artifacts with rollup 3`] = ` +[ + "lib/client.js", + "// Bundled with Packemon: https://packemon.dev +// Platform: browser, Support: legacy, Format: lib + +'use strict'; + +function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } +function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } +function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } +var Client = /*#__PURE__*/_createClass(function Client() { + _classCallCheck(this, Client); + _defineProperty(this, "prop", 123); +}); +function* gen() {} +async function wait() {} +async function createClient() { + await wait(); + var _iterator = _createForOfIteratorHelper(gen()), + _step; + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var iterator = _step.value; + console.log(iterator); + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + return new Client(); +} +exports.createClient = createClient; +//# sourceMappingURL=client.js.map +", +] +`; + +exports[`Outputs (swc) artifacts builds all the artifacts with rollup 4`] = ` +[ + "lib/index.js", + "// Bundled with Packemon: https://packemon.dev +// Platform: node, Support: stable, Format: lib + +'use strict'; + +const EXAMPLE = 'foo'; +exports.EXAMPLE = EXAMPLE; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (swc) artifacts builds all the artifacts with rollup 5`] = ` +[ + "lib/test.js", + "// Bundled with Packemon: https://packemon.dev +// Platform: native, Support: experimental, Format: lib + +'use strict'; + +class Spy { + called = false; + mock = () => {}; + method() {} +} +function spy() { + const inst = new Spy(); + return jest.fn(inst.mock); +} +async function wait() {} +exports.spy = spy; +exports.wait = wait; +//# sourceMappingURL=test.js.map +", +] +`; + +exports[`Outputs (swc) artifacts builds all the artifacts with rollup 6`] = ` +[ + "package.json", + { + "browser": "./umd/client.js", + "dependencies": { + "typescript": "*", + }, + "main": "./lib/index.js", + "module": "./esm/client.js", + "name": "project-rollup", + "packemon": { + "inputs": { + "client": "src/client.ts", + "index": "src/index.ts", + "server": "src/server/core.ts", + "test": "src/test-utils/base.ts", + }, + }, + }, +] +`; + +exports[`Outputs (swc) artifacts builds all the artifacts with rollup 7`] = ` +[ + "umd/client.js", + "(function (global, factory) { + if (typeof define === "function" && define.amd) { + define("Packemon", ["exports"], factory); + } else if (typeof exports !== "undefined") { + factory(exports); + } else { + var mod = { + exports: {} + }; + factory(mod.exports); + global.Packemon = mod.exports; + } +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports.createClient = createClient; + function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } + function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } + function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } + function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } + // Bundled with Packemon: https://packemon.dev + // Platform: browser, Support: legacy, Format: umd + var Client = /*#__PURE__*/_createClass(function Client() { + _classCallCheck(this, Client); + _defineProperty(this, "prop", 123); + }); + function* gen() {} + async function wait() {} + async function createClient() { + await wait(); + var _iterator = _createForOfIteratorHelper(gen()), + _step; + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var iterator = _step.value; + console.log(iterator); + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + return new Client(); + } +}); +//# sourceMappingURL=client.js.map +", +] +`; + +exports[`Outputs (swc) artifacts builds all the artifacts with rollup 8`] = ` +[ + { + "format": "lib", + "stats": { + "size": 195, + }, + }, +] +`; + +exports[`Outputs (swc) bundle bundles all files into a single file with rollup 1`] = ` +[ + "lib/index.js", + "// Bundled with Packemon: https://packemon.dev +// Platform: node, Support: stable, Format: lib + +'use strict'; + +function foo() {} +function bar() {} +exports.bar = bar; +exports.foo = foo; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (swc) bundle bundles all files into a single file with rollup 2`] = ` +[ + "package.json", + { + "main": "./lib/index.js", + "name": "project-bundle", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (browser, esm) 1`] = ` +[ + "esm/index.js", + "// Bundled with Packemon: https://packemon.dev +// Platform: browser, Support: stable, Format: esm + +import '../assets/globals-107ab52e.css'; +import '../assets/fonts-4e5dc96c.css'; +import '../assets/styles-b11c3a83.css'; +function button() {} +export { button }; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (browser, esm) 2`] = ` +[ + "package.json", + { + "main": "./esm/index.js", + "module": "./esm/index.js", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (browser, esm) 3`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (browser, esm) 4`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (browser, esm) 5`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (browser, lib) 1`] = ` +[ + "lib/index.js", + "// Bundled with Packemon: https://packemon.dev +// Platform: browser, Support: stable, Format: lib + +'use strict'; + +require('../assets/globals-107ab52e.css'); +require('../assets/fonts-4e5dc96c.css'); +require('../assets/styles-b11c3a83.css'); +function button() {} +exports.button = button; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (browser, lib) 2`] = ` +[ + "package.json", + { + "main": "./lib/index.js", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (browser, lib) 3`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (browser, lib) 4`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (browser, lib) 5`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (browser, umd) 1`] = ` +[ + "package.json", + { + "browser": "./umd/index.js", + "main": "./lib/index.js", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (browser, umd) 2`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (browser, umd) 3`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (browser, umd) 4`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (browser, umd) 5`] = ` +[ + "umd/index.js", + "(function (global, factory) { + if (typeof define === "function" && define.amd) { + define(["exports", "../assets/globals-107ab52e.css", "../assets/fonts-4e5dc96c.css", "../assets/styles-b11c3a83.css"], factory); + } else if (typeof exports !== "undefined") { + factory(exports, require("../assets/globals-107ab52e.css"), require("../assets/fonts-4e5dc96c.css"), require("../assets/styles-b11c3a83.css")); + } else { + var mod = { + exports: {} + }; + factory(mod.exports, global.globals107ab52e, global.fonts4e5dc96c, global.stylesB11c3a83); + global.projectAssets = mod.exports; + } +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _globals107ab52e, _fonts4e5dc96c, _stylesB11c3a) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports.button = button; + // Bundled with Packemon: https://packemon.dev + // Platform: browser, Support: stable, Format: umd + + function button() {} +}); +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (electron, esm) 1`] = ` +[ + "esm/index.js", + "// Bundled with Packemon: https://packemon.dev +// Platform: electron, Support: stable, Format: esm + +import '../assets/globals-107ab52e.css'; +import '../assets/fonts-4e5dc96c.css'; +import '../assets/styles-b11c3a83.css'; +function button() {} +export { button }; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (electron, esm) 2`] = ` +[ + "package.json", + { + "main": "./esm/index.js", + "module": "./esm/index.js", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (electron, esm) 3`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (electron, esm) 4`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (electron, esm) 5`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (electron, lib) 1`] = ` +[ + "lib/index.js", + "// Bundled with Packemon: https://packemon.dev +// Platform: electron, Support: stable, Format: lib + +'use strict'; + +require('../assets/globals-107ab52e.css'); +require('../assets/fonts-4e5dc96c.css'); +require('../assets/styles-b11c3a83.css'); +function button() {} +exports.button = button; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (electron, lib) 2`] = ` +[ + "package.json", + { + "main": "./lib/index.js", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (electron, lib) 3`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (electron, lib) 4`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (electron, lib) 5`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (native, lib) 1`] = ` +[ + "lib/index.js", + "// Bundled with Packemon: https://packemon.dev +// Platform: native, Support: stable, Format: lib + +'use strict'; + +require('../assets/globals-107ab52e.css'); +require('../assets/fonts-4e5dc96c.css'); +require('../assets/styles-b11c3a83.css'); +function button() {} +exports.button = button; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (native, lib) 2`] = ` +[ + "package.json", + { + "main": "./lib/index.js", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (native, lib) 3`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (native, lib) 4`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (native, lib) 5`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (node, cjs) 1`] = ` +[ + "cjs/index.cjs", + "// Bundled with Packemon: https://packemon.dev +// Platform: node, Support: stable, Format: cjs + +'use strict'; + +require('../assets/globals-107ab52e.css'); +require('../assets/fonts-4e5dc96c.css'); +require('../assets/styles-b11c3a83.css'); +function button() {} +exports.button = button; +//# sourceMappingURL=index.cjs.map +", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (node, cjs) 2`] = ` +[ + "package.json", + { + "main": "./cjs/index.cjs", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (node, cjs) 3`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (node, cjs) 4`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (node, cjs) 5`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (node, lib) 1`] = ` +[ + "lib/index.js", + "// Bundled with Packemon: https://packemon.dev +// Platform: node, Support: stable, Format: lib + +'use strict'; + +require('../assets/globals-107ab52e.css'); +require('../assets/fonts-4e5dc96c.css'); +require('../assets/styles-b11c3a83.css'); +function button() {} +exports.button = button; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (node, lib) 2`] = ` +[ + "package.json", + { + "main": "./lib/index.js", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (node, lib) 3`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (node, lib) 4`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (node, lib) 5`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (node, mjs) 1`] = ` +[ + "mjs/index.mjs", + "// Bundled with Packemon: https://packemon.dev +// Platform: node, Support: stable, Format: mjs + +import '../assets/globals-107ab52e.css'; +import '../assets/fonts-4e5dc96c.css'; +import '../assets/styles-b11c3a83.css'; +function button() {} +export { button }; +//# sourceMappingURL=index.mjs.map +", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (node, mjs) 2`] = ` +[ + "package.json", + { + "main": "./mjs/index.mjs", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (node, mjs) 3`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (node, mjs) 4`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (swc) bundle with assets bundles all files and references assets (node, mjs) 5`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (swc) bundle with assets uses same assets across multiple formats 1`] = ` +[ + "cjs/index.cjs", + "// Bundled with Packemon: https://packemon.dev +// Platform: node, Support: stable, Format: cjs + +'use strict'; + +require('../assets/globals-107ab52e.css'); +require('../assets/fonts-4e5dc96c.css'); +require('../assets/styles-b11c3a83.css'); +function button() {} +exports.button = button; +//# sourceMappingURL=index.cjs.map +", +] +`; + +exports[`Outputs (swc) bundle with assets uses same assets across multiple formats 2`] = ` +[ + "esm/index.js", + "// Bundled with Packemon: https://packemon.dev +// Platform: node, Support: stable, Format: esm + +import '../assets/globals-107ab52e.css'; +import '../assets/fonts-4e5dc96c.css'; +import '../assets/styles-b11c3a83.css'; +function button() {} +export { button }; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (swc) bundle with assets uses same assets across multiple formats 3`] = ` +[ + "lib/index.js", + "// Bundled with Packemon: https://packemon.dev +// Platform: node, Support: stable, Format: lib + +'use strict'; + +require('../assets/globals-107ab52e.css'); +require('../assets/fonts-4e5dc96c.css'); +require('../assets/styles-b11c3a83.css'); +function button() {} +exports.button = button; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (swc) bundle with assets uses same assets across multiple formats 4`] = ` +[ + "package.json", + { + "main": "./lib/index.js", + "module": "./esm/index.js", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, +] +`; + +exports[`Outputs (swc) bundle with assets uses same assets across multiple formats 5`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (swc) bundle with assets uses same assets across multiple formats 6`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (swc) bundle with assets uses same assets across multiple formats 7`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (swc) bundle with assets uses same assets across multiple formats 8`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (swc) bundle with assets uses same assets across multiple formats 9`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (swc) bundle with assets uses same assets across multiple formats 10`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (swc) bundle with assets uses same assets across multiple formats 11`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (swc) bundle with assets uses same assets across multiple formats 12`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (swc) bundle with assets uses same assets across multiple formats 13`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (swc) no bundle creates individual files for every source file 1`] = ` +[ + "lib/index.js", + "'use strict'; + +const other = require('./other.js'); +function bar() {} +exports.foo = other.foo; +exports.bar = bar; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (swc) no bundle creates individual files for every source file 2`] = ` +[ + "lib/not-imported.js", + "'use strict'; + +function baz() {} +exports.baz = baz; +//# sourceMappingURL=not-imported.js.map +", +] +`; + +exports[`Outputs (swc) no bundle creates individual files for every source file 3`] = ` +[ + "lib/other.js", + "'use strict'; + +function foo() {} +exports.foo = foo; +//# sourceMappingURL=other.js.map +", +] +`; + +exports[`Outputs (swc) no bundle creates individual files for every source file 4`] = ` +[ + "package.json", + { + "main": "./lib/index.js", + "name": "project-bundle", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, +] +`; + +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (browser, esm) 1`] = ` +[ + "esm/button/index.js", + "import '../../assets/styles-b11c3a83.css'; +function button() {} +export { button }; +//# sourceMappingURL=index.js.map ", ] `; -exports[`Outputs (swc) artifacts builds all the artifacts with rollup 2`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (browser, esm) 2`] = ` [ - "esm/client.js", - "function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } -function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } -function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } -function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } -// Bundled with Packemon: https://packemon.dev -// Platform: browser, Support: legacy, Format: esm -var Client = /*#__PURE__*/_createClass(function Client() { - _classCallCheck(this, Client); - _defineProperty(this, "prop", 123); -}); -function* gen() {} -async function wait() {} -async function createClient() { - await wait(); - var _iterator = _createForOfIteratorHelper(gen()), - _step; - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var iterator = _step.value; - console.log(iterator); - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - return new Client(); -} -export { createClient }; -//# sourceMappingURL=client.js.map + "esm/index.js", + "import '../assets/globals-107ab52e.css'; +import '../assets/fonts-4e5dc96c.css'; +export { button } from './button/index.js'; +//# sourceMappingURL=index.js.map ", ] `; -exports[`Outputs (swc) artifacts builds all the artifacts with rollup 3`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (browser, esm) 3`] = ` [ - "lib/client.js", - "// Bundled with Packemon: https://packemon.dev -// Platform: browser, Support: legacy, Format: lib + "package.json", + { + "main": "./esm/index.js", + "module": "./esm/index.js", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, +] +`; -'use strict'; +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (browser, esm) 4`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; -function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } -function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } -function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } -function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } -var Client = /*#__PURE__*/_createClass(function Client() { - _classCallCheck(this, Client); - _defineProperty(this, "prop", 123); -}); -function* gen() {} -async function wait() {} -async function createClient() { - await wait(); - var _iterator = _createForOfIteratorHelper(gen()), - _step; - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var iterator = _step.value; - console.log(iterator); - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - return new Client(); -} -exports.createClient = createClient; -//# sourceMappingURL=client.js.map -", +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (browser, esm) 5`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", ] `; -exports[`Outputs (swc) artifacts builds all the artifacts with rollup 4`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (browser, esm) 6`] = ` [ - "lib/index.js", - "// Bundled with Packemon: https://packemon.dev -// Platform: node, Support: stable, Format: lib + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; -'use strict'; +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (browser, lib) 1`] = ` +[ + "lib/button/index.js", + "'use strict'; -const EXAMPLE = 'foo'; -exports.EXAMPLE = EXAMPLE; +require('../../assets/styles-b11c3a83.css'); +function button() {} +exports.button = button; //# sourceMappingURL=index.js.map ", ] `; -exports[`Outputs (swc) artifacts builds all the artifacts with rollup 5`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (browser, lib) 2`] = ` [ - "lib/test.js", - "// Bundled with Packemon: https://packemon.dev -// Platform: native, Support: experimental, Format: lib - -'use strict'; + "lib/index.js", + "'use strict'; -class Spy { - called = false; - mock = () => {}; - method() {} -} -function spy() { - const inst = new Spy(); - return jest.fn(inst.mock); -} -async function wait() {} -exports.spy = spy; -exports.wait = wait; -//# sourceMappingURL=test.js.map +require('../assets/globals-107ab52e.css'); +require('../assets/fonts-4e5dc96c.css'); +const index = require('./button/index.js'); +exports.button = index.button; +//# sourceMappingURL=index.js.map ", ] `; -exports[`Outputs (swc) artifacts builds all the artifacts with rollup 6`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (browser, lib) 3`] = ` [ "package.json", { - "browser": "./umd/client.js", - "dependencies": { - "typescript": "*", + "main": "./lib/index.js", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", }, + }, +] +`; + +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (browser, lib) 4`] = ` +[ + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (browser, lib) 5`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (browser, lib) 6`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (browser, umd) 1`] = ` +[ + "package.json", + { + "browser": "./umd/index.js", "main": "./lib/index.js", - "module": "./esm/client.js", - "name": "project-rollup", + "name": "project-assets", "packemon": { - "inputs": { - "client": "src/client.ts", - "index": "src/index.ts", - "server": "src/server/core.ts", - "test": "src/test-utils/base.ts", - }, + "bundle": true, + "platform": "node", }, }, ] `; -exports[`Outputs (swc) artifacts builds all the artifacts with rollup 7`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (browser, umd) 2`] = ` [ - "umd/client.js", + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; + +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (browser, umd) 3`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (browser, umd) 4`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (browser, umd) 5`] = ` +[ + "umd/button/index.js", "(function (global, factory) { if (typeof define === "function" && define.amd) { - define("Packemon", ["exports"], factory); + define(["exports", "../../assets/styles-b11c3a83.css"], factory); } else if (typeof exports !== "undefined") { - factory(exports); + factory(exports, require("../../assets/styles-b11c3a83.css")); } else { var mod = { exports: {} }; - factory(mod.exports); - global.Packemon = mod.exports; + factory(mod.exports, global.stylesB11c3a83); + global.projectAssets = mod.exports; } -})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _stylesB11c3a) { "use strict"; Object.defineProperty(_exports, "__esModule", { value: true }); - _exports.createClient = createClient; - function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } - function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } - function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } - function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } - function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } - function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } - function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } - function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } - // Bundled with Packemon: https://packemon.dev - // Platform: browser, Support: legacy, Format: umd - var Client = /*#__PURE__*/_createClass(function Client() { - _classCallCheck(this, Client); - _defineProperty(this, "prop", 123); - }); - function* gen() {} - async function wait() {} - async function createClient() { - await wait(); - var _iterator = _createForOfIteratorHelper(gen()), - _step; - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var iterator = _step.value; - console.log(iterator); - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - return new Client(); + _exports.button = button; + function button() {} +}); +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (browser, umd) 6`] = ` +[ + "umd/index.js", + "(function (global, factory) { + if (typeof define === "function" && define.amd) { + define(["exports", "../assets/globals-107ab52e.css", "../assets/fonts-4e5dc96c.css", "./button/index.js"], factory); + } else if (typeof exports !== "undefined") { + factory(exports, require("../assets/globals-107ab52e.css"), require("../assets/fonts-4e5dc96c.css"), require("./button/index.js")); + } else { + var mod = { + exports: {} + }; + factory(mod.exports, global.globals107ab52e, global.fonts4e5dc96c, global.index); + global.projectAssets = mod.exports; } +})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _globals107ab52e, _fonts4e5dc96c, _index) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + Object.defineProperty(_exports, "button", { + enumerable: true, + get: function () { + return _index.button; + } + }); }); -//# sourceMappingURL=client.js.map +//# sourceMappingURL=index.js.map ", ] `; -exports[`Outputs (swc) artifacts builds all the artifacts with rollup 8`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (electron, esm) 1`] = ` [ - { - "format": "lib", - "stats": { - "size": 195, - }, - }, + "esm/button/index.js", + "import '../../assets/styles-b11c3a83.css'; +function button() {} +export { button }; +//# sourceMappingURL=index.js.map +", ] `; -exports[`Outputs (swc) bundle bundles all files into a single file with rollup 1`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (electron, esm) 2`] = ` [ - "lib/index.js", - "// Bundled with Packemon: https://packemon.dev -// Platform: node, Support: stable, Format: lib - -'use strict'; - -function foo() {} -function bar() {} -exports.bar = bar; -exports.foo = foo; + "esm/index.js", + "import '../assets/globals-107ab52e.css'; +import '../assets/fonts-4e5dc96c.css'; +export { button } from './button/index.js'; //# sourceMappingURL=index.js.map ", ] `; -exports[`Outputs (swc) bundle bundles all files into a single file with rollup 2`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (electron, esm) 3`] = ` [ "package.json", { - "main": "./lib/index.js", - "name": "project-bundle", + "main": "./esm/index.js", + "module": "./esm/index.js", + "name": "project-assets", "packemon": { "bundle": true, "platform": "node", @@ -859,17 +2738,33 @@ exports[`Outputs (swc) bundle bundles all files into a single file with rollup 2 ] `; -exports[`Outputs (swc) bundle with assets bundles all files and references assets 1`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (electron, esm) 4`] = ` [ - "lib/index.js", - "// Bundled with Packemon: https://packemon.dev -// Platform: node, Support: stable, Format: lib + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; -'use strict'; +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (electron, esm) 5`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; -require('../assets/globals-107ab52e.css'); -require('../assets/fonts-4e5dc96c.css'); -require('../assets/styles-a82c1676.css'); +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (electron, esm) 6`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (electron, lib) 1`] = ` +[ + "lib/button/index.js", + "'use strict'; + +require('../../assets/styles-b11c3a83.css'); function button() {} exports.button = button; //# sourceMappingURL=index.js.map @@ -877,7 +2772,21 @@ exports.button = button; ] `; -exports[`Outputs (swc) bundle with assets bundles all files and references assets 2`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (electron, lib) 2`] = ` +[ + "lib/index.js", + "'use strict'; + +require('../assets/globals-107ab52e.css'); +require('../assets/fonts-4e5dc96c.css'); +const index = require('./button/index.js'); +exports.button = index.button; +//# sourceMappingURL=index.js.map +", +] +`; + +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (electron, lib) 3`] = ` [ "package.json", { @@ -891,85 +2800,59 @@ exports[`Outputs (swc) bundle with assets bundles all files and references asset ] `; -exports[`Outputs (swc) bundle with assets bundles all files and references assets 3`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (electron, lib) 4`] = ` [ - "src/globals.css", - "assets/globals-107ab52e.css", + "src/button/styles.css", + "assets/styles-b11c3a83.css", ] `; -exports[`Outputs (swc) bundle with assets bundles all files and references assets 4`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (electron, lib) 5`] = ` [ - "src/shared/fonts.css", - "assets/fonts-4e5dc96c.css", + "src/globals.css", + "assets/globals-107ab52e.css", ] `; -exports[`Outputs (swc) bundle with assets bundles all files and references assets 5`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (electron, lib) 6`] = ` [ - "src/styles.css", - "assets/styles-a82c1676.css", + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", ] `; -exports[`Outputs (swc) bundle with assets uses same assets across multiple formats 1`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (native, lib) 1`] = ` [ - "cjs/index.cjs", - "// Bundled with Packemon: https://packemon.dev -// Platform: node, Support: stable, Format: cjs - -'use strict'; + "lib/button/index.js", + "'use strict'; -require('../assets/globals-107ab52e.css'); -require('../assets/fonts-4e5dc96c.css'); -require('../assets/styles-a82c1676.css'); +require('../../assets/styles-b11c3a83.css'); function button() {} exports.button = button; -//# sourceMappingURL=index.cjs.map -", -] -`; - -exports[`Outputs (swc) bundle with assets uses same assets across multiple formats 2`] = ` -[ - "esm/index.js", - "// Bundled with Packemon: https://packemon.dev -// Platform: node, Support: stable, Format: esm - -import '../assets/globals-107ab52e.css'; -import '../assets/fonts-4e5dc96c.css'; -import '../assets/styles-a82c1676.css'; -function button() {} -export { button }; //# sourceMappingURL=index.js.map ", ] `; -exports[`Outputs (swc) bundle with assets uses same assets across multiple formats 3`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (native, lib) 2`] = ` [ "lib/index.js", - "// Bundled with Packemon: https://packemon.dev -// Platform: node, Support: stable, Format: lib - -'use strict'; + "'use strict'; require('../assets/globals-107ab52e.css'); require('../assets/fonts-4e5dc96c.css'); -require('../assets/styles-a82c1676.css'); -function button() {} -exports.button = button; +const index = require('./button/index.js'); +exports.button = index.button; //# sourceMappingURL=index.js.map ", ] `; -exports[`Outputs (swc) bundle with assets uses same assets across multiple formats 4`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (native, lib) 3`] = ` [ "package.json", { "main": "./lib/index.js", - "module": "./esm/index.js", "name": "project-assets", "packemon": { "bundle": true, @@ -979,113 +2862,122 @@ exports[`Outputs (swc) bundle with assets uses same assets across multiple forma ] `; -exports[`Outputs (swc) bundle with assets uses same assets across multiple formats 5`] = ` -[ - "src/globals.css", - "assets/globals-107ab52e.css", -] -`; - -exports[`Outputs (swc) bundle with assets uses same assets across multiple formats 6`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (native, lib) 4`] = ` [ - "src/globals.css", - "assets/globals-107ab52e.css", + "src/button/styles.css", + "assets/styles-b11c3a83.css", ] `; -exports[`Outputs (swc) bundle with assets uses same assets across multiple formats 7`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (native, lib) 5`] = ` [ "src/globals.css", "assets/globals-107ab52e.css", ] `; -exports[`Outputs (swc) bundle with assets uses same assets across multiple formats 8`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (native, lib) 6`] = ` [ "src/shared/fonts.css", "assets/fonts-4e5dc96c.css", ] `; -exports[`Outputs (swc) bundle with assets uses same assets across multiple formats 9`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (node, cjs) 1`] = ` [ - "src/shared/fonts.css", - "assets/fonts-4e5dc96c.css", + "cjs/button/index.cjs", + "'use strict'; + +require('../../assets/styles-b11c3a83.css'); +function button() {} +exports.button = button; +//# sourceMappingURL=index.cjs.map +", ] `; -exports[`Outputs (swc) bundle with assets uses same assets across multiple formats 10`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (node, cjs) 2`] = ` [ - "src/shared/fonts.css", - "assets/fonts-4e5dc96c.css", + "cjs/index.cjs", + "'use strict'; + +require('../assets/globals-107ab52e.css'); +require('../assets/fonts-4e5dc96c.css'); +const index = require('./button/index.cjs'); +exports.button = index.button; +//# sourceMappingURL=index.cjs.map +", ] `; -exports[`Outputs (swc) bundle with assets uses same assets across multiple formats 11`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (node, cjs) 3`] = ` [ - "src/styles.css", - "assets/styles-a82c1676.css", + "package.json", + { + "main": "./cjs/index.cjs", + "name": "project-assets", + "packemon": { + "bundle": true, + "platform": "node", + }, + }, ] `; -exports[`Outputs (swc) bundle with assets uses same assets across multiple formats 12`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (node, cjs) 4`] = ` [ - "src/styles.css", - "assets/styles-a82c1676.css", + "src/button/styles.css", + "assets/styles-b11c3a83.css", ] `; -exports[`Outputs (swc) bundle with assets uses same assets across multiple formats 13`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (node, cjs) 5`] = ` [ - "src/styles.css", - "assets/styles-a82c1676.css", + "src/globals.css", + "assets/globals-107ab52e.css", ] `; -exports[`Outputs (swc) no bundle creates individual files for every source file 1`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (node, cjs) 6`] = ` [ - "lib/index.js", - "'use strict'; - -const other = require('./other.js'); -function bar() {} -exports.foo = other.foo; -exports.bar = bar; -//# sourceMappingURL=index.js.map -", + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", ] `; -exports[`Outputs (swc) no bundle creates individual files for every source file 2`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (node, lib) 1`] = ` [ - "lib/not-imported.js", + "lib/button/index.js", "'use strict'; -function baz() {} -exports.baz = baz; -//# sourceMappingURL=not-imported.js.map +require('../../assets/styles-b11c3a83.css'); +function button() {} +exports.button = button; +//# sourceMappingURL=index.js.map ", ] `; -exports[`Outputs (swc) no bundle creates individual files for every source file 3`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (node, lib) 2`] = ` [ - "lib/other.js", + "lib/index.js", "'use strict'; -function foo() {} -exports.foo = foo; -//# sourceMappingURL=other.js.map +require('../assets/globals-107ab52e.css'); +require('../assets/fonts-4e5dc96c.css'); +const index = require('./button/index.js'); +exports.button = index.button; +//# sourceMappingURL=index.js.map ", ] `; -exports[`Outputs (swc) no bundle creates individual files for every source file 4`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (node, lib) 3`] = ` [ "package.json", { "main": "./lib/index.js", - "name": "project-bundle", + "name": "project-assets", "packemon": { "bundle": true, "platform": "node", @@ -1094,38 +2986,54 @@ exports[`Outputs (swc) no bundle creates individual files for every source file ] `; -exports[`Outputs (swc) no bundle with assets creates individual files and references assets 1`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (node, lib) 4`] = ` [ - "lib/button/index.js", - "'use strict'; + "src/button/styles.css", + "assets/styles-b11c3a83.css", +] +`; -require('../../assets/styles-b11c3a83.css'); +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (node, lib) 5`] = ` +[ + "src/globals.css", + "assets/globals-107ab52e.css", +] +`; + +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (node, lib) 6`] = ` +[ + "src/shared/fonts.css", + "assets/fonts-4e5dc96c.css", +] +`; + +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (node, mjs) 1`] = ` +[ + "mjs/button/index.mjs", + "import '../../assets/styles-b11c3a83.css'; function button() {} -exports.button = button; -//# sourceMappingURL=index.js.map +export { button }; +//# sourceMappingURL=index.mjs.map ", ] `; -exports[`Outputs (swc) no bundle with assets creates individual files and references assets 2`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (node, mjs) 2`] = ` [ - "lib/index.js", - "'use strict'; - -require('../assets/globals-107ab52e.css'); -require('../assets/fonts-4e5dc96c.css'); -const index = require('./button/index.js'); -exports.button = index.button; -//# sourceMappingURL=index.js.map + "mjs/index.mjs", + "import '../assets/globals-107ab52e.css'; +import '../assets/fonts-4e5dc96c.css'; +export { button } from './button/index.mjs'; +//# sourceMappingURL=index.mjs.map ", ] `; -exports[`Outputs (swc) no bundle with assets creates individual files and references assets 3`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (node, mjs) 3`] = ` [ "package.json", { - "main": "./lib/index.js", + "main": "./mjs/index.mjs", "name": "project-assets", "packemon": { "bundle": true, @@ -1135,21 +3043,21 @@ exports[`Outputs (swc) no bundle with assets creates individual files and refere ] `; -exports[`Outputs (swc) no bundle with assets creates individual files and references assets 4`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (node, mjs) 4`] = ` [ "src/button/styles.css", "assets/styles-b11c3a83.css", ] `; -exports[`Outputs (swc) no bundle with assets creates individual files and references assets 5`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (node, mjs) 5`] = ` [ "src/globals.css", "assets/globals-107ab52e.css", ] `; -exports[`Outputs (swc) no bundle with assets creates individual files and references assets 6`] = ` +exports[`Outputs (swc) no bundle with assets creates individual files and references assets (node, mjs) 6`] = ` [ "src/shared/fonts.css", "assets/fonts-4e5dc96c.css", diff --git a/packages/packemon/tests/helpers.ts b/packages/packemon/tests/helpers.ts index b920a0b7d..680f19e4d 100644 --- a/packages/packemon/tests/helpers.ts +++ b/packages/packemon/tests/helpers.ts @@ -38,13 +38,12 @@ export function getFixturePath(fixture: string, file: string = ''): string { return path.normalize(path.join(...[FIXTURES_DIR, fixture, file].map(normalizeSeparators))); } -const builds = new Map(); +export const BUILDS = new Map(); +export const BUILDS_NO_SUPPORT = new Map(); FORMATS.forEach((format) => { PLATFORMS.forEach((platform) => { SUPPORTS.forEach((support) => { - const key = `${format}:${platform}:${support}`; - if ( (platform === 'browser' && !(FORMATS_BROWSER as string[]).includes(format)) || (platform === 'electron' && !(FORMATS_ELECTRON as string[]).includes(format)) || @@ -54,11 +53,16 @@ FORMATS.forEach((format) => { return; } - builds.set(key, { + BUILDS.set(`${format}:${platform}:${support}`, { format, platform, support, }); + + BUILDS_NO_SUPPORT.set(`${format}:${platform}`, { + format, + platform, + }); }); }); }); @@ -171,7 +175,7 @@ export function testExampleOutput( delete process.env.PACKEMON_SWC; }); - [...builds.values()].forEach((build) => { + [...BUILDS.values()].forEach((build) => { const pkg = loadPackageAtPath(root); const env = `${build.platform}-${build.support}-${build.format}`; diff --git a/packages/packemon/tests/outputs.test.ts b/packages/packemon/tests/outputs.test.ts index 9733add25..745db74e8 100644 --- a/packages/packemon/tests/outputs.test.ts +++ b/packages/packemon/tests/outputs.test.ts @@ -1,9 +1,12 @@ -/* eslint-disable jest/no-conditional-in-test */ - import fs from 'node:fs'; import { Path } from '@boost/common'; import { Artifact } from '../src'; -import { createSnapshotSpies, getFixturePath, loadPackageAtPath } from './helpers'; +import { + BUILDS_NO_SUPPORT, + createSnapshotSpies, + getFixturePath, + loadPackageAtPath, +} from './helpers'; ['babel', 'swc'].forEach((transformer) => { describe(`Outputs (${transformer})`, () => { @@ -80,28 +83,23 @@ import { createSnapshotSpies, getFixturePath, loadPackageAtPath } from './helper const root = new Path(getFixturePath('project-assets')); const snapshots = createSnapshotSpies(root, true); - it('bundles all files and references assets', async () => { - const pkg = loadPackageAtPath(root); - - const index = new Artifact(pkg, [{ format: 'lib' }]); - index.bundle = true; - index.platform = 'node'; - index.support = 'stable'; - index.inputs = { index: 'src/index.ts' }; + BUILDS_NO_SUPPORT.forEach((build) => { + it(`bundles all files and references assets (${build.platform}, ${build.format})`, async () => { + const pkg = loadPackageAtPath(root); - pkg.artifacts.push(index); + const index = new Artifact(pkg, [{ format: build.format }]); + index.bundle = true; + index.platform = build.platform; + index.support = 'stable'; + index.inputs = { index: 'src/index.ts' }; - await pkg.build({}, {}); + pkg.artifacts.push(index); - snapshots(pkg).forEach((ss) => { - expect(ss).toMatchSnapshot(); + await pkg.build({}, {}); - // Check import paths are correct - if (ss[0].endsWith('index.js')) { - expect(String(ss[1])).toContain("'../assets/globals-107ab52e.css'"); - expect(String(ss[1])).toContain("'../assets/fonts-4e5dc96c.css'"); - expect(String(ss[1])).toContain("'../assets/styles-a82c1676.css'"); - } + snapshots(pkg).forEach((ss) => { + expect(ss).toMatchSnapshot(); + }); }); }); @@ -151,31 +149,23 @@ import { createSnapshotSpies, getFixturePath, loadPackageAtPath } from './helper const root = new Path(getFixturePath('project-assets')); const snapshots = createSnapshotSpies(root, true); - it('creates individual files and references assets', async () => { - const pkg = loadPackageAtPath(root); - - const index = new Artifact(pkg, [{ format: 'lib' }]); - index.bundle = false; - index.platform = 'node'; - index.support = 'stable'; - index.inputs = { index: 'src/index.ts' }; - - pkg.artifacts.push(index); + BUILDS_NO_SUPPORT.forEach((build) => { + it(`creates individual files and references assets (${build.platform}, ${build.format})`, async () => { + const pkg = loadPackageAtPath(root); - await pkg.build({}, {}); + const index = new Artifact(pkg, [{ format: build.format }]); + index.bundle = false; + index.platform = build.platform; + index.support = 'stable'; + index.inputs = { index: 'src/index.ts' }; - snapshots(pkg).forEach((ss) => { - expect(ss).toMatchSnapshot(); + pkg.artifacts.push(index); - // Check import paths are correct - if (ss[0].endsWith('lib/index2.js')) { - expect(String(ss[1])).toContain("'../assets/globals-107ab52e.css'"); - expect(String(ss[1])).toContain("'../assets/fonts-4e5dc96c.css'"); - } + await pkg.build({}, {}); - if (ss[0].endsWith('lib/button/index2.js')) { - expect(String(ss[1])).toContain("'../../assets/styles-a82c1676.css'"); - } + snapshots(pkg).forEach((ss) => { + expect(ss).toMatchSnapshot(); + }); }); }); });