@embroider/addon-dev 1.8.3 → 3.0.0-unstable.21eae41
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/package.json +4 -13
- package/src/commands.js +0 -0
- package/src/rollup-public-assets.d.ts +5 -0
- package/src/rollup-public-assets.js +32 -0
- package/src/rollup-public-assets.js.map +1 -0
- package/src/rollup-public-entrypoints.js +40 -23
- package/src/rollup-public-entrypoints.js.map +1 -1
- package/src/rollup.d.ts +6 -0
- package/src/rollup.js +17 -2
- package/src/rollup.js.map +1 -1
- package/src/template-transform-plugin.d.ts +0 -17
- package/src/template-transform-plugin.js +0 -30
- package/src/template-transform-plugin.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embroider/addon-dev",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-unstable.21eae41",
|
|
4
4
|
"description": "Utilities for addon authors",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
},
|
|
15
15
|
"exports": {
|
|
16
16
|
"./template-colocation-plugin": "./src/template-colocation-plugin.js",
|
|
17
|
-
"./template-transform-plugin": "./src/template-transform-plugin.js",
|
|
18
17
|
"./rollup": "./src/rollup.js"
|
|
19
18
|
},
|
|
20
19
|
"files": [
|
|
@@ -24,11 +23,10 @@
|
|
|
24
23
|
"src/**/*.js.map"
|
|
25
24
|
],
|
|
26
25
|
"scripts": {
|
|
27
|
-
"prepare": "tsc",
|
|
28
26
|
"test": "jest"
|
|
29
27
|
},
|
|
30
28
|
"dependencies": {
|
|
31
|
-
"@embroider/core": "
|
|
29
|
+
"@embroider/core": "2.1.1-unstable.21eae41",
|
|
32
30
|
"@rollup/pluginutils": "^4.1.1",
|
|
33
31
|
"assert-never": "^1.2.1",
|
|
34
32
|
"fs-extra": "^10.0.0",
|
|
@@ -45,15 +43,8 @@
|
|
|
45
43
|
"@types/minimatch": "^3.0.4",
|
|
46
44
|
"@types/yargs": "^17.0.3",
|
|
47
45
|
"rollup": "^2.58.0",
|
|
48
|
-
"tmp": "^0.1.0"
|
|
49
|
-
|
|
50
|
-
"peerDependencies": {
|
|
51
|
-
"ember-source": "*"
|
|
52
|
-
},
|
|
53
|
-
"peerDependenciesMeta": {
|
|
54
|
-
"ember-source": {
|
|
55
|
-
"optional": true
|
|
56
|
-
}
|
|
46
|
+
"tmp": "^0.1.0",
|
|
47
|
+
"typescript": "*"
|
|
57
48
|
},
|
|
58
49
|
"engines": {
|
|
59
50
|
"node": "12.* || 14.* || >= 16"
|
package/src/commands.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
const fs_extra_1 = require("fs-extra");
|
|
7
|
+
const walk_sync_1 = __importDefault(require("walk-sync"));
|
|
8
|
+
function publicAssets(path, opts) {
|
|
9
|
+
const includeGlobPatterns = opts === null || opts === void 0 ? void 0 : opts.include;
|
|
10
|
+
const excludedGlobPatterns = (opts === null || opts === void 0 ? void 0 : opts.exclude) || [];
|
|
11
|
+
return {
|
|
12
|
+
name: 'public-assets-bundler',
|
|
13
|
+
generateBundle() {
|
|
14
|
+
let pkg = (0, fs_extra_1.readJsonSync)('package.json');
|
|
15
|
+
const filenames = (0, walk_sync_1.default)(path, {
|
|
16
|
+
directories: false,
|
|
17
|
+
globs: includeGlobPatterns,
|
|
18
|
+
ignore: excludedGlobPatterns,
|
|
19
|
+
});
|
|
20
|
+
const publicAssets = filenames.reduce((acc, v) => {
|
|
21
|
+
acc[`./${path}/${v}`] = ['/', pkg.name, '/', path, '/', v].join('');
|
|
22
|
+
return acc;
|
|
23
|
+
}, {});
|
|
24
|
+
pkg['ember-addon'] = Object.assign({}, pkg['ember-addon'], {
|
|
25
|
+
'public-assets': publicAssets,
|
|
26
|
+
});
|
|
27
|
+
(0, fs_extra_1.writeJsonSync)('package.json', pkg, { spaces: 2 });
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
exports.default = publicAssets;
|
|
32
|
+
//# 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":";;;;;AAAA,uCAAuD;AACvD,0DAAiC;AAGjC,SAAwB,YAAY,CAClC,IAAY,EACZ,IAA8C;IAE9C,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;QAC7B,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,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACpE,OAAO,GAAG,CAAC;YACb,CAAC,EACD,EAAE,CACH,CAAC;YAEF,GAAG,CAAC,aAAa,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,aAAa,CAAC,EAAE;gBACzD,eAAe,EAAE,YAAY;aAC9B,CAAC,CAAC;YAEH,IAAA,wBAAa,EAAC,cAAc,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;QACpD,CAAC;KACF,CAAC;AACJ,CAAC;AA/BD,+BA+BC","sourcesContent":["import { readJsonSync, writeJsonSync } from 'fs-extra';\nimport walkSync from 'walk-sync';\nimport type { Plugin } from 'rollup';\n\nexport default function publicAssets(\n path: string,\n opts: { include: string[]; exclude: string[] }\n): Plugin {\n const includeGlobPatterns = opts?.include;\n const excludedGlobPatterns = opts?.exclude || [];\n\n return {\n name: 'public-assets-bundler',\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}`] = ['/', pkg.name, '/', path, '/', v].join('');\n return acc;\n },\n {}\n );\n\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"]}
|
|
@@ -4,48 +4,65 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const walk_sync_1 = __importDefault(require("walk-sync"));
|
|
7
|
-
const path_1 = require("path");
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const minimatch_1 = __importDefault(require("minimatch"));
|
|
9
|
-
const fs_extra_1 = require("fs-extra");
|
|
10
9
|
function normalizeFileExt(fileName) {
|
|
11
10
|
return fileName.replace(/\.ts|\.hbs|\.gts|\.gjs$/, '.js');
|
|
12
11
|
}
|
|
13
|
-
const hbsPattern = '**/*.hbs';
|
|
14
12
|
function publicEntrypoints(args) {
|
|
15
13
|
return {
|
|
16
14
|
name: 'addon-modules',
|
|
17
15
|
async buildStart() {
|
|
18
16
|
let matches = (0, walk_sync_1.default)(args.srcDir, {
|
|
19
|
-
globs: [...args.include,
|
|
17
|
+
globs: [...args.include, '**/*.hbs', '**/*.ts', '**/*.gts', '**/*.gjs'],
|
|
20
18
|
});
|
|
21
19
|
for (let name of matches) {
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
// the matched file, but with the extension swapped with .js
|
|
21
|
+
let normalizedName = normalizeFileExt(name);
|
|
22
|
+
// anything that doesn't match the users patterns, and wasn't a template-only
|
|
23
|
+
// component needs to be emitted "as-is" so that other plugins may handle it.
|
|
24
|
+
let isTO = isTemplateOnly(matches, name);
|
|
25
|
+
let isHbs = path_1.default.extname(name) === '.hbs';
|
|
26
|
+
// hbs for-colocated components is handled by the rollup-hbs-plugin
|
|
27
|
+
// hbs for template-only components is handled in the isTO block
|
|
28
|
+
if (isHbs && !isTO) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
// these chunks matched are **/*.hbs glob and are
|
|
32
|
+
// guaranteed to not have any corresponding file as a co-located component would have.
|
|
33
|
+
if (isTO) {
|
|
24
34
|
this.emitFile({
|
|
25
35
|
type: 'chunk',
|
|
26
|
-
id:
|
|
27
|
-
fileName:
|
|
36
|
+
id: path_1.default.join(args.srcDir, normalizedName),
|
|
37
|
+
fileName: normalizedName,
|
|
28
38
|
});
|
|
39
|
+
continue;
|
|
29
40
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
fileName: normalizedName,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
41
|
+
// anything that matches one of the user's patterns is definitely emitted
|
|
42
|
+
let isUserDefined = args.include.some((pattern) => (0, minimatch_1.default)(name, pattern));
|
|
43
|
+
// additionally, we want to emit chunks where the pattern matches the supported
|
|
44
|
+
// file extensions above (TS, GTS, etc) as if they were already the built JS.
|
|
45
|
+
let wouldMatchIfBuilt = args.include.some((pattern) => (0, minimatch_1.default)(normalizedName, pattern));
|
|
46
|
+
if (isUserDefined || wouldMatchIfBuilt) {
|
|
47
|
+
this.emitFile({
|
|
48
|
+
type: 'chunk',
|
|
49
|
+
id: path_1.default.join(args.srcDir, name),
|
|
50
|
+
fileName: normalizedName,
|
|
51
|
+
});
|
|
52
|
+
continue;
|
|
45
53
|
}
|
|
46
54
|
}
|
|
47
55
|
},
|
|
48
56
|
};
|
|
49
57
|
}
|
|
50
58
|
exports.default = publicEntrypoints;
|
|
59
|
+
function isTemplateOnly(matches, filePath) {
|
|
60
|
+
let isHbs = path_1.default.extname(filePath) === '.hbs';
|
|
61
|
+
if (!isHbs)
|
|
62
|
+
return false;
|
|
63
|
+
let correspondingFileGlob = path_1.default.join(path_1.default.dirname(filePath), path_1.default.basename(filePath).replace(/hbs$/, '*'));
|
|
64
|
+
let relatedFiles = matches.filter((match) => (0, minimatch_1.default)(match, correspondingFileGlob));
|
|
65
|
+
let isTO = relatedFiles.filter((x) => x !== filePath).length === 0;
|
|
66
|
+
return isTO;
|
|
67
|
+
}
|
|
51
68
|
//# sourceMappingURL=rollup-public-entrypoints.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup-public-entrypoints.js","sourceRoot":"","sources":["rollup-public-entrypoints.ts"],"names":[],"mappings":";;;;;AAAA,0DAAiC;AACjC
|
|
1
|
+
{"version":3,"file":"rollup-public-entrypoints.js","sourceRoot":"","sources":["rollup-public-entrypoints.ts"],"names":[],"mappings":";;;;;AAAA,0DAAiC;AACjC,gDAAwB;AACxB,0DAAkC;AAIlC,SAAS,gBAAgB,CAAC,QAAgB;IACxC,OAAO,QAAQ,CAAC,OAAO,CAA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CAAC,CAAC,OAAO,EAAE,EAAE,CACpD,IAAA,mBAAS,EAAC,cAAc,EAAE,OAAO,CAAC,CACnC,CAAC;gBAEF,IAAI,aAAa,IAAI,iBAAiB,EAAE;oBACtC,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;iBACV;aACF;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AA9DD,oCA8DC;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(/\\.ts|\\.hbs|\\.gts|\\.gjs$/, '.js');\n}\n\nexport default function publicEntrypoints(args: {\n srcDir: string;\n include: string[];\n}): Plugin {\n return {\n name: 'addon-modules',\n async buildStart() {\n let matches = walkSync(args.srcDir, {\n globs: [...args.include, '**/*.hbs', '**/*.ts', '**/*.gts', '**/*.gjs'],\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 = args.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"]}
|
package/src/rollup.d.ts
CHANGED
|
@@ -16,6 +16,12 @@ export declare class Addon {
|
|
|
16
16
|
dir: string;
|
|
17
17
|
format: string;
|
|
18
18
|
entryFileNames: string;
|
|
19
|
+
hoistTransitiveImports: boolean;
|
|
20
|
+
sourcemap: boolean;
|
|
19
21
|
};
|
|
20
22
|
dependencies(): Plugin;
|
|
23
|
+
publicAssets(path: string, opts: {
|
|
24
|
+
include: string[];
|
|
25
|
+
exclude: string[];
|
|
26
|
+
}): Plugin;
|
|
21
27
|
}
|
package/src/rollup.js
CHANGED
|
@@ -22,6 +22,7 @@ const rollup_app_reexports_1 = __importDefault(require("./rollup-app-reexports")
|
|
|
22
22
|
const rollup_plugin_delete_1 = __importDefault(require("rollup-plugin-delete"));
|
|
23
23
|
const rollup_keep_assets_1 = __importDefault(require("./rollup-keep-assets"));
|
|
24
24
|
const rollup_addon_dependencies_1 = __importDefault(require("./rollup-addon-dependencies"));
|
|
25
|
+
const rollup_public_assets_1 = __importDefault(require("./rollup-public-assets"));
|
|
25
26
|
class Addon {
|
|
26
27
|
constructor(params = {}) {
|
|
27
28
|
var _a, _b;
|
|
@@ -56,7 +57,7 @@ class Addon {
|
|
|
56
57
|
// By default rollup does not clear the output directory between builds. This
|
|
57
58
|
// does that.
|
|
58
59
|
clean() {
|
|
59
|
-
return (0, rollup_plugin_delete_1.default)({ targets: `${__classPrivateFieldGet(this, _Addon_destDir, "f")}
|
|
60
|
+
return (0, rollup_plugin_delete_1.default)({ targets: `${__classPrivateFieldGet(this, _Addon_destDir, "f")}/*`, hook: 'generateBundle' });
|
|
60
61
|
}
|
|
61
62
|
// V2 Addons are allowed to contain imports of .css files. This tells rollup
|
|
62
63
|
// to leave those imports alone and to make sure the corresponding .css files
|
|
@@ -72,12 +73,26 @@ class Addon {
|
|
|
72
73
|
// emitting ES modules, in your `destDir`, and their filenames are equal to
|
|
73
74
|
// their bundle names (the bundle names get generated by `publicEntrypoints`
|
|
74
75
|
// above).
|
|
76
|
+
//
|
|
77
|
+
// hoistTransitiveImports is disabled because the purpose of hoisting transitive imports
|
|
78
|
+
// is to improve performance of apps loading modules.
|
|
79
|
+
// Since v2 addons do not know exactly how they'll be used, this performance decision
|
|
80
|
+
// is left up to apps.
|
|
75
81
|
output() {
|
|
76
|
-
return {
|
|
82
|
+
return {
|
|
83
|
+
dir: __classPrivateFieldGet(this, _Addon_destDir, "f"),
|
|
84
|
+
format: 'es',
|
|
85
|
+
entryFileNames: '[name]',
|
|
86
|
+
hoistTransitiveImports: false,
|
|
87
|
+
sourcemap: true,
|
|
88
|
+
};
|
|
77
89
|
}
|
|
78
90
|
dependencies() {
|
|
79
91
|
return (0, rollup_addon_dependencies_1.default)();
|
|
80
92
|
}
|
|
93
|
+
publicAssets(path, opts) {
|
|
94
|
+
return (0, rollup_public_assets_1.default)(path, opts);
|
|
95
|
+
}
|
|
81
96
|
}
|
|
82
97
|
exports.Addon = Addon;
|
|
83
98
|
_Addon_srcDir = new WeakMap(), _Addon_destDir = new WeakMap();
|
package/src/rollup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup.js","sourceRoot":"","sources":["rollup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,4EAAqD;AACrD,4FAA2E;AAC3E,kFAAiE;AACjE,gFAAwD;AACxD,8EAA6D;AAC7D,4FAAsE;
|
|
1
|
+
{"version":3,"file":"rollup.js","sourceRoot":"","sources":["rollup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,4EAAqD;AACrD,4FAA2E;AAC3E,kFAAiE;AACjE,gFAAwD;AACxD,8EAA6D;AAC7D,4FAAsE;AACtE,kFAAiE;AAGjE,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,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EAAE,IAAI;SAChB,CAAC;IACJ,CAAC;IAED,YAAY;QACV,OAAO,IAAA,mCAAY,GAAE,CAAC;IACxB,CAAC;IAED,YAAY,CAAC,IAAY,EAAE,IAA8C;QACvE,OAAO,IAAA,8BAAY,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;CACF;AAjFD,sBAiFC","sourcesContent":["import { default as hbs } from './rollup-hbs-plugin';\nimport { default as publicEntrypoints } from './rollup-public-entrypoints';\nimport { default as appReexports } from './rollup-app-reexports';\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 { default as publicAssets } 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: { mapFilename?: (fileName: string) => string } = {}\n ): Plugin {\n return appReexports({\n from: this.#srcDir,\n to: this.#destDir,\n include: patterns,\n mapFilename: opts.mapFilename,\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[]) {\n return publicEntrypoints({ srcDir: this.#srcDir, include: patterns });\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() {\n return hbs();\n }\n\n // By default rollup does not clear the output directory between builds. This\n // does that.\n clean() {\n return clean({ targets: `${this.#destDir}/*`, hook: 'generateBundle' });\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 format: 'es',\n entryFileNames: '[name]',\n hoistTransitiveImports: false,\n sourcemap: true,\n };\n }\n\n dependencies() {\n return dependencies();\n }\n\n publicAssets(path: string, opts: { include: string[]; exclude: string[] }) {\n return publicAssets(path, opts);\n }\n}\n"]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export declare type TemplateTransform = () => {
|
|
2
|
-
name: string;
|
|
3
|
-
visitor: {};
|
|
4
|
-
};
|
|
5
|
-
export declare type TemplateTransformPlugin = TemplateTransform | string;
|
|
6
|
-
export interface Options {
|
|
7
|
-
astTransforms?: TemplateTransformPlugin[];
|
|
8
|
-
compilerPath?: string;
|
|
9
|
-
}
|
|
10
|
-
declare const _default: {
|
|
11
|
-
(babel: typeof import("@babel/core")): unknown;
|
|
12
|
-
_parallelBabel: {
|
|
13
|
-
requireFile: string;
|
|
14
|
-
};
|
|
15
|
-
baseDir(): string;
|
|
16
|
-
};
|
|
17
|
-
export default _default;
|
|
@@ -1,30 +0,0 @@
|
|
|
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
|
-
const babel_plugin_stage1_inline_hbs_1 = __importDefault(require("@embroider/core/src/babel-plugin-stage1-inline-hbs"));
|
|
7
|
-
const core_1 = require("@embroider/core");
|
|
8
|
-
const load_ember_template_compiler_1 = require("@embroider/core/src/load-ember-template-compiler");
|
|
9
|
-
function resolvePlugins(plugins) {
|
|
10
|
-
return plugins.map((somePlugin) => {
|
|
11
|
-
// If it's a string attempt to resolve the path to a module.
|
|
12
|
-
return typeof somePlugin === 'string'
|
|
13
|
-
? require(somePlugin) // eslint-disable-line @typescript-eslint/no-require-imports
|
|
14
|
-
: somePlugin;
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
exports.default = (0, babel_plugin_stage1_inline_hbs_1.default)((options) => {
|
|
18
|
-
let { astTransforms: somePlugins = [], compilerPath = 'ember-source/dist/ember-template-compiler', } = options;
|
|
19
|
-
compilerPath = require.resolve(compilerPath);
|
|
20
|
-
const astTransforms = resolvePlugins(somePlugins);
|
|
21
|
-
const params = {
|
|
22
|
-
EmberENV: {},
|
|
23
|
-
loadEmberTemplateCompiler: () => (0, load_ember_template_compiler_1.getEmberExports)(compilerPath),
|
|
24
|
-
plugins: {
|
|
25
|
-
ast: astTransforms,
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
return new core_1.TemplateCompiler(params);
|
|
29
|
-
});
|
|
30
|
-
//# sourceMappingURL=template-transform-plugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"template-transform-plugin.js","sourceRoot":"","sources":["template-transform-plugin.ts"],"names":[],"mappings":";;;;;AAAA,wHAAsE;AACtE,0CAA2E;AAC3E,mGAAmF;AAWnF,SAAS,cAAc,CAAC,OAAkC;IACxD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,UAAmC,EAAE,EAAE;QACzD,4DAA4D;QAC5D,OAAO,OAAO,UAAU,KAAK,QAAQ;YACnC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,4DAA4D;YAClF,CAAC,CAAC,UAAU,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,kBAAe,IAAA,wCAAI,EAAC,CAAC,OAAgB,EAAE,EAAE;IACvC,IAAI,EACF,aAAa,EAAE,WAAW,GAAG,EAAE,EAC/B,YAAY,GAAG,2CAA2C,GAC3D,GAAG,OAAO,CAAC;IAEZ,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAE7C,MAAM,aAAa,GAAwB,cAAc,CAAC,WAAW,CAAC,CAAC;IAEvE,MAAM,MAAM,GAA2B;QACrC,QAAQ,EAAE,EAAE;QACZ,yBAAyB,EAAE,GAAG,EAAE,CAAC,IAAA,8CAAe,EAAC,YAAY,CAAC;QAC9D,OAAO,EAAE;YACP,GAAG,EAAE,aAAa;SACnB;KACF,CAAC;IAEF,OAAO,IAAI,uBAAgB,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC,CAAC,CAAC","sourcesContent":["import make from '@embroider/core/src/babel-plugin-stage1-inline-hbs';\nimport { TemplateCompiler, TemplateCompilerParams } from '@embroider/core';\nimport { getEmberExports } from '@embroider/core/src/load-ember-template-compiler';\n\nexport type TemplateTransform = () => { name: string; visitor: {} };\nexport type TemplateTransformPlugin = TemplateTransform | string;\nexport interface Options {\n // An array of either Glimmer AST plugins or paths that can be resolved to a plugin.\n astTransforms?: TemplateTransformPlugin[];\n // Defaults to 'ember-source/dist/ember-template-compiler'\n compilerPath?: string;\n}\n\nfunction resolvePlugins(plugins: TemplateTransformPlugin[]) {\n return plugins.map((somePlugin: TemplateTransformPlugin) => {\n // If it's a string attempt to resolve the path to a module.\n return typeof somePlugin === 'string'\n ? require(somePlugin) // eslint-disable-line @typescript-eslint/no-require-imports\n : somePlugin;\n });\n}\n\nexport default make((options: Options) => {\n let {\n astTransforms: somePlugins = [],\n compilerPath = 'ember-source/dist/ember-template-compiler',\n } = options;\n\n compilerPath = require.resolve(compilerPath);\n\n const astTransforms: TemplateTransform[] = resolvePlugins(somePlugins);\n\n const params: TemplateCompilerParams = {\n EmberENV: {},\n loadEmberTemplateCompiler: () => getEmberExports(compilerPath),\n plugins: {\n ast: astTransforms,\n },\n };\n\n return new TemplateCompiler(params);\n});\n"]}
|