@embroider/addon-dev 4.2.2-unstable.f30e685 → 4.3.1-unstable.445e96b
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.
- package/README.md +4 -0
- package/package.json +2 -2
- package/src/rollup-hbs-plugin.d.ts +3 -1
- package/src/rollup-hbs-plugin.js +28 -16
- package/src/rollup-hbs-plugin.js.map +1 -1
- package/src/rollup-public-assets.d.ts +21 -4
- package/src/rollup-public-assets.js +9 -1
- package/src/rollup-public-assets.js.map +1 -1
- package/src/rollup.d.ts +3 -5
- package/src/rollup.js +2 -2
- package/src/rollup.js.map +1 -1
package/README.md
CHANGED
|
@@ -18,6 +18,10 @@ For a guide on porting a V1 addon to V2, see https://github.com/embroider-build/
|
|
|
18
18
|
2. Copy the `./sample-rollup.config.js` in this repo to your own `rollup.config.js`.
|
|
19
19
|
3. Copy the `./sample-babel.config.json` in this repo to your own `babel.config.json`.
|
|
20
20
|
|
|
21
|
+
### addon.publicAssets(path <required>, options)
|
|
22
|
+
|
|
23
|
+
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
|
|
24
|
+
|
|
21
25
|
## addon-dev command
|
|
22
26
|
|
|
23
27
|
The `addon-dev` command helps with common tasks in v2 addons.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embroider/addon-dev",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.1-unstable.445e96b",
|
|
4
4
|
"description": "Utilities for addon authors",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"test": "jest"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@embroider/core": "3.4.
|
|
29
|
+
"@embroider/core": "3.4.8-unstable.445e96b",
|
|
30
30
|
"@rollup/pluginutils": "^4.1.1",
|
|
31
31
|
"content-tag": "^2.0.1",
|
|
32
32
|
"fs-extra": "^10.0.0",
|
package/src/rollup-hbs-plugin.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
const pluginutils_1 = require("@rollup/pluginutils");
|
|
4
7
|
const fs_1 = require("fs");
|
|
5
8
|
const core_1 = require("@embroider/core");
|
|
6
|
-
const
|
|
7
|
-
function rollupHbsPlugin() {
|
|
9
|
+
const minimatch_1 = __importDefault(require("minimatch"));
|
|
10
|
+
function rollupHbsPlugin({ excludeColocation, }) {
|
|
8
11
|
return {
|
|
9
12
|
name: 'rollup-hbs-plugin',
|
|
10
13
|
async resolveId(source, importer, options) {
|
|
@@ -16,18 +19,19 @@ function rollupHbsPlugin() {
|
|
|
16
19
|
return resolution;
|
|
17
20
|
}
|
|
18
21
|
else {
|
|
19
|
-
return maybeSynthesizeComponentJS(this, source, importer, options);
|
|
22
|
+
return maybeSynthesizeComponentJS(this, source, importer, options, excludeColocation);
|
|
20
23
|
}
|
|
21
24
|
},
|
|
22
25
|
load(id) {
|
|
23
26
|
if (hbsFilter(id)) {
|
|
24
|
-
|
|
25
|
-
let code = (0, core_1.hbsToJS)(input);
|
|
26
|
-
return {
|
|
27
|
-
code,
|
|
28
|
-
};
|
|
27
|
+
return getHbsToJSCode(id);
|
|
29
28
|
}
|
|
30
|
-
|
|
29
|
+
let meta = getMeta(this, id);
|
|
30
|
+
if (meta) {
|
|
31
|
+
if ((meta === null || meta === void 0 ? void 0 : meta.type) === 'template-js') {
|
|
32
|
+
const hbsFile = id.replace(/\.js$/, '.hbs');
|
|
33
|
+
return getHbsToJSCode(hbsFile);
|
|
34
|
+
}
|
|
31
35
|
return {
|
|
32
36
|
code: templateOnlyComponent,
|
|
33
37
|
};
|
|
@@ -48,25 +52,33 @@ function getMeta(context, id) {
|
|
|
48
52
|
return null;
|
|
49
53
|
}
|
|
50
54
|
}
|
|
51
|
-
function
|
|
52
|
-
let
|
|
53
|
-
|
|
55
|
+
function getHbsToJSCode(file) {
|
|
56
|
+
let input = (0, fs_1.readFileSync)(file, 'utf8');
|
|
57
|
+
let code = (0, core_1.hbsToJS)(input);
|
|
58
|
+
return {
|
|
59
|
+
code,
|
|
60
|
+
};
|
|
54
61
|
}
|
|
55
|
-
async function maybeSynthesizeComponentJS(context, source, importer, options) {
|
|
56
|
-
let
|
|
62
|
+
async function maybeSynthesizeComponentJS(context, source, importer, options, excludeColocation) {
|
|
63
|
+
let hbsFilename = (0, core_1.correspondingTemplate)(source);
|
|
64
|
+
let templateResolution = await context.resolve(hbsFilename, importer, {
|
|
57
65
|
skipSelf: true,
|
|
58
66
|
...options,
|
|
59
67
|
});
|
|
60
68
|
if (!templateResolution) {
|
|
61
69
|
return null;
|
|
62
70
|
}
|
|
71
|
+
let type = (excludeColocation === null || excludeColocation === void 0 ? void 0 : excludeColocation.some((glob) => (0, minimatch_1.default)(hbsFilename, glob)))
|
|
72
|
+
? 'template-js'
|
|
73
|
+
: 'template-only-component-js';
|
|
63
74
|
// we're trying to resolve a JS module but only the corresponding HBS
|
|
64
|
-
// file exists. Synthesize the
|
|
75
|
+
// file exists. Synthesize the JS. The meta states if the hbs corresponds
|
|
76
|
+
// to a template-only component or a simple template like a route template.
|
|
65
77
|
return {
|
|
66
78
|
id: templateResolution.id.replace(/\.hbs$/, '.js'),
|
|
67
79
|
meta: {
|
|
68
80
|
'rollup-hbs-plugin': {
|
|
69
|
-
type
|
|
81
|
+
type,
|
|
70
82
|
},
|
|
71
83
|
},
|
|
72
84
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup-hbs-plugin.js","sourceRoot":"","sources":["rollup-hbs-plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rollup-hbs-plugin.js","sourceRoot":"","sources":["rollup-hbs-plugin.ts"],"names":[],"mappings":";;;;;AAAA,qDAAmD;AAEnD,2BAAkC;AAClC,0CAAiE;AACjE,0DAAkC;AAElC,SAAwB,eAAe,CAAC,EACtC,iBAAiB,GAGlB;IACC,OAAO;QACL,IAAI,EAAE,mBAAmB;QACzB,KAAK,CAAC,SAAS,CAAC,MAAc,EAAE,QAA4B,EAAE,OAAO;YACnE,IAAI,UAAU,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE;gBACpD,QAAQ,EAAE,IAAI;gBACd,GAAG,OAAO;aACX,CAAC,CAAC;YAEH,IAAI,UAAU,EAAE;gBACd,OAAO,UAAU,CAAC;aACnB;iBAAM;gBACL,OAAO,0BAA0B,CAC/B,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,OAAO,EACP,iBAAiB,CAClB,CAAC;aACH;QACH,CAAC;QAED,IAAI,CAAC,EAAU;YACb,IAAI,SAAS,CAAC,EAAE,CAAC,EAAE;gBACjB,OAAO,cAAc,CAAC,EAAE,CAAC,CAAC;aAC3B;YACD,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAC7B,IAAI,IAAI,EAAE;gBACR,IAAI,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,MAAK,aAAa,EAAE;oBAChC,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;oBAC5C,OAAO,cAAc,CAAC,OAAO,CAAC,CAAC;iBAChC;gBACD,OAAO;oBACL,IAAI,EAAE,qBAAqB;iBAC5B,CAAC;aACH;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AA1CD,kCA0CC;AAED,MAAM,qBAAqB,GACzB,8DAA8D;IAC9D,kCAAkC,CAAC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AI;aACL;SACF;KACF,CAAC;AACJ,CAAC;AAED,MAAM,SAAS,GAAG,IAAA,0BAAY,EAAC,UAAU,CAAC,CAAC","sourcesContent":["import { createFilter } from '@rollup/pluginutils';\nimport type { Plugin, PluginContext, CustomPluginOptions } from 'rollup';\nimport { readFileSync } from 'fs';\nimport { correspondingTemplate, hbsToJS } from '@embroider/core';\nimport minimatch from 'minimatch';\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 let resolution = await this.resolve(source, importer, {\n skipSelf: true,\n ...options,\n });\n\n if (resolution) {\n return resolution;\n } else {\n return maybeSynthesizeComponentJS(\n this,\n source,\n importer,\n options,\n excludeColocation\n );\n }\n },\n\n load(id: string) {\n if (hbsFilter(id)) {\n return getHbsToJSCode(id);\n }\n let meta = getMeta(this, id);\n if (meta) {\n if (meta?.type === 'template-js') {\n const hbsFile = id.replace(/\\.js$/, '.hbs');\n return getHbsToJSCode(hbsFile);\n }\n return {\n code: templateOnlyComponent,\n };\n }\n },\n };\n}\n\nconst templateOnlyComponent =\n `import templateOnly from '@ember/component/template-only';\\n` +\n `export default templateOnly();\\n`;\n\ntype Meta = {\n type: 'template-only-component-js' | 'template-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\nfunction getHbsToJSCode(file: string): { code: string } {\n let input = readFileSync(file, 'utf8');\n let code = hbsToJS(input);\n return {\n code,\n };\n}\n\nasync function maybeSynthesizeComponentJS(\n context: PluginContext,\n source: string,\n importer: string | undefined,\n options: { custom?: CustomPluginOptions; isEntry: boolean },\n excludeColocation: string[] | undefined\n) {\n let hbsFilename = correspondingTemplate(source);\n let templateResolution = await context.resolve(hbsFilename, importer, {\n skipSelf: true,\n ...options,\n });\n if (!templateResolution) {\n return null;\n }\n let type = excludeColocation?.some((glob) => minimatch(hbsFilename, glob))\n ? 'template-js'\n : 'template-only-component-js';\n // we're trying to resolve a JS module but only the corresponding HBS\n // file exists. Synthesize the JS. The meta states if the hbs corresponds\n // to a template-only component or a simple template like a route template.\n return {\n id: templateResolution.id.replace(/\\.hbs$/, '.js'),\n meta: {\n 'rollup-hbs-plugin': {\n type,\n },\n },\n };\n}\n\nconst hbsFilter = createFilter('**/*.hbs');\n"]}
|
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
import type { Plugin } from 'rollup';
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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;
|
|
@@ -5,6 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const fs_extra_1 = require("fs-extra");
|
|
7
7
|
const walk_sync_1 = __importDefault(require("walk-sync"));
|
|
8
|
+
const posix_1 = require("path/posix");
|
|
9
|
+
/**
|
|
10
|
+
* A rollup plugin to expose a folder of assets
|
|
11
|
+
*
|
|
12
|
+
* @param path - the public folder that you want to add as public assets
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
8
15
|
function publicAssets(path, opts) {
|
|
9
16
|
const includeGlobPatterns = opts === null || opts === void 0 ? void 0 : opts.include;
|
|
10
17
|
const excludedGlobPatterns = (opts === null || opts === void 0 ? void 0 : opts.exclude) || [];
|
|
@@ -24,7 +31,8 @@ function publicAssets(path, opts) {
|
|
|
24
31
|
ignore: excludedGlobPatterns,
|
|
25
32
|
});
|
|
26
33
|
const publicAssets = filenames.reduce((acc, v) => {
|
|
27
|
-
|
|
34
|
+
var _a;
|
|
35
|
+
acc[`./${path}/${v}`] = (0, posix_1.resolve)('/' + (0, posix_1.join)((_a = opts === null || opts === void 0 ? void 0 : opts.namespace) !== null && _a !== void 0 ? _a : pkg.name, path, v));
|
|
28
36
|
return acc;
|
|
29
37
|
}, {});
|
|
30
38
|
let originalPublicAssets = (_a = pkg['ember-addon']) === null || _a === void 0 ? void 0 : _a['public-assets'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup-public-assets.js","sourceRoot":"","sources":["rollup-public-assets.ts"],"names":[],"mappings":";;;;;AAAA,uCAAuD;AACvD,0DAAiC;
|
|
1
|
+
{"version":3,"file":"rollup-public-assets.js","sourceRoot":"","sources":["rollup-public-assets.ts"],"names":[],"mappings":";;;;;AAAA,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,cAAc;;YACZ,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,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,EAAE,CAAC,GAAG,IAAA,eAAO,EAC7B,GAAG,GAAG,IAAA,YAAI,EAAC,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,SAAS,mCAAI,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CACjD,CAAC;gBACF,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;gBACd,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;aACnD;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AA/CD,+BA+CC","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 generateBundle() {\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 acc[`./${path}/${v}`] = resolve(\n '/' + join(opts?.namespace ?? pkg.name, path, v)\n );\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"]}
|
package/src/rollup.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Options as DelOptions } from 'rollup-plugin-delete';
|
|
2
|
+
import { type PublicAssetsOptions } from './rollup-public-assets';
|
|
2
3
|
import type { Plugin } from 'rollup';
|
|
3
4
|
export declare class Addon {
|
|
4
5
|
#private;
|
|
@@ -14,7 +15,7 @@ export declare class Addon {
|
|
|
14
15
|
publicEntrypoints(patterns: string[], opts?: {
|
|
15
16
|
exclude?: string[];
|
|
16
17
|
}): Plugin<any>;
|
|
17
|
-
hbs(): Plugin<any>;
|
|
18
|
+
hbs(options?: {}): Plugin<any>;
|
|
18
19
|
gjs(options?: {
|
|
19
20
|
inline_source_map: boolean;
|
|
20
21
|
}): Plugin<any>;
|
|
@@ -29,8 +30,5 @@ export declare class Addon {
|
|
|
29
30
|
sourcemap: boolean;
|
|
30
31
|
};
|
|
31
32
|
dependencies(): Plugin<any>;
|
|
32
|
-
publicAssets(path: string, opts:
|
|
33
|
-
include: string[];
|
|
34
|
-
exclude: string[];
|
|
35
|
-
}): Plugin<any>;
|
|
33
|
+
publicAssets(path: string, opts?: PublicAssetsOptions): Plugin<any>;
|
|
36
34
|
}
|
package/src/rollup.js
CHANGED
|
@@ -58,8 +58,8 @@ class Addon {
|
|
|
58
58
|
// This wraps standalone .hbs files as Javascript files using inline
|
|
59
59
|
// templates. This means special resolving rules for .hbs files aren't
|
|
60
60
|
// required for javascript tooling to understand your package.
|
|
61
|
-
hbs() {
|
|
62
|
-
return (0, rollup_hbs_plugin_1.default)();
|
|
61
|
+
hbs(options = {}) {
|
|
62
|
+
return (0, rollup_hbs_plugin_1.default)(options);
|
|
63
63
|
}
|
|
64
64
|
gjs(options) {
|
|
65
65
|
return (0, rollup_gjs_plugin_1.default)(options);
|
package/src/rollup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup.js","sourceRoot":"","sources":["rollup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,4EAAqD;AACrD,4EAAqD;AACrD,4FAA2E;AAC3E,kFAAiE;AAEjE,gFAAwD;AACxD,8EAA6D;AAC7D,4FAAsE;AACtE,
|
|
1
|
+
{"version":3,"file":"rollup.js","sourceRoot":"","sources":["rollup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,4EAAqD;AACrD,4EAAqD;AACrD,4FAA2E;AAC3E,kFAAiE;AAEjE,gFAAwD;AACxD,8EAA6D;AAC7D,4FAAsE;AACtE,kFAGgC;AAGhC,MAAa,KA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C;IAC9D,CAAC;IAED,4EAA4E;IAC5E,6EAA6E;IAC7E,6EAA6E;IAC7E,UAAU;IACV,UAAU,CAAC,QAAkB;QAC3B,OAAO,IAAA,4BAAU,EAAC;YAChB,IAAI,EAAE,uBAAA,IAAI,qBAAQ;YAClB,OAAO,EAAE,QAAQ;SAClB,CAAC,CAAC;IACL,CAAC;IAED,8EAA8E;IAC9E,2EAA2E;IAC3E,4EAA4E;IAC5E,UAAU;IACV,EAAE;IACF,wFAAwF;IACxF,qDAAqD;IACrD,qFAAqF;IACrF,sBAAsB;IACtB,MAAM;QACJ,OAAO;YACL,GAAG,EAAE,uBAAA,IAAI,sBAAS;YAClB,cAAc,EAAE,QAAQ;YACxB,wBAAwB,EAAE,CAAC;YAC3B,MAAM,EAAE,IAAI;YACZ,sBAAsB,EAAE,KAAK;YAC7B,SAAS,EAAE,IAAI;SAChB,CAAC;IACJ,CAAC;IAED,YAAY;QACV,OAAO,IAAA,mCAAY,GAAE,CAAC;IACxB,CAAC;IAED,YAAY,CAAC,IAAY,EAAE,IAA0B;QACnD,OAAO,IAAA,8BAAY,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;CACF;AAhGD,sBAgGC","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 type { Options as DelOptions } from 'rollup-plugin-delete';\nimport { default as clean } from 'rollup-plugin-delete';\nimport { default as keepAssets } from './rollup-keep-assets';\nimport { default as dependencies } from './rollup-addon-dependencies';\nimport {\n default as publicAssets,\n type PublicAssetsOptions,\n} from './rollup-public-assets';\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(options?: { inline_source_map: boolean }) {\n return gjs(options);\n }\n\n // By default rollup does not clear the output directory between builds. This\n // does that.\n clean(options: DelOptions) {\n return clean({ targets: `${this.#destDir}/*`, ...options });\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[]) {\n return keepAssets({\n from: this.#srcDir,\n include: patterns,\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"]}
|