@embroider/addon-dev 1.6.0 → 1.8.0
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 +20 -3
- package/src/commands.js +0 -0
- package/src/rollup-addon-dependencies.js +5 -5
- package/src/rollup-addon-dependencies.js.map +1 -1
- package/src/rollup-app-reexports.d.ts +1 -0
- package/src/rollup-app-reexports.js +9 -6
- package/src/rollup-app-reexports.js.map +1 -1
- package/src/rollup-hbs-plugin.js +84 -21
- package/src/rollup-hbs-plugin.js.map +1 -1
- package/src/rollup-keep-assets.js +4 -1
- package/src/rollup-keep-assets.js.map +1 -1
- package/src/rollup-public-entrypoints.js +33 -10
- package/src/rollup-public-entrypoints.js.map +1 -1
- package/src/rollup.d.ts +3 -1
- package/src/rollup.js +2 -1
- package/src/rollup.js.map +1 -1
- package/src/template-colocation-plugin.d.ts +3 -1
- package/src/template-colocation-plugin.js +2 -6
- package/src/template-colocation-plugin.js.map +1 -1
- package/src/template-transform-plugin.d.ts +17 -0
- package/src/template-transform-plugin.js +30 -0
- package/src/template-transform-plugin.js.map +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embroider/addon-dev",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Utilities for addon authors",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"exports": {
|
|
16
16
|
"./template-colocation-plugin": "./src/template-colocation-plugin.js",
|
|
17
|
+
"./template-transform-plugin": "./src/template-transform-plugin.js",
|
|
17
18
|
"./rollup": "./src/rollup.js"
|
|
18
19
|
},
|
|
19
20
|
"files": [
|
|
@@ -22,9 +23,14 @@
|
|
|
22
23
|
"src/**/*.d.ts",
|
|
23
24
|
"src/**/*.js.map"
|
|
24
25
|
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"prepare": "tsc",
|
|
28
|
+
"test": "jest"
|
|
29
|
+
},
|
|
25
30
|
"dependencies": {
|
|
26
|
-
"@embroider/
|
|
31
|
+
"@embroider/core": "^1.8.0",
|
|
27
32
|
"@rollup/pluginutils": "^4.1.1",
|
|
33
|
+
"assert-never": "^1.2.1",
|
|
28
34
|
"fs-extra": "^10.0.0",
|
|
29
35
|
"minimatch": "^3.0.4",
|
|
30
36
|
"rollup-plugin-copy-assets": "^2.0.3",
|
|
@@ -33,10 +39,21 @@
|
|
|
33
39
|
"yargs": "^17.0.1"
|
|
34
40
|
},
|
|
35
41
|
"devDependencies": {
|
|
42
|
+
"@embroider/test-support": "0.36.0",
|
|
43
|
+
"@glimmer/syntax": "^0.84.2",
|
|
36
44
|
"@types/fs-extra": "^9.0.12",
|
|
37
45
|
"@types/minimatch": "^3.0.4",
|
|
38
46
|
"@types/yargs": "^17.0.3",
|
|
39
|
-
"rollup": "^2.58.0"
|
|
47
|
+
"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
|
+
}
|
|
40
57
|
},
|
|
41
58
|
"engines": {
|
|
42
59
|
"node": "12.* || 14.* || >= 16"
|
package/src/commands.js
CHANGED
|
File without changes
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const fs_extra_1 = require("fs-extra");
|
|
4
|
-
const
|
|
5
|
-
const compilationModules = new Set(
|
|
4
|
+
const core_1 = require("@embroider/core");
|
|
5
|
+
const compilationModules = new Set(core_1.templateCompilationModules.map((m) => m.module));
|
|
6
6
|
function resolvableDependencies() {
|
|
7
7
|
let deps = new Set();
|
|
8
8
|
let pkg = (0, fs_extra_1.readJsonSync)('package.json');
|
|
@@ -23,15 +23,15 @@ function emberExternals() {
|
|
|
23
23
|
return {
|
|
24
24
|
name: 'ember-externals',
|
|
25
25
|
async resolveId(source) {
|
|
26
|
-
let pkgName = (0,
|
|
26
|
+
let pkgName = (0, core_1.packageName)(source);
|
|
27
27
|
if (!pkgName) {
|
|
28
28
|
// No package name found means this is a relative import, which we don't
|
|
29
29
|
// need to deal with.
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
if (deps.has(pkgName) ||
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
core_1.emberVirtualPeerDeps.has(pkgName) ||
|
|
34
|
+
core_1.emberVirtualPackages.has(pkgName) ||
|
|
35
35
|
compilationModules.has(pkgName)) {
|
|
36
36
|
return { id: source, external: true };
|
|
37
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup-addon-dependencies.js","sourceRoot":"","sources":["rollup-addon-dependencies.ts"],"names":[],"mappings":";;AACA,uCAAwC;AACxC,
|
|
1
|
+
{"version":3,"file":"rollup-addon-dependencies.js","sourceRoot":"","sources":["rollup-addon-dependencies.ts"],"names":[],"mappings":";;AACA,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,EAAE,CAAC;IACrB,IAAI,GAAG,GAAG,IAAA,uBAAY,EAAC,cAAc,CAAC,CAAC;IACvC,IAAI,GAAG,CAAC,YAAY,EAAE;QACpB,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE;YAC9C,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;SAChB;KACF;IACD,IAAI,GAAG,CAAC,gBAAgB,EAAE;QACxB,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE;YAClD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;SAChB;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAwB,cAAc;IACpC,IAAI,IAAI,GAAG,sBAAsB,EAAE,CAAC;IAEpC,OAAO;QACL,IAAI,EAAE,iBAAiB;QAEvB,KAAK,CAAC,SAAS,CAAC,MAAM;YACpB,IAAI,OAAO,GAAG,IAAA,kBAAW,EAAC,MAAM,CAAC,CAAC;YAClC,IAAI,CAAC,OAAO,EAAE;gBACZ,wEAAwE;gBACxE,qBAAqB;gBACrB,OAAO;aACR;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;gBACA,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;aACvC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAxBD,iCAwBC","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() {\n let deps = new Set();\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 = resolvableDependencies();\n\n return {\n name: 'ember-externals',\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"]}
|
|
@@ -4,21 +4,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const fs_extra_1 = require("fs-extra");
|
|
7
|
+
const path_1 = require("path");
|
|
7
8
|
const minimatch_1 = __importDefault(require("minimatch"));
|
|
8
9
|
function appReexports(opts) {
|
|
9
10
|
return {
|
|
10
11
|
name: 'app-reexports',
|
|
11
12
|
generateBundle(_, bundle) {
|
|
13
|
+
var _a, _b;
|
|
12
14
|
let pkg = (0, fs_extra_1.readJsonSync)('package.json');
|
|
13
15
|
let appJS = {};
|
|
14
|
-
for (let
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
for (let addonFilename of Object.keys(bundle)) {
|
|
17
|
+
let appFilename = (_b = (_a = opts.mapFilename) === null || _a === void 0 ? void 0 : _a.call(opts, addonFilename)) !== null && _b !== void 0 ? _b : addonFilename;
|
|
18
|
+
if (opts.include.some((glob) => (0, minimatch_1.default)(addonFilename, glob)) &&
|
|
19
|
+
!(0, minimatch_1.default)(addonFilename, '**/*.d.ts')) {
|
|
20
|
+
appJS[`./${appFilename}`] = `./dist/_app_/${appFilename}`;
|
|
18
21
|
this.emitFile({
|
|
19
22
|
type: 'asset',
|
|
20
|
-
fileName: `_app_/${
|
|
21
|
-
source: `export { default } from "${pkg.name}/${
|
|
23
|
+
fileName: `_app_/${appFilename}`,
|
|
24
|
+
source: `export { default } from "${pkg.name}/${addonFilename.slice(0, -(0, path_1.extname)(addonFilename).length)}";\n`,
|
|
22
25
|
});
|
|
23
26
|
}
|
|
24
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup-app-reexports.js","sourceRoot":"","sources":["rollup-app-reexports.ts"],"names":[],"mappings":";;;;;AAAA,uCAAuD;AACvD,0DAAkC;AAGlC,SAAwB,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"rollup-app-reexports.js","sourceRoot":"","sources":["rollup-app-reexports.ts"],"names":[],"mappings":";;;;;AAAA,uCAAuD;AACvD,+BAA+B;AAC/B,0DAAkC;AAGlC,SAAwB,YAAY,CAAC,IAKpC;IACC,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,cAAc,CAAC,CAAC,EAAE,MAAM;;YACtB,IAAI,GAAG,GAAG,IAAA,uBAAY,EAAC,cAAc,CAAC,CAAC;YACvC,IAAI,KAAK,GAA2B,EAAE,CAAC;YACvC,KAAK,IAAI,aAAa,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;gBAC7C,IAAI,WAAW,GAAG,MAAA,MAAA,IAAI,CAAC,WAAW,+CAAhB,IAAI,EAAe,aAAa,CAAC,mCAAI,aAAa,CAAC;gBAErE,IACE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,mBAAS,EAAC,aAAa,EAAE,IAAI,CAAC,CAAC;oBAC3D,CAAC,IAAA,mBAAS,EAAC,aAAa,EAAE,WAAW,CAAC,EACtC;oBACA,KAAK,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,4BAA4B,GAAG,CAAC,IAAI,IAAI,aAAa,CAAC,KAAK,CACjE,CAAC,EACD,CAAC,IAAA,cAAO,EAAC,aAAa,CAAC,CAAC,MAAM,CAC/B,MAAM;qBACR,CAAC,CAAC;iBACJ;aACF;YACD,GAAG,CAAC,aAAa,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,aAAa,CAAC,EAAE;gBACzD,QAAQ,EAAE,KAAK;aAChB,CAAC,CAAC;YACH,IAAA,wBAAa,EAAC,cAAc,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;QACpD,CAAC;KACF,CAAC;AACJ,CAAC;AAnCD,+BAmCC","sourcesContent":["import { readJsonSync, writeJsonSync } from 'fs-extra';\nimport { extname } from 'path';\nimport minimatch from 'minimatch';\nimport type { Plugin } from 'rollup';\n\nexport default function appReexports(opts: {\n from: string;\n to: string;\n include: string[];\n mapFilename?: (filename: string) => string;\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\n if (\n opts.include.some((glob) => minimatch(addonFilename, glob)) &&\n !minimatch(addonFilename, '**/*.d.ts')\n ) {\n appJS[`./${appFilename}`] = `./dist/_app_/${appFilename}`;\n this.emitFile({\n type: 'asset',\n fileName: `_app_/${appFilename}`,\n source: `export { default } from \"${pkg.name}/${addonFilename.slice(\n 0,\n -extname(addonFilename).length\n )}\";\\n`,\n });\n }\n }\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"]}
|
package/src/rollup-hbs-plugin.js
CHANGED
|
@@ -1,38 +1,101 @@
|
|
|
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
|
-
const
|
|
8
|
+
const core_1 = require("@embroider/core");
|
|
9
|
+
const assert_never_1 = __importDefault(require("assert-never"));
|
|
10
|
+
const path_1 = require("path");
|
|
6
11
|
function rollupHbsPlugin() {
|
|
7
|
-
const filter = (0, pluginutils_1.createFilter)('**/*.hbs');
|
|
8
12
|
return {
|
|
9
13
|
name: 'rollup-hbs-plugin',
|
|
10
14
|
async resolveId(source, importer, options) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
let resolution = await this.resolve(source, importer, {
|
|
16
|
+
skipSelf: true,
|
|
17
|
+
...options,
|
|
18
|
+
});
|
|
19
|
+
if (!resolution) {
|
|
20
|
+
return maybeSynthesizeComponentJS(this, source, importer, options);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return maybeRewriteHBS(resolution);
|
|
24
|
+
}
|
|
21
25
|
},
|
|
22
26
|
load(id) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const originalId = (_b = meta === null || meta === void 0 ? void 0 : meta['rollup-hbs-plugin']) === null || _b === void 0 ? void 0 : _b.originalId;
|
|
26
|
-
if (!originalId) {
|
|
27
|
+
const meta = getMeta(this, id);
|
|
28
|
+
if (!meta) {
|
|
27
29
|
return;
|
|
28
30
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
switch (meta.type) {
|
|
32
|
+
case 'template':
|
|
33
|
+
let input = (0, fs_1.readFileSync)(meta.originalId, 'utf8');
|
|
34
|
+
let code = (0, core_1.hbsToJS)(input);
|
|
35
|
+
return {
|
|
36
|
+
code,
|
|
37
|
+
};
|
|
38
|
+
case 'template-only-component-js':
|
|
39
|
+
return {
|
|
40
|
+
code: templateOnlyComponent,
|
|
41
|
+
};
|
|
42
|
+
default:
|
|
43
|
+
(0, assert_never_1.default)(meta);
|
|
44
|
+
}
|
|
34
45
|
},
|
|
35
46
|
};
|
|
36
47
|
}
|
|
37
48
|
exports.default = rollupHbsPlugin;
|
|
49
|
+
const templateOnlyComponent = `import templateOnly from '@ember/component/template-only';\n` +
|
|
50
|
+
`export default templateOnly();\n`;
|
|
51
|
+
function getMeta(context, id) {
|
|
52
|
+
var _a, _b;
|
|
53
|
+
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'];
|
|
54
|
+
if (meta) {
|
|
55
|
+
return meta;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function correspondingTemplate(filename) {
|
|
62
|
+
let { ext } = (0, path_1.parse)(filename);
|
|
63
|
+
return filename.slice(0, filename.length - ext.length) + '.hbs';
|
|
64
|
+
}
|
|
65
|
+
async function maybeSynthesizeComponentJS(context, source, importer, options) {
|
|
66
|
+
let templateResolution = await context.resolve(correspondingTemplate(source), importer, {
|
|
67
|
+
skipSelf: true,
|
|
68
|
+
...options,
|
|
69
|
+
});
|
|
70
|
+
if (!templateResolution) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
// we're trying to resolve a JS module but only the corresponding HBS
|
|
74
|
+
// file exists. Synthesize the template-only component JS.
|
|
75
|
+
return {
|
|
76
|
+
id: templateResolution.id.replace(/\.hbs$/, '.js'),
|
|
77
|
+
meta: {
|
|
78
|
+
'rollup-hbs-plugin': {
|
|
79
|
+
type: 'template-only-component-js',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
const hbsFilter = (0, pluginutils_1.createFilter)('**/*.hbs');
|
|
85
|
+
function maybeRewriteHBS(resolution) {
|
|
86
|
+
if (!hbsFilter(resolution.id)) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
// This creates an `*.hbs.js` that we will populate in `load()` hook.
|
|
90
|
+
return {
|
|
91
|
+
...resolution,
|
|
92
|
+
id: resolution.id + '.js',
|
|
93
|
+
meta: {
|
|
94
|
+
'rollup-hbs-plugin': {
|
|
95
|
+
type: 'template',
|
|
96
|
+
originalId: resolution.id,
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
38
101
|
//# sourceMappingURL=rollup-hbs-plugin.js.map
|
|
@@ -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":"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","sourcesContent":["import { createFilter } from '@rollup/pluginutils';\nimport type {\n Plugin,\n PluginContext,\n CustomPluginOptions,\n ResolvedId,\n} from 'rollup';\nimport { readFileSync } from 'fs';\nimport { hbsToJS } from '@embroider/core';\nimport assertNever from 'assert-never';\nimport { parse as pathParse } from 'path';\n\nexport default function rollupHbsPlugin(): 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 maybeSynthesizeComponentJS(this, source, importer, options);\n } else {\n return maybeRewriteHBS(resolution);\n }\n },\n\n load(id: string) {\n const meta = getMeta(this, id);\n if (!meta) {\n return;\n }\n\n switch (meta.type) {\n case 'template':\n let input = readFileSync(meta.originalId, 'utf8');\n let code = hbsToJS(input);\n return {\n code,\n };\n case 'template-only-component-js':\n return {\n code: templateOnlyComponent,\n };\n default:\n assertNever(meta);\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 | {\n type: 'template';\n originalId: string;\n }\n | {\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\nfunction correspondingTemplate(filename: string): string {\n let { ext } = pathParse(filename);\n return filename.slice(0, filename.length - ext.length) + '.hbs';\n}\n\nasync function maybeSynthesizeComponentJS(\n context: PluginContext,\n source: string,\n importer: string | undefined,\n options: { custom?: CustomPluginOptions; isEntry: boolean }\n) {\n let templateResolution = await context.resolve(\n correspondingTemplate(source),\n importer,\n {\n skipSelf: true,\n ...options,\n }\n );\n if (!templateResolution) {\n return null;\n }\n // we're trying to resolve a JS module but only the corresponding HBS\n // file exists. Synthesize the template-only component JS.\n return {\n id: templateResolution.id.replace(/\\.hbs$/, '.js'),\n meta: {\n 'rollup-hbs-plugin': {\n type: 'template-only-component-js',\n },\n },\n };\n}\n\nconst hbsFilter = createFilter('**/*.hbs');\n\nfunction maybeRewriteHBS(resolution: ResolvedId) {\n if (!hbsFilter(resolution.id)) {\n return null;\n }\n\n // This creates an `*.hbs.js` that we will populate in `load()` hook.\n return {\n ...resolution,\n id: resolution.id + '.js',\n meta: {\n 'rollup-hbs-plugin': {\n type: 'template',\n originalId: resolution.id,\n },\n },\n };\n}\n"]}
|
|
@@ -13,7 +13,10 @@ function keepAssets({ from, include, }) {
|
|
|
13
13
|
// imports of assets should be left alone in the source code. This can cover
|
|
14
14
|
// the case of .css as defined in the embroider v2 addon spec.
|
|
15
15
|
async resolveId(source, importer, options) {
|
|
16
|
-
const resolution = await this.resolve(source, importer,
|
|
16
|
+
const resolution = await this.resolve(source, importer, {
|
|
17
|
+
skipSelf: true,
|
|
18
|
+
...options,
|
|
19
|
+
});
|
|
17
20
|
if (resolution &&
|
|
18
21
|
include.some((pattern) => (0, minimatch_1.default)(resolution.id, pattern))) {
|
|
19
22
|
return { id: source, external: true };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup-keep-assets.js","sourceRoot":"","sources":["rollup-keep-assets.ts"],"names":[],"mappings":";;;;;AAAA,0DAAiC;AAEjC,2BAAkC;AAClC,+BAA4B;AAC5B,0DAAkC;AAElC,SAAwB,UAAU,CAAC,EACjC,IAAI,EACJ,OAAO,GAIR;IACC,OAAO;QACL,IAAI,EAAE,aAAa;QAEnB,4EAA4E;QAC5E,8DAA8D;QAC9D,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO;YACvC,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"rollup-keep-assets.js","sourceRoot":"","sources":["rollup-keep-assets.ts"],"names":[],"mappings":";;;;;AAAA,0DAAiC;AAEjC,2BAAkC;AAClC,+BAA4B;AAC5B,0DAAkC;AAElC,SAAwB,UAAU,CAAC,EACjC,IAAI,EACJ,OAAO,GAIR;IACC,OAAO;QACL,IAAI,EAAE,aAAa;QAEnB,4EAA4E;QAC5E,8DAA8D;QAC9D,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO;YACvC,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE;gBACtD,QAAQ,EAAE,IAAI;gBACd,GAAG,OAAO;aACX,CAAC,CAAC;YACH,IACE,UAAU;gBACV,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAA,mBAAS,EAAC,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,EAC5D;gBACA,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;aACvC;YACD,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,4EAA4E;QAC5E,yBAAyB;QACzB,KAAK,CAAC,cAAc;YAClB,KAAK,IAAI,IAAI,IAAI,IAAA,mBAAQ,EAAC,IAAI,EAAE;gBAC9B,KAAK,EAAE,OAAO;gBACd,WAAW,EAAE,KAAK;aACnB,CAAC,EAAE;gBACF,IAAI,CAAC,QAAQ,CAAC;oBACZ,IAAI,EAAE,OAAO;oBACb,QAAQ,EAAE,IAAI;oBACd,MAAM,EAAE,IAAA,iBAAY,EAAC,IAAA,WAAI,EAAC,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC;iBAC/C,CAAC,CAAC;aACJ;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAzCD,6BAyCC","sourcesContent":["import walkSync from 'walk-sync';\nimport type { Plugin } from 'rollup';\nimport { readFileSync } from 'fs';\nimport { join } from 'path';\nimport minimatch from 'minimatch';\n\nexport default function keepAssets({\n from,\n include,\n}: {\n from: string;\n include: string[];\n}): Plugin {\n return {\n name: 'copy-assets',\n\n // imports of assets should be left alone in the source code. This can cover\n // the case of .css as defined in the embroider v2 addon spec.\n async resolveId(source, importer, options) {\n const resolution = await this.resolve(source, importer, {\n skipSelf: true,\n ...options,\n });\n if (\n resolution &&\n include.some((pattern) => minimatch(resolution.id, pattern))\n ) {\n return { id: source, external: true };\n }\n return resolution;\n },\n\n // the assets go into the output directory in the same relative locations as\n // in the input directory\n async generateBundle() {\n for (let name of walkSync(from, {\n globs: include,\n directories: false,\n })) {\n this.emitFile({\n type: 'asset',\n fileName: name,\n source: readFileSync(join(from, name), 'utf8'),\n });\n }\n },\n };\n}\n"]}
|
|
@@ -5,21 +5,44 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const walk_sync_1 = __importDefault(require("walk-sync"));
|
|
7
7
|
const path_1 = require("path");
|
|
8
|
+
const minimatch_1 = __importDefault(require("minimatch"));
|
|
9
|
+
const fs_extra_1 = require("fs-extra");
|
|
8
10
|
function normalizeFileExt(fileName) {
|
|
9
|
-
return fileName.replace(/\.ts|\.gts|\.gjs$/, '.js');
|
|
11
|
+
return fileName.replace(/\.ts|\.hbs|\.gts|\.gjs$/, '.js');
|
|
10
12
|
}
|
|
13
|
+
const hbsPattern = '**/*.hbs';
|
|
11
14
|
function publicEntrypoints(args) {
|
|
12
15
|
return {
|
|
13
16
|
name: 'addon-modules',
|
|
14
|
-
buildStart() {
|
|
15
|
-
|
|
16
|
-
globs: args.include,
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
async buildStart() {
|
|
18
|
+
let matches = (0, walk_sync_1.default)(args.srcDir, {
|
|
19
|
+
globs: [...args.include, hbsPattern],
|
|
20
|
+
});
|
|
21
|
+
for (let name of matches) {
|
|
22
|
+
if (args.include.some((pattern) => (0, minimatch_1.default)(name, pattern))) {
|
|
23
|
+
// anything that matches one of the user's patterns is definitely emitted
|
|
24
|
+
this.emitFile({
|
|
25
|
+
type: 'chunk',
|
|
26
|
+
id: (0, path_1.join)(args.srcDir, name),
|
|
27
|
+
fileName: normalizeFileExt(name),
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
// this file didn't match one of the user's patterns, so it must match
|
|
32
|
+
// our hbsPattern. Infer the possible existence of a synthesized
|
|
33
|
+
// template-only component JS file and test whether that file would
|
|
34
|
+
// match the user's patterns.
|
|
35
|
+
let normalizedName = normalizeFileExt(name);
|
|
36
|
+
let id = (0, path_1.join)(args.srcDir, normalizedName);
|
|
37
|
+
if (args.include.some((pattern) => (0, minimatch_1.default)(normalizedName, pattern)) &&
|
|
38
|
+
!(0, fs_extra_1.pathExistsSync)(id)) {
|
|
39
|
+
this.emitFile({
|
|
40
|
+
type: 'chunk',
|
|
41
|
+
id,
|
|
42
|
+
fileName: normalizedName,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
23
46
|
}
|
|
24
47
|
},
|
|
25
48
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup-public-entrypoints.js","sourceRoot":"","sources":["rollup-public-entrypoints.ts"],"names":[],"mappings":";;;;;AAAA,0DAAiC;
|
|
1
|
+
{"version":3,"file":"rollup-public-entrypoints.js","sourceRoot":"","sources":["rollup-public-entrypoints.ts"],"names":[],"mappings":";;;;;AAAA,0DAAiC;AACjC,+BAA4B;AAC5B,0DAAkC;AAGlC,uCAA0C;AAE1C,SAAS,gBAAgB,CAAC,QAAgB;IACxC,OAAO,QAAQ,CAAC,OAAO,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,GAAG,UAAU,CAAC;AAE9B,SAAwB,iBAAiB,CAAC,IAGzC;IACC,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,KAAK,CAAC,UAAU;YACd,IAAI,OAAO,GAAG,IAAA,mBAAQ,EAAC,IAAI,CAAC,MAAM,EAAE;gBAClC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC;aACrC,CAAC,CAAC;YAEH,KAAK,IAAI,IAAI,IAAI,OAAO,EAAE;gBACxB,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAA,mBAAS,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC,EAAE;oBAC5D,yEAAyE;oBACzE,IAAI,CAAC,QAAQ,CAAC;wBACZ,IAAI,EAAE,OAAO;wBACb,EAAE,EAAE,IAAA,WAAI,EAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC;wBAC3B,QAAQ,EAAE,gBAAgB,CAAC,IAAI,CAAC;qBACjC,CAAC,CAAC;iBACJ;qBAAM;oBACL,sEAAsE;oBACtE,gEAAgE;oBAChE,mEAAmE;oBACnE,6BAA6B;oBAC7B,IAAI,cAAc,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;oBAC5C,IAAI,EAAE,GAAG,IAAA,WAAI,EAAC,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;oBAC3C,IACE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAC5B,IAAA,mBAAS,EAAC,cAAc,EAAE,OAAO,CAAC,CACnC;wBACD,CAAC,IAAA,yBAAc,EAAC,EAAE,CAAC,EACnB;wBACA,IAAI,CAAC,QAAQ,CAAC;4BACZ,IAAI,EAAE,OAAO;4BACb,EAAE;4BACF,QAAQ,EAAE,cAAc;yBACzB,CAAC,CAAC;qBACJ;iBACF;aACF;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AA1CD,oCA0CC","sourcesContent":["import walkSync from 'walk-sync';\nimport { join } from 'path';\nimport minimatch from 'minimatch';\n\nimport type { Plugin } from 'rollup';\nimport { pathExistsSync } from 'fs-extra';\n\nfunction normalizeFileExt(fileName: string) {\n return fileName.replace(/\\.ts|\\.hbs|\\.gts|\\.gjs$/, '.js');\n}\n\nconst hbsPattern = '**/*.hbs';\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, hbsPattern],\n });\n\n for (let name of matches) {\n if (args.include.some((pattern) => minimatch(name, pattern))) {\n // anything that matches one of the user's patterns is definitely emitted\n this.emitFile({\n type: 'chunk',\n id: join(args.srcDir, name),\n fileName: normalizeFileExt(name),\n });\n } else {\n // this file didn't match one of the user's patterns, so it must match\n // our hbsPattern. Infer the possible existence of a synthesized\n // template-only component JS file and test whether that file would\n // match the user's patterns.\n let normalizedName = normalizeFileExt(name);\n let id = join(args.srcDir, normalizedName);\n if (\n args.include.some((pattern) =>\n minimatch(normalizedName, pattern)\n ) &&\n !pathExistsSync(id)\n ) {\n this.emitFile({\n type: 'chunk',\n id,\n fileName: normalizedName,\n });\n }\n }\n }\n },\n };\n}\n"]}
|
package/src/rollup.d.ts
CHANGED
|
@@ -5,7 +5,9 @@ export declare class Addon {
|
|
|
5
5
|
srcDir?: string;
|
|
6
6
|
destDir?: string;
|
|
7
7
|
});
|
|
8
|
-
appReexports(patterns: string[]
|
|
8
|
+
appReexports(patterns: string[], opts?: {
|
|
9
|
+
mapFilename?: (fileName: string) => string;
|
|
10
|
+
}): Plugin;
|
|
9
11
|
publicEntrypoints(patterns: string[]): Plugin;
|
|
10
12
|
hbs(): Plugin;
|
|
11
13
|
clean(): Plugin;
|
package/src/rollup.js
CHANGED
|
@@ -33,11 +33,12 @@ class Addon {
|
|
|
33
33
|
// Given a list of globs describing modules in your srcDir, this generates
|
|
34
34
|
// corresponding appTree modules that contain reexports, and updates your
|
|
35
35
|
// package.json metadata to list them all.
|
|
36
|
-
appReexports(patterns) {
|
|
36
|
+
appReexports(patterns, opts = {}) {
|
|
37
37
|
return (0, rollup_app_reexports_1.default)({
|
|
38
38
|
from: __classPrivateFieldGet(this, _Addon_srcDir, "f"),
|
|
39
39
|
to: __classPrivateFieldGet(this, _Addon_destDir, "f"),
|
|
40
40
|
include: patterns,
|
|
41
|
+
mapFilename: opts.mapFilename,
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
44
|
// This configures rollup to emit public entrypoints for each module in your
|
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;AAGtE,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,
|
|
1
|
+
{"version":3,"file":"rollup.js","sourceRoot":"","sources":["rollup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,4EAAqD;AACrD,4FAA2E;AAC3E,kFAAiE;AACjE,gFAAwD;AACxD,8EAA6D;AAC7D,4FAAsE;AAGtE,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,OAAuD,EAAE;QAEzD,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;SAC9B,CAAC,CAAC;IACL,CAAC;IAED,4EAA4E;IAC5E,0EAA0E;IAC1E,+EAA+E;IAC/E,iBAAiB,CAAC,QAAkB;QAClC,OAAO,IAAA,mCAAiB,EAAC,EAAE,MAAM,EAAE,uBAAA,IAAI,qBAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,oEAAoE;IACpE,sEAAsE;IACtE,8DAA8D;IAC9D,GAAG;QACD,OAAO,IAAA,2BAAG,GAAE,CAAC;IACf,CAAC;IAED,6EAA6E;IAC7E,aAAa;IACb,KAAK;QACH,OAAO,IAAA,8BAAK,EAAC,EAAE,OAAO,EAAE,GAAG,uBAAA,IAAI,sBAAS,IAAI,EAAE,CAAC,CAAC;IAClD,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,MAAM;QACJ,OAAO,EAAE,GAAG,EAAE,uBAAA,IAAI,sBAAS,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC;IACxE,CAAC;IAED,YAAY;QACV,OAAO,IAAA,mCAAY,GAAE,CAAC;IACxB,CAAC;CACF;AAlED,sBAkEC","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 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}/*` });\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 output() {\n return { dir: this.#destDir, format: 'es', entryFileNames: '[name]' };\n }\n\n dependencies() {\n return dependencies();\n }\n}\n"]}
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import { templateColocationPlugin, Options as TemplateColocationPluginOptions } from '@embroider/core';
|
|
2
|
+
export { TemplateColocationPluginOptions as Options };
|
|
3
|
+
export default templateColocationPlugin;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(template_colocation_plugin_1).default; } });
|
|
3
|
+
const core_1 = require("@embroider/core");
|
|
4
|
+
exports.default = core_1.templateColocationPlugin;
|
|
9
5
|
//# sourceMappingURL=template-colocation-plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-colocation-plugin.js","sourceRoot":"","sources":["template-colocation-plugin.ts"],"names":[],"mappings":"
|
|
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"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
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;
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"]}
|