@embroider/addon-dev 8.4.1 → 8.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +2 -2
  2. package/package.json +2 -2
  3. package/src/commands.d.ts +3 -0
  4. package/src/commands.js +70 -0
  5. package/src/commands.js.map +1 -0
  6. package/src/rollup-addon-dependencies.d.ts +3 -0
  7. package/src/rollup-addon-dependencies.js +46 -0
  8. package/src/rollup-addon-dependencies.js.map +1 -0
  9. package/src/rollup-app-reexports.d.ts +10 -0
  10. package/src/rollup-app-reexports.js +51 -0
  11. package/src/rollup-app-reexports.js.map +1 -0
  12. package/src/rollup-declarations.d.ts +10 -0
  13. package/src/rollup-declarations.js +134 -0
  14. package/src/rollup-declarations.js.map +1 -0
  15. package/src/rollup-gjs-plugin.d.ts +3 -0
  16. package/src/rollup-gjs-plugin.js +36 -0
  17. package/src/rollup-gjs-plugin.js.map +1 -0
  18. package/src/rollup-hbs-plugin.d.ts +5 -0
  19. package/src/rollup-hbs-plugin.js +105 -0
  20. package/src/rollup-hbs-plugin.js.map +1 -0
  21. package/src/rollup-incremental-plugin.d.ts +3 -0
  22. package/src/rollup-incremental-plugin.js +76 -0
  23. package/src/rollup-incremental-plugin.js.map +1 -0
  24. package/src/rollup-keep-assets.d.ts +7 -0
  25. package/src/rollup-keep-assets.js +110 -0
  26. package/src/rollup-keep-assets.js.map +1 -0
  27. package/src/rollup-public-assets.d.ts +23 -0
  28. package/src/rollup-public-assets.js +51 -0
  29. package/src/rollup-public-assets.js.map +1 -0
  30. package/src/rollup-public-entrypoints.d.ts +7 -0
  31. package/src/rollup-public-entrypoints.js +83 -0
  32. package/src/rollup-public-entrypoints.js.map +1 -0
  33. package/src/rollup.d.ts +33 -0
  34. package/src/rollup.js +116 -0
  35. package/src/rollup.js.map +1 -0
  36. package/src/template-colocation-plugin.d.ts +4 -0
  37. package/src/template-colocation-plugin.js +5 -0
  38. package/src/template-colocation-plugin.js.map +1 -0
package/README.md CHANGED
@@ -19,7 +19,7 @@ For a guide on porting a V1 addon to V2, see https://github.com/embroider-build/
19
19
 
20
20
  ### addon.publicAssets(path <required>, options)
21
21
 
22
- A rollup plugin to expose a folder of assets. `path` is a required to define which folder to expose. `options.include` is a glob pattern passed to `walkSync.include` to pick files. `options.exlude` is a glob pattern passed to `walkSync.ignore` to exclude files. `options.namespace` is the namespace to expose files, defaults to the package name + the path that you provided e.g. if you call `addon.publicAssets('public')` in a v2 addon named `super-addon` then your namespace will default to `super-addon/public`.
22
+ A rollup plugin to expose a folder of assets. `path` is required to define which folder to expose. `options.include` is a glob pattern passed to `walkSync.include` to pick files. `options.exclude` is a glob pattern passed to `walkSync.ignore` to exclude files. `options.namespace` is the namespace to expose files, defaults to the package name + the path that you provided e.g. if you call `addon.publicAssets('public')` in a v2 addon named `super-addon` then your namespace will default to `super-addon/public`.
23
23
 
24
24
  ### addon.keepAssets(patterns: string[], exports?: 'default' | '*')
25
25
 
@@ -39,7 +39,7 @@ The `exports` option defaults to `undefined` which means the assets are used for
39
39
  addon.keepAssets(["**/*.png"], "default")
40
40
  ```
41
41
 
42
- lets you say `import imageURL from './my-image.png'`. Not that this pattern is **not** automatically supported in V2 addons and you would need to tell apps that consume your addon to handle it in a custom way.
42
+ lets you say `import imageURL from './my-image.png'`. Note that this pattern is **not** automatically supported in V2 addons and you would need to tell apps that consume your addon to handle it in a custom way.
43
43
 
44
44
  ## addon-dev command
45
45
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embroider/addon-dev",
3
- "version": "8.4.1",
3
+ "version": "8.4.2",
4
4
  "description": "Utilities for addon authors",
5
5
  "repository": {
6
6
  "type": "git",
@@ -39,7 +39,7 @@
39
39
  "rollup-plugin-copy-assets": "^2.0.3",
40
40
  "walk-sync": "^3.0.0",
41
41
  "yargs": "^17.0.1",
42
- "@embroider/core": "^4.6.8"
42
+ "@embroider/core": "^4.6.9"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@glimmer/syntax": "^0.94.9",
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=commands.d.ts.map
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const fs_extra_1 = require("fs-extra");
8
+ const path_1 = require("path");
9
+ const yargs_1 = __importDefault(require("yargs/yargs"));
10
+ function commonArgs(yargs) {
11
+ return yargs
12
+ .option('testAppDir', {
13
+ type: 'string',
14
+ description: 'Path to the test app',
15
+ default: 'test-app',
16
+ })
17
+ .option('addonDir', {
18
+ type: 'string',
19
+ description: 'Path to your addon',
20
+ default: process.cwd(),
21
+ });
22
+ }
23
+ (0, yargs_1.default)(process.argv.slice(2))
24
+ .scriptName('addon-dev')
25
+ .command('link-test-app', 'Ensures that a test app (that lives a subdir under an addon) has access to the addon and all appropriate deps', (yargs) => commonArgs(yargs), function (opts) {
26
+ let { testAppDir, addonDir } = opts;
27
+ (0, fs_extra_1.ensureSymlinkSync)((0, path_1.join)(addonDir, 'node_modules', '.bin'), (0, path_1.join)(testAppDir, 'node_modules', '.bin'), 'dir');
28
+ (0, fs_extra_1.ensureSymlinkSync)(addonDir, (0, path_1.join)(testAppDir, 'node_modules', (0, fs_extra_1.readJSONSync)((0, path_1.join)(addonDir, 'package.json')).name));
29
+ })
30
+ .command('sync-dev-deps', `Synchronizes a test app's devDependencies into the parent addon's devDependencies`, (yargs) => {
31
+ return commonArgs(yargs).option('lint', {
32
+ type: 'boolean',
33
+ description: 'Instead of modifying package.json, print what would have been modified and exit with a failure if any changes are required.',
34
+ default: false,
35
+ });
36
+ }, function (opts) {
37
+ let { testAppDir, addonDir, lint } = opts;
38
+ let addonPkg = (0, fs_extra_1.readJSONSync)((0, path_1.join)(addonDir, 'package.json'));
39
+ let testPkg = (0, fs_extra_1.readJSONSync)((0, path_1.join)(testAppDir, 'package.json'));
40
+ let foundDifferences = false;
41
+ let devDeps = Object.assign({}, addonPkg.devDependencies);
42
+ for (let [name, range] of Object.entries(testPkg.devDependencies)) {
43
+ if (name === addonPkg.name) {
44
+ continue;
45
+ }
46
+ if (devDeps[name] !== range) {
47
+ foundDifferences = true;
48
+ if (lint) {
49
+ console.error(`test app depends on ${name} ${range} but that is not present in addon's devDependencies package.json`);
50
+ }
51
+ else {
52
+ devDeps[name] = range;
53
+ }
54
+ }
55
+ }
56
+ if (!foundDifferences) {
57
+ return;
58
+ }
59
+ if (lint) {
60
+ process.exit(-1);
61
+ }
62
+ else {
63
+ addonPkg.devDependencies = devDeps;
64
+ (0, fs_extra_1.writeJSONSync)((0, path_1.join)(addonDir, 'package.json'), addonPkg, { spaces: 2 });
65
+ }
66
+ })
67
+ .demandCommand()
68
+ .strictCommands()
69
+ .help().argv;
70
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.js","sourceRoot":"","sources":["commands.ts"],"names":[],"mappings":";;;;;;AAEA,uCAA0E;AAC1E,+BAA4B;AAC5B,wDAAgC;AAGhC,SAAS,UAAU,CAAC,KAAW;IAC7B,OAAO,KAAK;SACT,MAAM,CAAC,YAAY,EAAE;QACpB,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,sBAAsB;QACnC,OAAO,EAAE,UAAU;KACpB,CAAC;SACD,MAAM,CAAC,UAAU,EAAE;QAClB,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,oBAAoB;QACjC,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE;KACvB,CAAC,CAAC;AACP,CAAC;AAED,IAAA,eAAK,EAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KACzB,UAAU,CAAC,WAAW,CAAC;KACvB,OAAO,CACN,eAAe,EACf,+GAA+G,EAC/G,CAAC,KAAK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EAAE,CAAC;QACF,IAAI,IAAI,KAAK,QAAQ,CAAC,IAAI,EAAE,CAAC;YAC3B,SAAS;QACX,CAAC;QACD,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC;YAC5B,gBAAgB,GAAG,IAAI,CAAC;YACxB,IAAI,IAAI,EAAE,CAAC;gBACT,OAAO,CAAC,KAAK,CACX,uBAAuB,IAAI,IAAI,KAAK,kEAAkE,CACvG,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;YACxB,CAAC;QACH,CAAC;IACH,CAAC;IACD,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,OAAO;IACT,CAAC;IACD,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC;SAAM,CAAC;QACN,QAAQ,CAAC,eAAe,GAAG,OAAO,CAAC;QACnC,IAAA,wBAAa,EAAC,IAAA,WAAI,EAAC,QAAQ,EAAE,cAAc,CAAC,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;IACzE,CAAC;AACH,CAAC,CACF;KACA,aAAa,EAAE;KACf,cAAc,EAAE;KAChB,IAAI,EAAE,CAAC,IAAI,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport { ensureSymlinkSync, readJSONSync, writeJSONSync } from 'fs-extra';\nimport { join } from 'path';\nimport yargs from 'yargs/yargs';\nimport type { Argv } from 'yargs';\n\nfunction commonArgs(yargs: Argv) {\n return yargs\n .option('testAppDir', {\n type: 'string',\n description: 'Path to the test app',\n default: 'test-app',\n })\n .option('addonDir', {\n type: 'string',\n description: 'Path to your addon',\n default: process.cwd(),\n });\n}\n\nyargs(process.argv.slice(2))\n .scriptName('addon-dev')\n .command(\n 'link-test-app',\n 'Ensures that a test app (that lives a subdir under an addon) has access to the addon and all appropriate deps',\n (yargs) => commonArgs(yargs),\n function (opts) {\n let { testAppDir, addonDir } = opts;\n ensureSymlinkSync(\n join(addonDir, 'node_modules', '.bin'),\n join(testAppDir, 'node_modules', '.bin'),\n 'dir'\n );\n ensureSymlinkSync(\n addonDir,\n join(\n testAppDir,\n 'node_modules',\n readJSONSync(join(addonDir, 'package.json')).name\n )\n );\n }\n )\n .command(\n 'sync-dev-deps',\n `Synchronizes a test app's devDependencies into the parent addon's devDependencies`,\n (yargs) => {\n return commonArgs(yargs).option('lint', {\n type: 'boolean',\n description:\n 'Instead of modifying package.json, print what would have been modified and exit with a failure if any changes are required.',\n default: false,\n });\n },\n function (opts) {\n let { testAppDir, addonDir, lint } = opts;\n let addonPkg = readJSONSync(join(addonDir, 'package.json'));\n let testPkg = readJSONSync(join(testAppDir, 'package.json'));\n let foundDifferences = false;\n let devDeps: { [name: string]: string } = Object.assign(\n {},\n addonPkg.devDependencies\n );\n for (let [name, range] of Object.entries(\n testPkg.devDependencies as { [name: string]: string }\n )) {\n if (name === addonPkg.name) {\n continue;\n }\n if (devDeps[name] !== range) {\n foundDifferences = true;\n if (lint) {\n console.error(\n `test app depends on ${name} ${range} but that is not present in addon's devDependencies package.json`\n );\n } else {\n devDeps[name] = range;\n }\n }\n }\n if (!foundDifferences) {\n return;\n }\n if (lint) {\n process.exit(-1);\n } else {\n addonPkg.devDependencies = devDeps;\n writeJSONSync(join(addonDir, 'package.json'), addonPkg, { spaces: 2 });\n }\n }\n )\n .demandCommand()\n .strictCommands()\n .help().argv;\n"]}
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from 'rollup';
2
+ export default function emberExternals(): Plugin;
3
+ //# sourceMappingURL=rollup-addon-dependencies.d.ts.map
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = emberExternals;
4
+ const fs_extra_1 = require("fs-extra");
5
+ const core_1 = require("@embroider/core");
6
+ const compilationModules = new Set(core_1.templateCompilationModules.map((m) => m.module));
7
+ function resolvableDependencies() {
8
+ let deps = new Set();
9
+ let pkg = (0, fs_extra_1.readJsonSync)('package.json');
10
+ if (pkg.dependencies) {
11
+ for (let name of Object.keys(pkg.dependencies)) {
12
+ deps.add(name);
13
+ }
14
+ }
15
+ if (pkg.peerDependencies) {
16
+ for (let name of Object.keys(pkg.peerDependencies)) {
17
+ deps.add(name);
18
+ }
19
+ }
20
+ return deps;
21
+ }
22
+ function emberExternals() {
23
+ let deps;
24
+ return {
25
+ name: 'ember-externals',
26
+ buildStart() {
27
+ this.addWatchFile('package.json');
28
+ deps = resolvableDependencies();
29
+ },
30
+ async resolveId(source) {
31
+ let pkgName = (0, core_1.packageName)(source);
32
+ if (!pkgName) {
33
+ // No package name found means this is a relative import, which we don't
34
+ // need to deal with.
35
+ return;
36
+ }
37
+ if (deps.has(pkgName) ||
38
+ core_1.emberVirtualPeerDeps.has(pkgName) ||
39
+ core_1.emberVirtualPackages.has(pkgName) ||
40
+ compilationModules.has(pkgName)) {
41
+ return { id: source, external: true };
42
+ }
43
+ },
44
+ };
45
+ }
46
+ //# sourceMappingURL=rollup-addon-dependencies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rollup-addon-dependencies.js","sourceRoot":"","sources":["rollup-addon-dependencies.ts"],"names":[],"mappings":";;AA6BA,iCA6BC;AAzDD,uCAAwC;AACxC,0CAKyB;AAEzB,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAChC,iCAA0B,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAChD,CAAC;AAEF,SAAS,sBAAsB;IAC7B,IAAI,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC7B,IAAI,GAAG,GAAG,IAAA,uBAAY,EAAC,cAAc,CAAC,CAAC;IACvC,IAAI,GAAG,CAAC,YAAY,EAAE,CAAC;QACrB,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;YAC/C,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC;IACH,CAAC;IACD,IAAI,GAAG,CAAC,gBAAgB,EAAE,CAAC;QACzB,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE,CAAC;YACnD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAwB,cAAc;IACpC,IAAI,IAAiB,CAAC;IAEtB,OAAO;QACL,IAAI,EAAE,iBAAiB;QAEvB,UAAU;YACR,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;YAClC,IAAI,GAAG,sBAAsB,EAAE,CAAC;QAClC,CAAC;QAED,KAAK,CAAC,SAAS,CAAC,MAAM;YACpB,IAAI,OAAO,GAAG,IAAA,kBAAW,EAAC,MAAM,CAAC,CAAC;YAClC,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,wEAAwE;gBACxE,qBAAqB;gBACrB,OAAO;YACT,CAAC;YAED,IACE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;gBACjB,2BAAoB,CAAC,GAAG,CAAC,OAAO,CAAC;gBACjC,2BAAoB,CAAC,GAAG,CAAC,OAAO,CAAC;gBACjC,kBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC,EAC/B,CAAC;gBACD,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;YACxC,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { Plugin } from 'rollup';\nimport { readJsonSync } from 'fs-extra';\nimport {\n emberVirtualPackages,\n emberVirtualPeerDeps,\n packageName,\n templateCompilationModules,\n} from '@embroider/core';\n\nconst compilationModules = new Set(\n templateCompilationModules.map((m) => m.module)\n);\n\nfunction resolvableDependencies(): Set<string> {\n let deps = new Set<string>();\n let pkg = readJsonSync('package.json');\n if (pkg.dependencies) {\n for (let name of Object.keys(pkg.dependencies)) {\n deps.add(name);\n }\n }\n if (pkg.peerDependencies) {\n for (let name of Object.keys(pkg.peerDependencies)) {\n deps.add(name);\n }\n }\n return deps;\n}\n\nexport default function emberExternals(): Plugin {\n let deps: Set<string>;\n\n return {\n name: 'ember-externals',\n\n buildStart() {\n this.addWatchFile('package.json');\n deps = resolvableDependencies();\n },\n\n async resolveId(source) {\n let pkgName = packageName(source);\n if (!pkgName) {\n // No package name found means this is a relative import, which we don't\n // need to deal with.\n return;\n }\n\n if (\n deps.has(pkgName) ||\n emberVirtualPeerDeps.has(pkgName) ||\n emberVirtualPackages.has(pkgName) ||\n compilationModules.has(pkgName)\n ) {\n return { id: source, external: true };\n }\n },\n };\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import type { Plugin } from 'rollup';
2
+ export default function appReexports(opts: {
3
+ from: string;
4
+ to: string;
5
+ include: string[];
6
+ exclude?: string[];
7
+ mapFilename?: (filename: string) => string;
8
+ exports?: (filename: string) => string[] | string | undefined;
9
+ }): Plugin;
10
+ //# sourceMappingURL=rollup-app-reexports.d.ts.map
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = appReexports;
7
+ const fs_extra_1 = require("fs-extra");
8
+ const path_1 = require("path");
9
+ const minimatch_1 = __importDefault(require("minimatch"));
10
+ function symmetricDifference(arr1, arr2) {
11
+ return arr1
12
+ .filter((x) => !arr2.includes(x))
13
+ .concat(arr2.filter((x) => !arr1.includes(x)));
14
+ }
15
+ function appReexports(opts) {
16
+ return {
17
+ name: 'app-reexports',
18
+ generateBundle(_, bundle) {
19
+ var _a, _b, _c, _d, _e, _f;
20
+ let pkg = (0, fs_extra_1.readJsonSync)('package.json');
21
+ let appJS = {};
22
+ for (let addonFilename of Object.keys(bundle)) {
23
+ let appFilename = (_b = (_a = opts.mapFilename) === null || _a === void 0 ? void 0 : _a.call(opts, addonFilename)) !== null && _b !== void 0 ? _b : addonFilename;
24
+ let appExports = ((_c = opts.exports) === null || _c === void 0 ? void 0 : _c.call(opts, addonFilename)) || ['default'];
25
+ let computedExports = typeof appExports === 'string'
26
+ ? appExports
27
+ : `{ ${appExports.join(', ')} }`;
28
+ if (opts.include.some((glob) => (0, minimatch_1.default)(addonFilename, glob)) &&
29
+ !(0, minimatch_1.default)(addonFilename, '**/*.d.ts') &&
30
+ ((_d = opts.exclude) === null || _d === void 0 ? void 0 : _d.some((glob) => (0, minimatch_1.default)(addonFilename, glob))) !== true) {
31
+ appJS[`./${appFilename}`] = `./dist/_app_/${appFilename}`;
32
+ this.emitFile({
33
+ type: 'asset',
34
+ fileName: `_app_/${appFilename}`,
35
+ source: `export ${computedExports} from "${pkg.name}/${addonFilename.slice(0, -(0, path_1.extname)(addonFilename).length)}";\n`,
36
+ });
37
+ }
38
+ }
39
+ let originalAppJS = (_f = (_e = pkg['ember-addon']) === null || _e === void 0 ? void 0 : _e['app-js']) !== null && _f !== void 0 ? _f : {};
40
+ let hasChanges = !!symmetricDifference(Object.keys(originalAppJS), Object.keys(appJS)).length;
41
+ // Don't cause a file i/o event unless something actually changed
42
+ if (hasChanges) {
43
+ pkg['ember-addon'] = Object.assign({}, pkg['ember-addon'], {
44
+ 'app-js': appJS,
45
+ });
46
+ (0, fs_extra_1.writeJsonSync)('package.json', pkg, { spaces: 2 });
47
+ }
48
+ },
49
+ };
50
+ }
51
+ //# sourceMappingURL=rollup-app-reexports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rollup-app-reexports.js","sourceRoot":"","sources":["rollup-app-reexports.ts"],"names":[],"mappings":";;;;;AAWA,+BAqDC;AAhED,uCAAuD;AACvD,+BAA+B;AAC/B,0DAAkC;AAGlC,SAAS,mBAAmB,CAAC,IAAW,EAAE,IAAW;IACnD,OAAO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AAK,CAAC,KAAK,WAAW,EAAE,CAAC,GAAG,gBAAgB,WAAW,EAAE,CAAC;oBAC1D,IAAI,CAAC,QAAQ,CAAC;wBACZ,IAAI,EAAE,OAAO;wBACb,QAAQ,EAAE,SAAS,WAAW,EAAE;wBAChC,MAAM,EAAE,UAAU,eAAe,UAC/B,GAAG,CAAC,IACN,IAAI,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,IAAA,cAAO,EAAC,aAAa,CAAC,CAAC,MAAM,CAAC,MAAM;qBACjE,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YACD,IAAI,aAAa,GAAG,MAAA,MAAA,GAAG,CAAC,aAAa,CAAC,0CAAG,QAAQ,CAAC,mCAAI,EAAE,CAAC;YAEzD,IAAI,UAAU,GAAG,CAAC,CAAC,mBAAmB,CACpC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,EAC1B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CACnB,CAAC,MAAM,CAAC;YAET,iEAAiE;YACjE,IAAI,UAAU,EAAE,CAAC;gBACf,GAAG,CAAC,aAAa,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,aAAa,CAAC,EAAE;oBACzD,QAAQ,EAAE,KAAK;iBAChB,CAAC,CAAC;gBACH,IAAA,wBAAa,EAAC,cAAc,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;YACpD,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { readJsonSync, writeJsonSync } from 'fs-extra';\nimport { extname } from 'path';\nimport minimatch from 'minimatch';\nimport type { Plugin } from 'rollup';\n\nfunction symmetricDifference(arr1: any[], arr2: any[]) {\n return arr1\n .filter((x) => !arr2.includes(x))\n .concat(arr2.filter((x) => !arr1.includes(x)));\n}\n\nexport default function appReexports(opts: {\n from: string;\n to: string;\n include: string[];\n exclude?: string[];\n mapFilename?: (filename: string) => string;\n exports?: (filename: string) => string[] | string | undefined;\n}): Plugin {\n return {\n name: 'app-reexports',\n generateBundle(_, bundle) {\n let pkg = readJsonSync('package.json');\n let appJS: Record<string, string> = {};\n for (let addonFilename of Object.keys(bundle)) {\n let appFilename = opts.mapFilename?.(addonFilename) ?? addonFilename;\n let appExports = opts.exports?.(addonFilename) || ['default'];\n\n let computedExports =\n typeof appExports === 'string'\n ? appExports\n : `{ ${appExports.join(', ')} }`;\n\n if (\n opts.include.some((glob) => minimatch(addonFilename, glob)) &&\n !minimatch(addonFilename, '**/*.d.ts') &&\n opts.exclude?.some((glob) => minimatch(addonFilename, glob)) !== true\n ) {\n appJS[`./${appFilename}`] = `./dist/_app_/${appFilename}`;\n this.emitFile({\n type: 'asset',\n fileName: `_app_/${appFilename}`,\n source: `export ${computedExports} from \"${\n pkg.name\n }/${addonFilename.slice(0, -extname(addonFilename).length)}\";\\n`,\n });\n }\n }\n let originalAppJS = pkg['ember-addon']?.['app-js'] ?? {};\n\n let hasChanges = !!symmetricDifference(\n Object.keys(originalAppJS),\n Object.keys(appJS)\n ).length;\n\n // Don't cause a file i/o event unless something actually changed\n if (hasChanges) {\n pkg['ember-addon'] = Object.assign({}, pkg['ember-addon'], {\n 'app-js': appJS,\n });\n writeJsonSync('package.json', pkg, { spaces: 2 });\n }\n },\n };\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import type { Plugin } from 'rollup';
2
+ export default function rollupDeclarationsPlugin(declarationsDir: string,
3
+ /**
4
+ * The command to use to generate types.
5
+ * Defaults to:
6
+ * - glint --declaration # for glint v1
7
+ * - ember-tsc --declaration # for glint v2
8
+ */
9
+ command?: string): Plugin;
10
+ //# sourceMappingURL=rollup-declarations.d.ts.map
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = rollupDeclarationsPlugin;
7
+ const execa_1 = __importDefault(require("execa"));
8
+ const walk_sync_1 = __importDefault(require("walk-sync"));
9
+ const promises_1 = require("fs/promises");
10
+ const fs_1 = require("fs");
11
+ const package_up_1 = require("package-up");
12
+ let glint1 = 'glint --declaration';
13
+ let glint2 = 'ember-tsc --declaration';
14
+ function rollupDeclarationsPlugin(declarationsDir,
15
+ /**
16
+ * The command to use to generate types.
17
+ * Defaults to:
18
+ * - glint --declaration # for glint v1
19
+ * - ember-tsc --declaration # for glint v2
20
+ */
21
+ command) {
22
+ let glintPromise;
23
+ let commandToRun = command;
24
+ async function determineCommand() {
25
+ if (commandToRun)
26
+ return;
27
+ let manifestPath = await (0, package_up_1.packageUp)();
28
+ if (!manifestPath) {
29
+ /**
30
+ * Historical default is to use glint v1
31
+ */
32
+ commandToRun = glint1;
33
+ return;
34
+ }
35
+ let manifestBuffer = (0, fs_1.readFileSync)(manifestPath);
36
+ let manifest = JSON.parse(manifestBuffer.toString());
37
+ let deps = {
38
+ ...manifest.devDependencies,
39
+ ...manifest.dependencies,
40
+ };
41
+ if (deps['@glint/ember-tsc']) {
42
+ commandToRun = glint2;
43
+ return;
44
+ }
45
+ if (deps['@glint/core']) {
46
+ commandToRun = glint1;
47
+ return;
48
+ }
49
+ throw new Error(`Cannot use addon.declarations() plugin without glint present or an explicit command set as the second parameter. e.g.: addon.declarations('declarations', 'tsc --declaration')`);
50
+ }
51
+ return {
52
+ name: 'declarations',
53
+ buildStart() {
54
+ const runGlint = async () => {
55
+ await determineCommand();
56
+ if (!commandToRun)
57
+ return;
58
+ let { exitCode, escapedCommand } = await execa_1.default.command(commandToRun, {
59
+ // using stdio: inherit is the only way to retain color output from the
60
+ // underlying tsc process.
61
+ // However, the viewer of the error will not know which plugin it comes from.
62
+ // So that's why we have the additional logging below
63
+ stdio: 'inherit',
64
+ preferLocal: true,
65
+ // Without reject, execa would throw a hard exception
66
+ reject: false,
67
+ });
68
+ if (exitCode > 0) {
69
+ let msg = `Failed to generate declarations via \`${escapedCommand}\``;
70
+ if (this.meta.watchMode) {
71
+ this.warn(msg);
72
+ }
73
+ else {
74
+ this.error(msg);
75
+ }
76
+ }
77
+ await fixDeclarationsInMatchingFiles(declarationsDir);
78
+ if (exitCode === 0) {
79
+ this.info(`\`${escapedCommand}\` succeeded`);
80
+ }
81
+ };
82
+ // We just kick off glint here early in the rollup process, without making rollup wait for this to finish, by not returning the promise
83
+ // The output of this is not relevant to further stages of the rollup build, this is just happening in parallel to other rollup compilation
84
+ glintPromise = runGlint();
85
+ },
86
+ // Make rollup wait for glint to have finished before calling the build job done
87
+ writeBundle: () => glintPromise,
88
+ };
89
+ }
90
+ async function fixDeclarationsInMatchingFiles(dir) {
91
+ // can't fix what doesn't exist
92
+ // (happens when glint errors and doesn't output a ${dir} directory
93
+ if (!(0, fs_1.existsSync)(dir)) {
94
+ return;
95
+ }
96
+ const dtsFiles = (0, walk_sync_1.default)(dir, {
97
+ globs: ['**/*.d.ts', '**/*.d.gts.ts', '**/*.d.gjs.ts'],
98
+ directories: false,
99
+ includeBasePath: true,
100
+ });
101
+ return Promise.all(dtsFiles.map(async (file) => {
102
+ // TypeScript has never supported "compiled to JS" workflows
103
+ // when using external tools.
104
+ //
105
+ // So, the "arbitrary extensions" TS emits, will look like .d.gts.ts
106
+ // or .d.gjs.ts
107
+ //
108
+ // Because TS doesn't understand that external tools emit JS,
109
+ // and thus their declarations must be .d.ts, we have to
110
+ // manually handle this rename ourselves.
111
+ //
112
+ // Upstream: https://github.com/microsoft/TypeScript/issues/64053
113
+ // This'll be a no-op if/when TS fixes this.
114
+ let target = file.replace(/\.d\.(gts|gjs)\.ts$/, '.d.ts');
115
+ if (target !== file) {
116
+ await (0, promises_1.rename)(file, target);
117
+ }
118
+ const content = await (0, promises_1.readFile)(target, { encoding: 'utf8' });
119
+ await (0, promises_1.writeFile)(target, fixDeclarations(content));
120
+ }));
121
+ }
122
+ // Strip any .gts/.gjs extension from imports in d.ts files, as these won't
123
+ // resolve once the declaration files themselves are named *.d.ts.
124
+ // See
125
+ // - https://github.com/typed-ember/glint/issues/628
126
+ // - https://github.com/microsoft/TypeScript/issues/64053
127
+ function fixDeclarations(content) {
128
+ return content
129
+ .replace(/from\s+'([^']+)\.(gts|gjs)'/g, `from '$1'`)
130
+ .replace(/from\s+"([^"]+)\.(gts|gjs)"/g, `from '$1'`)
131
+ .replace(/import\("([^"]+)\.(gts|gjs)"\)/g, `import('$1')`)
132
+ .replace(/import\('([^']+)\.(gts|gjs)'\)/g, `import('$1')`);
133
+ }
134
+ //# sourceMappingURL=rollup-declarations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rollup-declarations.js","sourceRoot":"","sources":["rollup-declarations.ts"],"names":[],"mappings":";;;;;AAUA,2CA0FC;AAnGD,kDAA0B;AAC1B,0DAAiC;AACjC,0CAA0D;AAC1D,2BAA8C;AAC9C,2CAAuC;AAEvC,IAAI,MAAM,GAAG,qBAAqB,CAAC;AACnC,IAAI,MAAM,GAAG,yBAAyB,CAAC;AAEvC,SAAwB,wBAAwB,CAC9C,eAAuB;AACvB;;;;;GAKG;AACH,OAAgB;IAEhB,IAAI,YAA2B,CAAC;IAEhC,IAAI,YAAY,GAAG,OAAO,CAAC;IAE3B,KAAK,UAAU,gBAAgB;QAC7B,IAAI,YAAY;YAAE,OAAO;QAEzB,IAAI,YAAY,GAAG,MAAM,IAAA,sBAAS,GAAE,CAAC;QACrC,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB;;eAEG;YACH,YAAY,GAAG,MAAM,CAAC;YACtB,OAAO;QACT,CAAC;QAED,IAAI,cAAc,GAAG,IAAA,iBAAY,EAAC,YAAY,CAAC,CAAC;QAChD,IAAI,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC;QACrD,IAAI,IAAI,GAAG;YACT,GAAG,QAAQ,CAAC,eAAe;YAC3B,GAAG,QAAQ,CAAC,YAAY;SACzB,CAAC;QAEF,IAAI,IAAI,CAAC,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,CAAC,8BAA8B,EAAE,WAAW,CAAC;SACpD,OAAO,CAAC,8BAA8B,EAAE,WAAW,CAAC;SACpD,OAAO,CAAC,iCAAiC,EAAE,cAAc,CAAC;SAC1D,OAAO,CAAC,iCAAiC,EAAE,cAAc,CAAC,CAAC;AAChE,CAAC","sourcesContent":["import type { Plugin } from 'rollup';\nimport execa from 'execa';\nimport walkSync from 'walk-sync';\nimport { readFile, rename, writeFile } from 'fs/promises';\nimport { existsSync, readFileSync } from 'fs';\nimport { packageUp } from 'package-up';\n\nlet glint1 = 'glint --declaration';\nlet glint2 = 'ember-tsc --declaration';\n\nexport default function rollupDeclarationsPlugin(\n declarationsDir: string,\n /**\n * The command to use to generate types.\n * Defaults to:\n * - glint --declaration # for glint v1\n * - ember-tsc --declaration # for glint v2\n */\n command?: string\n): Plugin {\n let glintPromise: Promise<void>;\n\n let commandToRun = command;\n\n async function determineCommand() {\n if (commandToRun) return;\n\n let manifestPath = await packageUp();\n if (!manifestPath) {\n /**\n * Historical default is to use glint v1\n */\n commandToRun = glint1;\n return;\n }\n\n let manifestBuffer = readFileSync(manifestPath);\n let manifest = JSON.parse(manifestBuffer.toString());\n let deps = {\n ...manifest.devDependencies,\n ...manifest.dependencies,\n };\n\n if (deps['@glint/ember-tsc']) {\n commandToRun = glint2;\n return;\n }\n if (deps['@glint/core']) {\n commandToRun = glint1;\n return;\n }\n\n throw new Error(\n `Cannot use addon.declarations() plugin without glint present or an explicit command set as the second parameter. e.g.: addon.declarations('declarations', 'tsc --declaration')`\n );\n }\n\n return {\n name: 'declarations',\n buildStart() {\n const runGlint = async () => {\n await determineCommand();\n\n if (!commandToRun) return;\n\n let { exitCode, escapedCommand } = await execa.command(commandToRun, {\n // using stdio: inherit is the only way to retain color output from the\n // underlying tsc process.\n // However, the viewer of the error will not know which plugin it comes from.\n // So that's why we have the additional logging below\n stdio: 'inherit',\n preferLocal: true,\n // Without reject, execa would throw a hard exception\n reject: false,\n });\n\n if (exitCode > 0) {\n let msg = `Failed to generate declarations via \\`${escapedCommand}\\``;\n\n if (this.meta.watchMode) {\n this.warn(msg);\n } else {\n this.error(msg);\n }\n }\n\n await fixDeclarationsInMatchingFiles(declarationsDir);\n if (exitCode === 0) {\n this.info(`\\`${escapedCommand}\\` succeeded`);\n }\n };\n\n // We just kick off glint here early in the rollup process, without making rollup wait for this to finish, by not returning the promise\n // The output of this is not relevant to further stages of the rollup build, this is just happening in parallel to other rollup compilation\n glintPromise = runGlint();\n },\n\n // Make rollup wait for glint to have finished before calling the build job done\n writeBundle: () => glintPromise,\n };\n}\n\nasync function fixDeclarationsInMatchingFiles(dir: string) {\n // can't fix what doesn't exist\n // (happens when glint errors and doesn't output a ${dir} directory\n if (!existsSync(dir)) {\n return;\n }\n\n const dtsFiles = walkSync(dir, {\n globs: ['**/*.d.ts', '**/*.d.gts.ts', '**/*.d.gjs.ts'],\n directories: false,\n includeBasePath: true,\n });\n\n return Promise.all(\n dtsFiles.map(async (file) => {\n // TypeScript has never supported \"compiled to JS\" workflows\n // when using external tools.\n //\n // So, the \"arbitrary extensions\" TS emits, will look like .d.gts.ts\n // or .d.gjs.ts\n //\n // Because TS doesn't understand that external tools emit JS,\n // and thus their declarations must be .d.ts, we have to\n // manually handle this rename ourselves.\n //\n // Upstream: https://github.com/microsoft/TypeScript/issues/64053\n // This'll be a no-op if/when TS fixes this.\n let target = file.replace(/\\.d\\.(gts|gjs)\\.ts$/, '.d.ts');\n\n if (target !== file) {\n await rename(file, target);\n }\n\n const content = await readFile(target, { encoding: 'utf8' });\n\n await writeFile(target, fixDeclarations(content));\n })\n );\n}\n\n// Strip any .gts/.gjs extension from imports in d.ts files, as these won't\n// resolve once the declaration files themselves are named *.d.ts.\n// See\n// - https://github.com/typed-ember/glint/issues/628\n// - https://github.com/microsoft/TypeScript/issues/64053\nfunction fixDeclarations(content: string) {\n return content\n .replace(/from\\s+'([^']+)\\.(gts|gjs)'/g, `from '$1'`)\n .replace(/from\\s+\"([^\"]+)\\.(gts|gjs)\"/g, `from '$1'`)\n .replace(/import\\(\"([^\"]+)\\.(gts|gjs)\"\\)/g, `import('$1')`)\n .replace(/import\\('([^']+)\\.(gts|gjs)'\\)/g, `import('$1')`);\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from 'rollup';
2
+ export default function rollupGjsPlugin(): Plugin;
3
+ //# sourceMappingURL=rollup-gjs-plugin.d.ts.map
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = rollupGjsPlugin;
4
+ const pluginutils_1 = require("@rollup/pluginutils");
5
+ const content_tag_1 = require("content-tag");
6
+ const PLUGIN_NAME = 'rollup-gjs-plugin';
7
+ const processor = new content_tag_1.Preprocessor();
8
+ // import { parse as pathParse } from 'path';
9
+ function rollupGjsPlugin() {
10
+ return {
11
+ name: PLUGIN_NAME,
12
+ transform: {
13
+ // Enforce running the gjs transform before any others like babel that expect valid JS
14
+ order: 'pre',
15
+ handler(input, id) {
16
+ if (!gjsFilter(id)) {
17
+ return null;
18
+ }
19
+ let { code, map } = processor.process(input, {
20
+ filename: id,
21
+ });
22
+ return {
23
+ code,
24
+ map,
25
+ };
26
+ },
27
+ },
28
+ onLog(_level, log) {
29
+ if (log.code === 'EVAL' && gjsFilter(log.id)) {
30
+ return false;
31
+ }
32
+ },
33
+ };
34
+ }
35
+ const gjsFilter = (0, pluginutils_1.createFilter)('**/*.g{j,t}s');
36
+ //# sourceMappingURL=rollup-gjs-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rollup-gjs-plugin.js","sourceRoot":"","sources":["rollup-gjs-plugin.ts"],"names":[],"mappings":";;AASA,kCA2BC;AApCD,qDAAmD;AAEnD,6CAA2C;AAE3C,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAExC,MAAM,SAAS,GAAG,IAAI,0BAAY,EAAE,CAAC;AACrC,6CAA6C;AAE7C,SAAwB,eAAe;IACrC,OAAO;QACL,IAAI,EAAE,WAAW;QAEjB,SAAS,EAAE;YACT,sFAAsF;YACtF,KAAK,EAAE,KAAK;YACZ,OAAO,CAAC,KAAa,EAAE,EAAU;gBAC/B,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC;oBACnB,OAAO,IAAI,CAAC;gBACd,CAAC;gBACD,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE;oBAC3C,QAAQ,EAAE,EAAE;iBACb,CAAC,CAAC;gBACH,OAAO;oBACL,IAAI;oBACJ,GAAG;iBACJ,CAAC;YACJ,CAAC;SACF;QAED,KAAK,CAAC,MAAgB,EAAE,GAAc;YACpC,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,IAAI,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;gBAC7C,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,SAAS,GAAG,IAAA,0BAAY,EAAC,cAAc,CAAC,CAAC","sourcesContent":["import { createFilter } from '@rollup/pluginutils';\nimport type { LogLevel, Plugin, RollupLog } from 'rollup';\nimport { Preprocessor } from 'content-tag';\n\nconst PLUGIN_NAME = 'rollup-gjs-plugin';\n\nconst processor = new Preprocessor();\n// import { parse as pathParse } from 'path';\n\nexport default function rollupGjsPlugin(): Plugin {\n return {\n name: PLUGIN_NAME,\n\n transform: {\n // Enforce running the gjs transform before any others like babel that expect valid JS\n order: 'pre',\n handler(input: string, id: string) {\n if (!gjsFilter(id)) {\n return null;\n }\n let { code, map } = processor.process(input, {\n filename: id,\n });\n return {\n code,\n map,\n };\n },\n },\n\n onLog(_level: LogLevel, log: RollupLog): boolean | void {\n if (log.code === 'EVAL' && gjsFilter(log.id)) {\n return false;\n }\n },\n };\n}\n\nconst gjsFilter = createFilter('**/*.g{j,t}s');\n"]}
@@ -0,0 +1,5 @@
1
+ import type { Plugin } from 'rollup';
2
+ export default function rollupHbsPlugin({ excludeColocation, }: {
3
+ excludeColocation?: string[];
4
+ }): Plugin;
5
+ //# sourceMappingURL=rollup-hbs-plugin.d.ts.map
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = rollupHbsPlugin;
7
+ const pluginutils_1 = require("@rollup/pluginutils");
8
+ const minimatch_1 = __importDefault(require("minimatch"));
9
+ const core_1 = require("@embroider/core");
10
+ const path_1 = require("path");
11
+ const hbsFilter = (0, pluginutils_1.createFilter)('**/*.hbs?([?]*)');
12
+ function rollupHbsPlugin({ excludeColocation, }) {
13
+ return {
14
+ name: 'rollup-hbs-plugin',
15
+ async resolveId(source, importer, options) {
16
+ var _a, _b;
17
+ if ((_b = (_a = options.custom) === null || _a === void 0 ? void 0 : _a.embroider) === null || _b === void 0 ? void 0 : _b.isExtensionSearch) {
18
+ return null;
19
+ }
20
+ let resolution = await this.resolve(source, importer, {
21
+ ...options,
22
+ skipSelf: true,
23
+ });
24
+ if (!resolution && (0, path_1.extname)(source) === '') {
25
+ resolution = await this.resolve(source + '.hbs', importer, {
26
+ ...options,
27
+ skipSelf: true,
28
+ });
29
+ }
30
+ if (!resolution) {
31
+ let hbsSource = (0, core_1.syntheticJStoHBS)(source);
32
+ if (hbsSource) {
33
+ resolution = await this.resolve(hbsSource, importer, {
34
+ ...options,
35
+ skipSelf: true,
36
+ custom: {
37
+ embroider: {
38
+ isExtensionSearch: true,
39
+ },
40
+ },
41
+ });
42
+ }
43
+ if (!resolution) {
44
+ return null;
45
+ }
46
+ }
47
+ if (resolution && resolution.id.endsWith('.hbs')) {
48
+ let isExcluded = excludeColocation === null || excludeColocation === void 0 ? void 0 : excludeColocation.some((glob) => (0, minimatch_1.default)(resolution.id, glob));
49
+ if (isExcluded) {
50
+ return resolution;
51
+ }
52
+ }
53
+ let syntheticId = (0, core_1.needsSyntheticComponentJS)(source, resolution.id);
54
+ if (syntheticId) {
55
+ this.addWatchFile(source);
56
+ return {
57
+ id: syntheticId,
58
+ meta: {
59
+ 'rollup-hbs-plugin': {
60
+ type: 'template-only-component-js',
61
+ },
62
+ },
63
+ };
64
+ }
65
+ },
66
+ load(id) {
67
+ var _a;
68
+ if (((_a = getMeta(this, id)) === null || _a === void 0 ? void 0 : _a.type) === 'template-only-component-js') {
69
+ this.addWatchFile(id);
70
+ return {
71
+ code: (0, core_1.templateOnlyComponentSource)(),
72
+ };
73
+ }
74
+ },
75
+ transform: {
76
+ // Enforce running the hbs transform before any others like babel that expect valid JS
77
+ order: 'pre',
78
+ handler(code, id) {
79
+ var _a;
80
+ let hbsFilename = id.replace(/\.\w{1,3}$/, '') + '.hbs';
81
+ if (hbsFilename !== id) {
82
+ this.addWatchFile(hbsFilename);
83
+ if (((_a = getMeta(this, id)) === null || _a === void 0 ? void 0 : _a.type) === 'template-only-component-js') {
84
+ this.addWatchFile(id);
85
+ }
86
+ }
87
+ if (!hbsFilter(id)) {
88
+ return null;
89
+ }
90
+ return (0, core_1.hbsToJS)(code);
91
+ },
92
+ },
93
+ };
94
+ }
95
+ function getMeta(context, id) {
96
+ var _a, _b;
97
+ const meta = (_b = (_a = context.getModuleInfo(id)) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b['rollup-hbs-plugin'];
98
+ if (meta) {
99
+ return meta;
100
+ }
101
+ else {
102
+ return null;
103
+ }
104
+ }
105
+ //# sourceMappingURL=rollup-hbs-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rollup-hbs-plugin.js","sourceRoot":"","sources":["rollup-hbs-plugin.ts"],"names":[],"mappings":";;;;;AAaA,kCA6FC;AAzGD,qDAAmD;AACnD,0DAAkC;AAClC,0CAKyB;AACzB,+BAA+B;AAE/B,MAAM,SAAS,GAAG,IAAA,0BAAY,EAAC,iBAAiB,CAAC,CAAC;AAElD,SAAwB,eAAe,CA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AAS,CAAC,EAAE,CAAC,EAAE,CAAC;oBACnB,OAAO,IAAI,CAAC;gBACd,CAAC;gBACD,OAAO,IAAA,cAAO,EAAC,IAAI,CAAC,CAAC;YACvB,CAAC;SACF;KACF,CAAC;AACJ,CAAC;AAMD,SAAS,OAAO,CAAC,OAAsB,EAAE,EAAU;;IACjD,MAAM,IAAI,GAAG,MAAA,MAAA,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,0CAAE,IAAI,0CAAG,mBAAmB,CAAC,CAAC;IACpE,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,IAAY,CAAC;IACtB,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import type { Plugin, PluginContext } from 'rollup';\nimport { createFilter } from '@rollup/pluginutils';\nimport minimatch from 'minimatch';\nimport {\n hbsToJS,\n templateOnlyComponentSource,\n needsSyntheticComponentJS,\n syntheticJStoHBS,\n} from '@embroider/core';\nimport { extname } from 'path';\n\nconst hbsFilter = createFilter('**/*.hbs?([?]*)');\n\nexport default function rollupHbsPlugin({\n excludeColocation,\n}: {\n excludeColocation?: string[];\n}): Plugin {\n return {\n name: 'rollup-hbs-plugin',\n async resolveId(source: string, importer: string | undefined, options) {\n if (options.custom?.embroider?.isExtensionSearch) {\n return null;\n }\n\n let resolution = await this.resolve(source, importer, {\n ...options,\n skipSelf: true,\n });\n\n if (!resolution && extname(source) === '') {\n resolution = await this.resolve(source + '.hbs', importer, {\n ...options,\n skipSelf: true,\n });\n }\n\n if (!resolution) {\n let hbsSource = syntheticJStoHBS(source);\n if (hbsSource) {\n resolution = await this.resolve(hbsSource, importer, {\n ...options,\n skipSelf: true,\n custom: {\n embroider: {\n isExtensionSearch: true,\n },\n },\n });\n }\n\n if (!resolution) {\n return null;\n }\n }\n\n if (resolution && resolution.id.endsWith('.hbs')) {\n let isExcluded = excludeColocation?.some((glob) =>\n minimatch(resolution!.id, glob)\n );\n if (isExcluded) {\n return resolution;\n }\n }\n\n let syntheticId = needsSyntheticComponentJS(source, resolution.id);\n if (syntheticId) {\n this.addWatchFile(source);\n return {\n id: syntheticId,\n meta: {\n 'rollup-hbs-plugin': {\n type: 'template-only-component-js',\n },\n },\n };\n }\n },\n\n load(id: string) {\n if (getMeta(this, id)?.type === 'template-only-component-js') {\n this.addWatchFile(id);\n return {\n code: templateOnlyComponentSource(),\n };\n }\n },\n\n transform: {\n // Enforce running the hbs transform before any others like babel that expect valid JS\n order: 'pre',\n handler(code: string, id: string) {\n let hbsFilename = id.replace(/\\.\\w{1,3}$/, '') + '.hbs';\n if (hbsFilename !== id) {\n this.addWatchFile(hbsFilename);\n if (getMeta(this, id)?.type === 'template-only-component-js') {\n this.addWatchFile(id);\n }\n }\n if (!hbsFilter(id)) {\n return null;\n }\n return hbsToJS(code);\n },\n },\n };\n}\n\ntype Meta = {\n type: 'template-only-component-js';\n};\n\nfunction getMeta(context: PluginContext, id: string): Meta | null {\n const meta = context.getModuleInfo(id)?.meta?.['rollup-hbs-plugin'];\n if (meta) {\n return meta as Meta;\n } else {\n return null;\n }\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from 'rollup';
2
+ export default function incremental(): Plugin;
3
+ //# sourceMappingURL=rollup-incremental-plugin.d.ts.map
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = incremental;
7
+ const walk_sync_1 = __importDefault(require("walk-sync"));
8
+ const fs_1 = require("fs");
9
+ const path_1 = require("path");
10
+ const fs_extra_1 = require("fs-extra");
11
+ function incremental() {
12
+ const generatedAssets = new Map();
13
+ const generatedFiles = new Set();
14
+ function isEqual(v1, v2) {
15
+ if (typeof v1 === 'string' && typeof v2 === 'string') {
16
+ return v1 === v2;
17
+ }
18
+ if (Buffer.isBuffer(v1) && Buffer.isBuffer(v2)) {
19
+ return v1.equals(v2);
20
+ }
21
+ return false;
22
+ }
23
+ let firstTime = true;
24
+ function initGeneratedFiles(outDir) {
25
+ if ((0, fs_extra_1.existsSync)(outDir)) {
26
+ const files = (0, walk_sync_1.default)(outDir, {
27
+ globs: ['**/*'],
28
+ directories: false,
29
+ });
30
+ for (const file of files) {
31
+ generatedFiles.add(file);
32
+ }
33
+ }
34
+ }
35
+ function deleteRemovedFiles(bundle, outDir) {
36
+ for (const file of generatedFiles) {
37
+ if (!bundle[file]) {
38
+ generatedAssets.delete(file);
39
+ (0, fs_1.rmSync)((0, path_1.join)(outDir, file));
40
+ }
41
+ }
42
+ generatedFiles.clear();
43
+ for (const file of Object.keys(bundle)) {
44
+ generatedFiles.add(file);
45
+ }
46
+ }
47
+ function syncFiles(bundle) {
48
+ for (const checkKey of Object.keys(bundle)) {
49
+ if (bundle[checkKey]) {
50
+ let module = bundle[checkKey];
51
+ let code = module.source || module.code;
52
+ if (generatedAssets.has(checkKey) &&
53
+ isEqual(code, generatedAssets.get(checkKey))) {
54
+ delete bundle[checkKey];
55
+ }
56
+ else {
57
+ generatedAssets.set(checkKey, code);
58
+ }
59
+ }
60
+ }
61
+ }
62
+ return {
63
+ name: 'incremental',
64
+ generateBundle(options, bundle) {
65
+ if (firstTime) {
66
+ firstTime = false;
67
+ initGeneratedFiles(options.dir);
68
+ }
69
+ if ((0, fs_extra_1.existsSync)(options.dir)) {
70
+ deleteRemovedFiles(bundle, options.dir);
71
+ }
72
+ syncFiles(bundle);
73
+ },
74
+ };
75
+ }
76
+ //# sourceMappingURL=rollup-incremental-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rollup-incremental-plugin.js","sourceRoot":"","sources":["rollup-incremental-plugin.ts"],"names":[],"mappings":";;;;;AAMA,8BAwEC;AA9ED,0DAAiC;AACjC,2BAA4B;AAC5B,+BAA4B;AAE5B,uCAAsC;AAEtC,SAAwB,WAAW;IACjC,MAAM,eAAe,GAAG,IAAI,GAAG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C,EAAE,CAAC;YACvC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,SAAS,SAAS,CAAC,MAA2B;QAC5C,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YAC3C,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACrB,IAAI,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAQ,CAAC;gBACrC,IAAI,IAAI,GAAG,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC;gBACxC,IACE,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC;oBAC7B,OAAO,CAAC,IAAI,EAAE,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAC5C,CAAC;oBACD,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC;gBAC1B,CAAC;qBAAM,CAAC;oBACN,eAAe,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;gBACtC,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,cAAc,CAAC,OAAO,EAAE,MAAM;YAC5B,IAAI,SAAS,EAAE,CAAC;gBACd,SAAS,GAAG,KAAK,CAAC;gBAClB,kBAAkB,CAAC,OAAO,CAAC,GAAI,CAAC,CAAC;YACnC,CAAC;YACD,IAAI,IAAA,qBAAU,EAAC,OAAO,CAAC,GAAI,CAAC,EAAE,CAAC;gBAC7B,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,GAAI,CAAC,CAAC;YAC3C,CAAC;YAED,SAAS,CAAC,MAAM,CAAC,CAAC;QACpB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import walkSync from 'walk-sync';\nimport { rmSync } from 'fs';\nimport { join } from 'path';\nimport type { Plugin } from 'rollup';\nimport { existsSync } from 'fs-extra';\n\nexport default function incremental(): Plugin {\n const generatedAssets = new Map();\n const generatedFiles = new Set<string>();\n\n function isEqual(v1: string | Uint8Array, v2: string | Uint8Array): boolean {\n if (typeof v1 === 'string' && typeof v2 === 'string') {\n return v1 === v2;\n }\n if (Buffer.isBuffer(v1) && Buffer.isBuffer(v2)) {\n return v1.equals(v2);\n }\n return false;\n }\n\n let firstTime = true;\n\n function initGeneratedFiles(outDir: string) {\n if (existsSync(outDir)) {\n const files = walkSync(outDir, {\n globs: ['**/*'],\n directories: false,\n });\n for (const file of files) {\n generatedFiles.add(file);\n }\n }\n }\n\n function deleteRemovedFiles(bundle: Record<string, any>, outDir: string) {\n for (const file of generatedFiles) {\n if (!bundle[file]) {\n generatedAssets.delete(file);\n rmSync(join(outDir, file));\n }\n }\n generatedFiles.clear();\n for (const file of Object.keys(bundle)) {\n generatedFiles.add(file);\n }\n }\n\n function syncFiles(bundle: Record<string, any>) {\n for (const checkKey of Object.keys(bundle)) {\n if (bundle[checkKey]) {\n let module = bundle[checkKey] as any;\n let code = module.source || module.code;\n if (\n generatedAssets.has(checkKey) &&\n isEqual(code, generatedAssets.get(checkKey))\n ) {\n delete bundle[checkKey];\n } else {\n generatedAssets.set(checkKey, code);\n }\n }\n }\n }\n\n return {\n name: 'incremental',\n generateBundle(options, bundle) {\n if (firstTime) {\n firstTime = false;\n initGeneratedFiles(options.dir!);\n }\n if (existsSync(options.dir!)) {\n deleteRemovedFiles(bundle, options.dir!);\n }\n\n syncFiles(bundle);\n },\n };\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import type { Plugin } from 'rollup';
2
+ export default function keepAssets({ from, include, exports, }: {
3
+ from: string;
4
+ include: string[];
5
+ exports?: undefined | 'default' | '*';
6
+ }): Plugin;
7
+ //# sourceMappingURL=rollup-keep-assets.d.ts.map
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = keepAssets;
7
+ const minimatch_1 = __importDefault(require("minimatch"));
8
+ const path_1 = require("path");
9
+ const fs_1 = require("fs");
10
+ // randomly chosen, we're just looking to have high-entropy identifiers that
11
+ // won't collide with anyting else in the source
12
+ let counter = 11559;
13
+ function keepAssets({ from, include, exports, }) {
14
+ const marker = `__keep_assets_marker_${counter++}__`;
15
+ return {
16
+ name: 'keep-assets',
17
+ // we implement a load hook for the assets we're keeping so that we can
18
+ // capture their true binary representations. If we fell through to the
19
+ // default rollup load hook we would get utf8 interpretations of them.
20
+ //
21
+ // Our plugin should be placed after any other plugins that have their own
22
+ // load hooks, in which case this will not run but our transform hook will
23
+ // still over from there.
24
+ load(id) {
25
+ if (include.some((pattern) => (0, minimatch_1.default)(id, pattern))) {
26
+ return {
27
+ code: (0, fs_1.readFileSync)(id).toString('binary'),
28
+ meta: {
29
+ 'keep-assets': {
30
+ binaryLoaded: true,
31
+ },
32
+ },
33
+ };
34
+ }
35
+ },
36
+ transform(code, id) {
37
+ var _a, _b;
38
+ let output = code;
39
+ let ourMeta = (_b = (_a = this.getModuleInfo(id)) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b['keep-assets'];
40
+ if (ourMeta === null || ourMeta === void 0 ? void 0 : ourMeta.binaryLoaded) {
41
+ // when the code was produced by our own load hook it is binary-encoded
42
+ // string and we can emit the true bytes.
43
+ output = Buffer.from(code, 'binary');
44
+ }
45
+ if (include.some((pattern) => (0, minimatch_1.default)(id, pattern))) {
46
+ let ref = this.emitFile({
47
+ type: 'asset',
48
+ fileName: (0, path_1.relative)(from, id),
49
+ source: output,
50
+ });
51
+ if (exports === '*') {
52
+ return `export * from ${marker}("${ref}")`;
53
+ }
54
+ else if (exports === 'default') {
55
+ return `export default ${marker}("${ref}")`;
56
+ }
57
+ else {
58
+ // side-effect only
59
+ return `${marker}("${ref}")`;
60
+ }
61
+ }
62
+ },
63
+ renderChunk(code, chunk) {
64
+ if (code.includes(marker)) {
65
+ const { getName, imports } = nameTracker(code, exports);
66
+ code = code.replace(new RegExp(`${marker}\\("([^"]+)"\\)`, 'g'), (_x, ref) => {
67
+ var _a;
68
+ let assetFileName = this.getFileName(ref);
69
+ let relativeName = './' + (0, path_1.relative)((0, path_1.dirname)(chunk.fileName), assetFileName);
70
+ return (_a = getName(relativeName)) !== null && _a !== void 0 ? _a : '';
71
+ });
72
+ return imports() + code;
73
+ }
74
+ },
75
+ };
76
+ }
77
+ function nameTracker(code, exports) {
78
+ let counter = 0;
79
+ let assets = new Map();
80
+ function getName(assetName) {
81
+ if (assets.has(assetName)) {
82
+ return assets.get(assetName);
83
+ }
84
+ if (!exports) {
85
+ assets.set(assetName, undefined);
86
+ return undefined;
87
+ }
88
+ while (true) {
89
+ let candidate = `_asset_${counter++}_`;
90
+ if (!code.includes(candidate)) {
91
+ assets.set(assetName, candidate);
92
+ return candidate;
93
+ }
94
+ }
95
+ }
96
+ function imports() {
97
+ return ([...assets]
98
+ .map(([assetName, importedName]) => {
99
+ if (importedName) {
100
+ return `import ${importedName} from "${assetName}"`;
101
+ }
102
+ else {
103
+ return `import "${assetName}"`;
104
+ }
105
+ })
106
+ .join('\n') + '\n');
107
+ }
108
+ return { getName, imports };
109
+ }
110
+ //# sourceMappingURL=rollup-keep-assets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rollup-keep-assets.js","sourceRoot":"","sources":["rollup-keep-assets.ts"],"names":[],"mappings":";;;;;AASA,6BA2EC;AAnFD,0DAAkC;AAClC,+BAAyC;AACzC,2BAAkC;AAElC,4EAA4E;AAC5E,gDAAgD;AAChD,IAAI,OAAO,GAAG,KAAK,CAAC;AAEpB,SAAwB,UAAU,CAAC,EACjC,IAAI,EACJ,OAAO,EACP,OAAO,GAKR;IACC,MAAM,MAAM,GAAG,wBAAwB,OAAO,EAAE,IAAI,CAAC;IAErD,OAAO;QACL,IAAI,EAAE,aAAa;QAEnB,uEAAuE;QACvE,uEAAuE;QACvE,sEAAsE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,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;YACjC,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,IAAI,EAAE,CAAC;YACZ,IAAI,SAAS,GAAG,UAAU,OAAO,EAAE,GAAG,CAAC;YACvC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC9B,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;gBACjC,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;IACH,CAAC;IAED,SAAS,OAAO;QACd,OAAO,CACL,CAAC,GAAG,MAAM,CAAC;aACR,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE,EAAE;YACjC,IAAI,YAAY,EAAE,CAAC;gBACjB,OAAO,UAAU,YAAY,UAAU,SAAS,GAAG,CAAC;YACtD,CAAC;iBAAM,CAAC;gBACN,OAAO,WAAW,SAAS,GAAG,CAAC;YACjC,CAAC;QACH,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CACrB,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["import type { Plugin } from 'rollup';\nimport minimatch from 'minimatch';\nimport { dirname, relative } from 'path';\nimport { readFileSync } from 'fs';\n\n// randomly chosen, we're just looking to have high-entropy identifiers that\n// won't collide with anyting else in the source\nlet counter = 11559;\n\nexport default function keepAssets({\n from,\n include,\n exports,\n}: {\n from: string;\n include: string[];\n exports?: undefined | 'default' | '*';\n}): Plugin {\n const marker = `__keep_assets_marker_${counter++}__`;\n\n return {\n name: 'keep-assets',\n\n // we implement a load hook for the assets we're keeping so that we can\n // capture their true binary representations. If we fell through to the\n // default rollup load hook we would get utf8 interpretations of them.\n //\n // Our plugin should be placed after any other plugins that have their own\n // load hooks, in which case this will not run but our transform hook will\n // still over from there.\n load(id: string) {\n if (include.some((pattern) => minimatch(id, pattern))) {\n return {\n code: readFileSync(id).toString('binary'),\n meta: {\n 'keep-assets': {\n binaryLoaded: true,\n },\n },\n };\n }\n },\n\n transform(code: string, id: string) {\n let output: Buffer | string = code;\n let ourMeta = this.getModuleInfo(id)?.meta?.['keep-assets'];\n if (ourMeta?.binaryLoaded) {\n // when the code was produced by our own load hook it is binary-encoded\n // string and we can emit the true bytes.\n output = Buffer.from(code, 'binary');\n }\n if (include.some((pattern) => minimatch(id, pattern))) {\n let ref = this.emitFile({\n type: 'asset',\n fileName: relative(from, id),\n source: output,\n });\n if (exports === '*') {\n return `export * from ${marker}(\"${ref}\")`;\n } else if (exports === 'default') {\n return `export default ${marker}(\"${ref}\")`;\n } else {\n // side-effect only\n return `${marker}(\"${ref}\")`;\n }\n }\n },\n renderChunk(code, chunk) {\n if (code.includes(marker)) {\n const { getName, imports } = nameTracker(code, exports);\n\n code = code.replace(\n new RegExp(`${marker}\\\\(\"([^\"]+)\"\\\\)`, 'g'),\n (_x, ref) => {\n let assetFileName = this.getFileName(ref);\n let relativeName =\n './' + relative(dirname(chunk.fileName), assetFileName);\n return getName(relativeName) ?? '';\n }\n );\n return imports() + code;\n }\n },\n };\n}\n\nfunction nameTracker(code: string, exports: undefined | 'default' | '*') {\n let counter = 0;\n let assets = new Map<string, string | undefined>();\n\n function getName(assetName: string): string | undefined {\n if (assets.has(assetName)) {\n return assets.get(assetName)!;\n }\n if (!exports) {\n assets.set(assetName, undefined);\n return undefined;\n }\n while (true) {\n let candidate = `_asset_${counter++}_`;\n if (!code.includes(candidate)) {\n assets.set(assetName, candidate);\n return candidate;\n }\n }\n }\n\n function imports() {\n return (\n [...assets]\n .map(([assetName, importedName]) => {\n if (importedName) {\n return `import ${importedName} from \"${assetName}\"`;\n } else {\n return `import \"${assetName}\"`;\n }\n })\n .join('\\n') + '\\n'\n );\n }\n\n return { getName, imports };\n}\n"]}
@@ -0,0 +1,23 @@
1
+ import type { Plugin } from 'rollup';
2
+ export interface PublicAssetsOptions {
3
+ /**
4
+ * glob pattern passed to `walkSync.include` to pick files
5
+ */
6
+ include?: string[];
7
+ /**
8
+ * glob pattern passed to `walkSync.ignore` to exclude files
9
+ */
10
+ exclude?: string[];
11
+ /**
12
+ * namespace to expose files
13
+ */
14
+ namespace?: string;
15
+ }
16
+ /**
17
+ * A rollup plugin to expose a folder of assets
18
+ *
19
+ * @param path - the public folder that you want to add as public assets
20
+ * @returns
21
+ */
22
+ export default function publicAssets(path: string, opts?: PublicAssetsOptions): Plugin;
23
+ //# sourceMappingURL=rollup-public-assets.d.ts.map
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = publicAssets;
7
+ const fs_extra_1 = require("fs-extra");
8
+ const walk_sync_1 = __importDefault(require("walk-sync"));
9
+ const posix_1 = require("path/posix");
10
+ /**
11
+ * A rollup plugin to expose a folder of assets
12
+ *
13
+ * @param path - the public folder that you want to add as public assets
14
+ * @returns
15
+ */
16
+ function publicAssets(path, opts) {
17
+ const includeGlobPatterns = opts === null || opts === void 0 ? void 0 : opts.include;
18
+ const excludedGlobPatterns = (opts === null || opts === void 0 ? void 0 : opts.exclude) || [];
19
+ return {
20
+ name: 'public-assets-bundler',
21
+ // Prior to https://github.com/rollup/rollup/pull/5270, we cannot call this
22
+ // from within `generateBundle`
23
+ buildStart() {
24
+ this.addWatchFile(path);
25
+ },
26
+ closeBundle() {
27
+ var _a;
28
+ let pkg = (0, fs_extra_1.readJsonSync)('package.json');
29
+ const filenames = (0, walk_sync_1.default)(path, {
30
+ directories: false,
31
+ globs: includeGlobPatterns,
32
+ ignore: excludedGlobPatterns,
33
+ });
34
+ const publicAssets = filenames.reduce((acc, v) => {
35
+ var _a;
36
+ const namespace = (_a = opts === null || opts === void 0 ? void 0 : opts.namespace) !== null && _a !== void 0 ? _a : pkg.name;
37
+ acc[`./${path}/${v}`] = (0, posix_1.resolve)('/' + (0, posix_1.join)(namespace, v));
38
+ return acc;
39
+ }, {});
40
+ let originalPublicAssets = (_a = pkg['ember-addon']) === null || _a === void 0 ? void 0 : _a['public-assets'];
41
+ let hasChanges = JSON.stringify(originalPublicAssets) !== JSON.stringify(publicAssets);
42
+ if (hasChanges) {
43
+ pkg['ember-addon'] = Object.assign({}, pkg['ember-addon'], {
44
+ 'public-assets': publicAssets,
45
+ });
46
+ (0, fs_extra_1.writeJsonSync)('package.json', pkg, { spaces: 2 });
47
+ }
48
+ },
49
+ };
50
+ }
51
+ //# sourceMappingURL=rollup-public-assets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rollup-public-assets.js","sourceRoot":"","sources":["rollup-public-assets.ts"],"names":[],"mappings":";;;;;AA4BA,+BA+CC;AA3ED,uCAAuD;AACvD,0DAAiC;AAEjC,sCAA2C;AAmB3C;;;;;GAKG;AACH,SAAwB,YAAY,CAClC,IAAY,EACZ,IAA0B;IAE1B,MAAM,mBAAmB,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO,CAAC;IAC1C,MAAM,oBAAoB,GAAG,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO,KAAI,EAAE,CAAC;IAEjD,OAAO;QACL,IAAI,EAAE,uBAAuB;QAE7B,2EAA2E;QAC3E,+BAA+B;QAC/B,UAAU;YACR,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;QAED,WAAW;;YACT,IAAI,GAAG,GAAG,IAAA,uBAAY,EAAC,cAAc,CAAC,CAAC;YACvC,MAAM,SAAS,GAAG,IAAA,mBAAQ,EAAC,IAAI,EAAE;gBAC/B,WAAW,EAAE,KAAK;gBAClB,KAAK,EAAE,mBAAmB;gBAC1B,MAAM,EAAE,oBAAoB;aAC7B,CAAC,CAAC;YACH,MAAM,YAAY,GAA2B,SAAS,CAAC,MAAM,CAC3D,CAAC,GAA2B,EAAE,CAAC,EAA0B,EAAE;;gBACzD,MAAM,SAAS,GAAG,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,SAAS,mCAAI,GAAG,CAAC,IAAI,CAAC;gBAE9C,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,EAAE,CAAC,GAAG,IAAA,eAAO,EAAC,GAAG,GAAG,IAAA,YAAI,EAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;gBAC1D,OAAO,GAAG,CAAC;YACb,CAAC,EACD,EAAE,CACH,CAAC;YAEF,IAAI,oBAAoB,GAAG,MAAA,GAAG,CAAC,aAAa,CAAC,0CAAG,eAAe,CAAC,CAAC;YAEjE,IAAI,UAAU,GACZ,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;YAExE,IAAI,UAAU,EAAE,CAAC;gBACf,GAAG,CAAC,aAAa,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,aAAa,CAAC,EAAE;oBACzD,eAAe,EAAE,YAAY;iBAC9B,CAAC,CAAC;gBAEH,IAAA,wBAAa,EAAC,cAAc,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;YACpD,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { readJsonSync, writeJsonSync } from 'fs-extra';\nimport walkSync from 'walk-sync';\nimport type { Plugin } from 'rollup';\nimport { resolve, join } from 'path/posix';\n\nexport interface PublicAssetsOptions {\n /**\n * glob pattern passed to `walkSync.include` to pick files\n */\n include?: string[];\n\n /**\n * glob pattern passed to `walkSync.ignore` to exclude files\n */\n exclude?: string[];\n\n /**\n * namespace to expose files\n */\n namespace?: string;\n}\n\n/**\n * A rollup plugin to expose a folder of assets\n *\n * @param path - the public folder that you want to add as public assets\n * @returns\n */\nexport default function publicAssets(\n path: string,\n opts?: PublicAssetsOptions\n): Plugin {\n const includeGlobPatterns = opts?.include;\n const excludedGlobPatterns = opts?.exclude || [];\n\n return {\n name: 'public-assets-bundler',\n\n // Prior to https://github.com/rollup/rollup/pull/5270, we cannot call this\n // from within `generateBundle`\n buildStart() {\n this.addWatchFile(path);\n },\n\n closeBundle() {\n let pkg = readJsonSync('package.json');\n const filenames = walkSync(path, {\n directories: false,\n globs: includeGlobPatterns,\n ignore: excludedGlobPatterns,\n });\n const publicAssets: Record<string, string> = filenames.reduce(\n (acc: Record<string, string>, v): Record<string, string> => {\n const namespace = opts?.namespace ?? pkg.name;\n\n acc[`./${path}/${v}`] = resolve('/' + join(namespace, v));\n return acc;\n },\n {}\n );\n\n let originalPublicAssets = pkg['ember-addon']?.['public-assets'];\n\n let hasChanges =\n JSON.stringify(originalPublicAssets) !== JSON.stringify(publicAssets);\n\n if (hasChanges) {\n pkg['ember-addon'] = Object.assign({}, pkg['ember-addon'], {\n 'public-assets': publicAssets,\n });\n\n writeJsonSync('package.json', pkg, { spaces: 2 });\n }\n },\n };\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import type { Plugin } from 'rollup';
2
+ export default function publicEntrypoints(args: {
3
+ srcDir: string;
4
+ include: string[];
5
+ exclude?: string[];
6
+ }): Plugin;
7
+ //# sourceMappingURL=rollup-public-entrypoints.d.ts.map
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = publicEntrypoints;
7
+ const walk_sync_1 = __importDefault(require("walk-sync"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const minimatch_1 = __importDefault(require("minimatch"));
10
+ function normalizeFileExt(fileName) {
11
+ return fileName.replace(/(?<!\.d)\.ts|\.hbs|\.gts|\.gjs$/, '.js');
12
+ }
13
+ function publicEntrypoints(args) {
14
+ const allEntryPoints = new Set();
15
+ return {
16
+ name: 'addon-modules',
17
+ async buildStart() {
18
+ const include = [
19
+ ...args.include,
20
+ '**/*.hbs',
21
+ '**/*.ts',
22
+ '**/*.gts',
23
+ '**/*.gjs',
24
+ ];
25
+ // wait a bit first https://github.com/nodejs/node/issues/4760
26
+ await new Promise((resolve) => setTimeout(resolve, 50));
27
+ let matches = (0, walk_sync_1.default)(args.srcDir, {
28
+ globs: include,
29
+ ignore: args.exclude,
30
+ });
31
+ matches.forEach((m) => allEntryPoints.add(m));
32
+ for (const name of allEntryPoints) {
33
+ this.addWatchFile(path_1.default.resolve(args.srcDir, name));
34
+ }
35
+ for (let name of matches) {
36
+ // the matched file, but with the extension swapped with .js
37
+ let normalizedName = normalizeFileExt(name);
38
+ // anything that doesn't match the users patterns, and wasn't a template-only
39
+ // component needs to be emitted "as-is" so that other plugins may handle it.
40
+ let isTO = isTemplateOnly(matches, name);
41
+ let isHbs = path_1.default.extname(name) === '.hbs';
42
+ // hbs for-colocated components is handled by the rollup-hbs-plugin
43
+ // hbs for template-only components is handled in the isTO block
44
+ if (isHbs && !isTO) {
45
+ continue;
46
+ }
47
+ // these chunks matched are **/*.hbs glob and are
48
+ // guaranteed to not have any corresponding file as a co-located component would have.
49
+ if (isTO) {
50
+ this.emitFile({
51
+ type: 'chunk',
52
+ id: path_1.default.join(args.srcDir, normalizedName),
53
+ fileName: normalizedName,
54
+ });
55
+ continue;
56
+ }
57
+ // anything that matches one of the user's patterns is definitely emitted
58
+ let isUserDefined = args.include.some((pattern) => (0, minimatch_1.default)(name, pattern));
59
+ // additionally, we want to emit chunks where the pattern matches the supported
60
+ // file extensions above (TS, GTS, etc) as if they were already the built JS.
61
+ let wouldMatchIfBuilt = include.some((pattern) => (0, minimatch_1.default)(normalizedName, pattern));
62
+ if (isUserDefined || wouldMatchIfBuilt) {
63
+ this.emitFile({
64
+ type: 'chunk',
65
+ id: path_1.default.join(args.srcDir, name),
66
+ fileName: normalizedName,
67
+ });
68
+ continue;
69
+ }
70
+ }
71
+ },
72
+ };
73
+ }
74
+ function isTemplateOnly(matches, filePath) {
75
+ let isHbs = path_1.default.extname(filePath) === '.hbs';
76
+ if (!isHbs)
77
+ return false;
78
+ let correspondingFileGlob = path_1.default.join(path_1.default.dirname(filePath), path_1.default.basename(filePath).replace(/hbs$/, '*'));
79
+ let relatedFiles = matches.filter((match) => (0, minimatch_1.default)(match, correspondingFileGlob));
80
+ let isTO = relatedFiles.filter((x) => x !== filePath).length === 0;
81
+ return isTO;
82
+ }
83
+ //# sourceMappingURL=rollup-public-entrypoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rollup-public-entrypoints.js","sourceRoot":"","sources":["rollup-public-entrypoints.ts"],"names":[],"mappings":";;;;;AAUA,oCAkFC;AA5FD,0DAAiC;AACjC,gDAAwB;AACxB,0DAAkC;AAIlC,SAAS,gBAAgB,CAAC,QAAgB;IACxC,OAAO,QAAQ,CAAC,OAAO,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;AACpE,CAAC;AAED,SAAwB,iBAAiB,CAAC,IAIzC;IACC,MAAM,cAAc,GAAgB,IAAI,GAAG,EAAE,CAAC;IAE9C,OAAO;QACL,IAAI,EAAE,eAAe;QAErB,KAAK,CAAC,UAAU;YACd,MAAM,OAAO,GAAG;gBACd,GAAG,IAAI,CAAC,OAAO;gBACf,UAAU;gBACV,SAAS;gBACT,UAAU;gBACV,UAAU;aACX,CAAC;YACF,8DAA8D;YAC9D,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;YACxD,IAAI,OAAO,GAAG,IAAA,mBAAQ,EAAC,IAAI,CAAC,MAAM,EAAE;gBAClC,KAAK,EAAE,OAAO;gBACd,MAAM,EAAE,IAAI,CAAC,OAAO;aACrB,CAAC,CAAC;YAEH,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC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AiB,EAAE,CAAC;oBACvC,IAAI,CAAC,QAAQ,CAAC;wBACZ,IAAI,EAAE,OAAO;wBACb,EAAE,EAAE,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC;wBAChC,QAAQ,EAAE,cAAc;qBACzB,CAAC,CAAC;oBAEH,SAAS;gBACX,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,OAAiB,EAAE,QAAgB;IACzD,IAAI,KAAK,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,MAAM,CAAC;IAE9C,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IAEzB,IAAI,qBAAqB,GAAG,cAAI,CAAC,IAAI,CACnC,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EACtB,cAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAC7C,CAAC;IAEF,IAAI,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAC1C,IAAA,mBAAS,EAAC,KAAK,EAAE,qBAAqB,CAAC,CACxC,CAAC;IACF,IAAI,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;IAEnE,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import walkSync from 'walk-sync';\nimport path from 'path';\nimport minimatch from 'minimatch';\n\nimport type { Plugin } from 'rollup';\n\nfunction normalizeFileExt(fileName: string) {\n return fileName.replace(/(?<!\\.d)\\.ts|\\.hbs|\\.gts|\\.gjs$/, '.js');\n}\n\nexport default function publicEntrypoints(args: {\n srcDir: string;\n include: string[];\n exclude?: string[];\n}): Plugin {\n const allEntryPoints: Set<string> = new Set();\n\n return {\n name: 'addon-modules',\n\n async buildStart() {\n const include = [\n ...args.include,\n '**/*.hbs',\n '**/*.ts',\n '**/*.gts',\n '**/*.gjs',\n ];\n // wait a bit first https://github.com/nodejs/node/issues/4760\n await new Promise((resolve) => setTimeout(resolve, 50));\n let matches = walkSync(args.srcDir, {\n globs: include,\n ignore: args.exclude,\n });\n\n matches.forEach((m) => allEntryPoints.add(m));\n\n for (const name of allEntryPoints) {\n this.addWatchFile(path.resolve(args.srcDir, name));\n }\n\n for (let name of matches) {\n // the matched file, but with the extension swapped with .js\n let normalizedName = normalizeFileExt(name);\n\n // anything that doesn't match the users patterns, and wasn't a template-only\n // component needs to be emitted \"as-is\" so that other plugins may handle it.\n let isTO = isTemplateOnly(matches, name);\n\n let isHbs = path.extname(name) === '.hbs';\n\n // hbs for-colocated components is handled by the rollup-hbs-plugin\n // hbs for template-only components is handled in the isTO block\n if (isHbs && !isTO) {\n continue;\n }\n\n // these chunks matched are **/*.hbs glob and are\n // guaranteed to not have any corresponding file as a co-located component would have.\n if (isTO) {\n this.emitFile({\n type: 'chunk',\n id: path.join(args.srcDir, normalizedName),\n fileName: normalizedName,\n });\n\n continue;\n }\n\n // anything that matches one of the user's patterns is definitely emitted\n let isUserDefined = args.include.some((pattern) =>\n minimatch(name, pattern)\n );\n\n // additionally, we want to emit chunks where the pattern matches the supported\n // file extensions above (TS, GTS, etc) as if they were already the built JS.\n let wouldMatchIfBuilt = include.some((pattern) =>\n minimatch(normalizedName, pattern)\n );\n\n if (isUserDefined || wouldMatchIfBuilt) {\n this.emitFile({\n type: 'chunk',\n id: path.join(args.srcDir, name),\n fileName: normalizedName,\n });\n\n continue;\n }\n }\n },\n };\n}\n\nfunction isTemplateOnly(matches: string[], filePath: string) {\n let isHbs = path.extname(filePath) === '.hbs';\n\n if (!isHbs) return false;\n\n let correspondingFileGlob = path.join(\n path.dirname(filePath),\n path.basename(filePath).replace(/hbs$/, '*')\n );\n\n let relatedFiles = matches.filter((match) =>\n minimatch(match, correspondingFileGlob)\n );\n let isTO = relatedFiles.filter((x) => x !== filePath).length === 0;\n\n return isTO;\n}\n"]}
@@ -0,0 +1,33 @@
1
+ import { type PublicAssetsOptions } from './rollup-public-assets';
2
+ import type { Plugin } from 'rollup';
3
+ export declare class Addon {
4
+ #private;
5
+ constructor(params?: {
6
+ srcDir?: string;
7
+ destDir?: string;
8
+ });
9
+ appReexports(patterns: string[], opts?: {
10
+ mapFilename?: (fileName: string) => string;
11
+ exports?: (filename: string) => string[] | string | undefined;
12
+ exclude?: string[];
13
+ }): Plugin;
14
+ publicEntrypoints(patterns: string[], opts?: {
15
+ exclude?: string[];
16
+ }): Plugin<any>;
17
+ hbs(options?: {}): Plugin<any>;
18
+ gjs(): Plugin<any>;
19
+ clean(): Plugin<any>;
20
+ keepAssets(patterns: string[], exports?: undefined | 'default' | '*'): Plugin<any>;
21
+ output(): {
22
+ dir: string;
23
+ entryFileNames: string;
24
+ experimentalMinChunkSize: number;
25
+ format: string;
26
+ hoistTransitiveImports: boolean;
27
+ sourcemap: boolean;
28
+ };
29
+ dependencies(): Plugin<any>;
30
+ publicAssets(path: string, opts?: PublicAssetsOptions): Plugin<any>;
31
+ declarations(path: string, command?: string): Plugin<any>;
32
+ }
33
+ //# sourceMappingURL=rollup.d.ts.map
package/src/rollup.js ADDED
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ var _Addon_srcDir, _Addon_destDir;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.Addon = void 0;
19
+ const rollup_hbs_plugin_1 = __importDefault(require("./rollup-hbs-plugin"));
20
+ const rollup_gjs_plugin_1 = __importDefault(require("./rollup-gjs-plugin"));
21
+ const rollup_public_entrypoints_1 = __importDefault(require("./rollup-public-entrypoints"));
22
+ const rollup_app_reexports_1 = __importDefault(require("./rollup-app-reexports"));
23
+ const rollup_keep_assets_1 = __importDefault(require("./rollup-keep-assets"));
24
+ const rollup_declarations_1 = __importDefault(require("./rollup-declarations"));
25
+ const rollup_addon_dependencies_1 = __importDefault(require("./rollup-addon-dependencies"));
26
+ const rollup_public_assets_1 = __importDefault(require("./rollup-public-assets"));
27
+ const rollup_incremental_plugin_1 = __importDefault(require("./rollup-incremental-plugin"));
28
+ class Addon {
29
+ constructor(params = {}) {
30
+ var _a, _b;
31
+ _Addon_srcDir.set(this, void 0);
32
+ _Addon_destDir.set(this, void 0);
33
+ __classPrivateFieldSet(this, _Addon_srcDir, (_a = params.srcDir) !== null && _a !== void 0 ? _a : 'src', "f");
34
+ __classPrivateFieldSet(this, _Addon_destDir, (_b = params.destDir) !== null && _b !== void 0 ? _b : 'dist', "f");
35
+ }
36
+ // Given a list of globs describing modules in your srcDir, this generates
37
+ // corresponding appTree modules that contain reexports, and updates your
38
+ // package.json metadata to list them all.
39
+ appReexports(patterns, opts = {}) {
40
+ return (0, rollup_app_reexports_1.default)({
41
+ from: __classPrivateFieldGet(this, _Addon_srcDir, "f"),
42
+ to: __classPrivateFieldGet(this, _Addon_destDir, "f"),
43
+ include: patterns,
44
+ mapFilename: opts.mapFilename,
45
+ exports: opts.exports,
46
+ exclude: opts.exclude,
47
+ });
48
+ }
49
+ // This configures rollup to emit public entrypoints for each module in your
50
+ // srcDir that matches one of the given globs. Typical addons will want to
51
+ // match patterns like "components/**/*.js", "index.js", and "test-support.js".
52
+ publicEntrypoints(patterns, opts = {}) {
53
+ return (0, rollup_public_entrypoints_1.default)({
54
+ srcDir: __classPrivateFieldGet(this, _Addon_srcDir, "f"),
55
+ include: patterns,
56
+ exclude: opts.exclude,
57
+ });
58
+ }
59
+ // This wraps standalone .hbs files as Javascript files using inline
60
+ // templates. This means special resolving rules for .hbs files aren't
61
+ // required for javascript tooling to understand your package.
62
+ hbs(options = {}) {
63
+ return (0, rollup_hbs_plugin_1.default)(options);
64
+ }
65
+ gjs() {
66
+ return (0, rollup_gjs_plugin_1.default)();
67
+ }
68
+ // this does incremental updates to the dist files and also deletes files that are not part of the generated bundle
69
+ // rollup already supports incremental transforms of files,
70
+ // this extends it to the dist files
71
+ clean() {
72
+ return (0, rollup_incremental_plugin_1.default)();
73
+ }
74
+ // V2 Addons are allowed to contain imports of .css files. This tells rollup
75
+ // to leave those imports alone and to make sure the corresponding .css files
76
+ // are kept in the same relative locations in the destDir as they were in the
77
+ // srcDir.
78
+ keepAssets(patterns, exports) {
79
+ return (0, rollup_keep_assets_1.default)({
80
+ from: __classPrivateFieldGet(this, _Addon_srcDir, "f"),
81
+ include: patterns,
82
+ exports: exports,
83
+ });
84
+ }
85
+ // This is the default `output` configuration you should pass to rollup. We're
86
+ // emitting ES modules, in your `destDir`, and their filenames are equal to
87
+ // their bundle names (the bundle names get generated by `publicEntrypoints`
88
+ // above).
89
+ //
90
+ // hoistTransitiveImports is disabled because the purpose of hoisting transitive imports
91
+ // is to improve performance of apps loading modules.
92
+ // Since v2 addons do not know exactly how they'll be used, this performance decision
93
+ // is left up to apps.
94
+ output() {
95
+ return {
96
+ dir: __classPrivateFieldGet(this, _Addon_destDir, "f"),
97
+ entryFileNames: '[name]',
98
+ experimentalMinChunkSize: 0,
99
+ format: 'es',
100
+ hoistTransitiveImports: false,
101
+ sourcemap: true,
102
+ };
103
+ }
104
+ dependencies() {
105
+ return (0, rollup_addon_dependencies_1.default)();
106
+ }
107
+ publicAssets(path, opts) {
108
+ return (0, rollup_public_assets_1.default)(path, opts);
109
+ }
110
+ declarations(path, command) {
111
+ return (0, rollup_declarations_1.default)(path, command);
112
+ }
113
+ }
114
+ exports.Addon = Addon;
115
+ _Addon_srcDir = new WeakMap(), _Addon_destDir = new WeakMap();
116
+ //# sourceMappingURL=rollup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rollup.js","sourceRoot":"","sources":["rollup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,4EAAqD;AACrD,4EAAqD;AACrD,4FAA2E;AAC3E,kFAAiE;AACjE,8EAA6D;AAC7D,gFAAgE;AAChE,4FAAsE;AACtE,kFAGgC;AAChC,4FAA+D;AAG/D,MAAa,KAAK;IAIhB,YAAY,SAAgD,EAAE;;QAH9D,gCAAgB;QAChB,iCAAiB;QAGf,uBAAA,IAAI,iBAAW,MAAA,MAAM,CAAC,MAAM,mCAAI,KAAK,MAAA,CAAC;QACtC,uBAAA,IAAI,kBAAY,MAAA,MAAM,CAAC,OAAO,mCAAI,MAAM,MAAA,CAAC;IAC3C,CAAC;IAED,0EAA0E;IAC1E,yEAAyE;IACzE,0CAA0C;IAC1C,YAAY,CACV,QAAkB,EAClB,OAII,EAAE;QAEN,OAAO,IAAA,8BAAY,EAAC;YAClB,IAAI,EAAE,uBAAA,IAAI,qBAAQ;YAClB,EAAE,EAAE,uBAAA,IAAI,sBAAS;YACjB,OAAO,EAAE,QAAQ;YACjB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC,CAAC;IACL,CAAC;IAED,4EAA4E;IAC5E,0EAA0E;IAC1E,+EAA+E;IAC/E,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CAAC,CAAC;IAClC,CAAC;IAED,YAAY,CAAC,IAAY,EAAE,OAAgB;QACzC,OAAO,IAAA,6BAAY,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACrC,CAAC;CACF;AAtGD,sBAsGC","sourcesContent":["import { default as hbs } from './rollup-hbs-plugin';\nimport { default as gjs } from './rollup-gjs-plugin';\nimport { default as publicEntrypoints } from './rollup-public-entrypoints';\nimport { default as appReexports } from './rollup-app-reexports';\nimport { default as keepAssets } from './rollup-keep-assets';\nimport { default as declarations } from './rollup-declarations';\nimport { default as dependencies } from './rollup-addon-dependencies';\nimport {\n default as publicAssets,\n type PublicAssetsOptions,\n} from './rollup-public-assets';\nimport { default as clean } from './rollup-incremental-plugin';\nimport type { Plugin } from 'rollup';\n\nexport class Addon {\n #srcDir: string;\n #destDir: string;\n\n constructor(params: { srcDir?: string; destDir?: string } = {}) {\n this.#srcDir = params.srcDir ?? 'src';\n this.#destDir = params.destDir ?? 'dist';\n }\n\n // Given a list of globs describing modules in your srcDir, this generates\n // corresponding appTree modules that contain reexports, and updates your\n // package.json metadata to list them all.\n appReexports(\n patterns: string[],\n opts: {\n mapFilename?: (fileName: string) => string;\n exports?: (filename: string) => string[] | string | undefined;\n exclude?: string[];\n } = {}\n ): Plugin {\n return appReexports({\n from: this.#srcDir,\n to: this.#destDir,\n include: patterns,\n mapFilename: opts.mapFilename,\n exports: opts.exports,\n exclude: opts.exclude,\n });\n }\n\n // This configures rollup to emit public entrypoints for each module in your\n // srcDir that matches one of the given globs. Typical addons will want to\n // match patterns like \"components/**/*.js\", \"index.js\", and \"test-support.js\".\n publicEntrypoints(patterns: string[], opts: { exclude?: string[] } = {}) {\n return publicEntrypoints({\n srcDir: this.#srcDir,\n include: patterns,\n exclude: opts.exclude,\n });\n }\n\n // This wraps standalone .hbs files as Javascript files using inline\n // templates. This means special resolving rules for .hbs files aren't\n // required for javascript tooling to understand your package.\n hbs(options = {}) {\n return hbs(options);\n }\n\n gjs() {\n return gjs();\n }\n\n // this does incremental updates to the dist files and also deletes files that are not part of the generated bundle\n // rollup already supports incremental transforms of files,\n // this extends it to the dist files\n clean() {\n return clean();\n }\n\n // V2 Addons are allowed to contain imports of .css files. This tells rollup\n // to leave those imports alone and to make sure the corresponding .css files\n // are kept in the same relative locations in the destDir as they were in the\n // srcDir.\n keepAssets(patterns: string[], exports?: undefined | 'default' | '*') {\n return keepAssets({\n from: this.#srcDir,\n include: patterns,\n exports: exports,\n });\n }\n\n // This is the default `output` configuration you should pass to rollup. We're\n // emitting ES modules, in your `destDir`, and their filenames are equal to\n // their bundle names (the bundle names get generated by `publicEntrypoints`\n // above).\n //\n // hoistTransitiveImports is disabled because the purpose of hoisting transitive imports\n // is to improve performance of apps loading modules.\n // Since v2 addons do not know exactly how they'll be used, this performance decision\n // is left up to apps.\n output() {\n return {\n dir: this.#destDir,\n entryFileNames: '[name]',\n experimentalMinChunkSize: 0,\n format: 'es',\n hoistTransitiveImports: false,\n sourcemap: true,\n };\n }\n\n dependencies() {\n return dependencies();\n }\n\n publicAssets(path: string, opts?: PublicAssetsOptions) {\n return publicAssets(path, opts);\n }\n\n declarations(path: string, command?: string) {\n return declarations(path, command);\n }\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import { templateColocationPlugin, Options as TemplateColocationPluginOptions } from '@embroider/core';
2
+ export { TemplateColocationPluginOptions as Options };
3
+ export default templateColocationPlugin;
4
+ //# sourceMappingURL=template-colocation-plugin.d.ts.map
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@embroider/core");
4
+ exports.default = core_1.templateColocationPlugin;
5
+ //# sourceMappingURL=template-colocation-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template-colocation-plugin.js","sourceRoot":"","sources":["template-colocation-plugin.ts"],"names":[],"mappings":";;AAAA,0CAGyB;AAGzB,kBAAe,+BAAwB,CAAC","sourcesContent":["import {\n templateColocationPlugin,\n Options as TemplateColocationPluginOptions,\n} from '@embroider/core';\n\nexport { TemplateColocationPluginOptions as Options };\nexport default templateColocationPlugin;\n"]}