@embroider/addon-dev 1.7.1 → 1.8.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.
- package/package.json +19 -3
- package/src/rollup-addon-dependencies.js +5 -5
- package/src/rollup-addon-dependencies.js.map +1 -1
- package/src/rollup-app-reexports.js +2 -1
- package/src/rollup-app-reexports.js.map +1 -1
- package/src/rollup-hbs-plugin.js +3 -2
- package/src/rollup-hbs-plugin.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.2",
|
|
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,8 +23,12 @@
|
|
|
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.2",
|
|
27
32
|
"@rollup/pluginutils": "^4.1.1",
|
|
28
33
|
"assert-never": "^1.2.1",
|
|
29
34
|
"fs-extra": "^10.0.0",
|
|
@@ -34,10 +39,21 @@
|
|
|
34
39
|
"yargs": "^17.0.1"
|
|
35
40
|
},
|
|
36
41
|
"devDependencies": {
|
|
42
|
+
"@embroider/test-support": "0.36.0",
|
|
43
|
+
"@glimmer/syntax": "^0.84.2",
|
|
37
44
|
"@types/fs-extra": "^9.0.12",
|
|
38
45
|
"@types/minimatch": "^3.0.4",
|
|
39
46
|
"@types/yargs": "^17.0.3",
|
|
40
|
-
"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
|
+
}
|
|
41
57
|
},
|
|
42
58
|
"engines": {
|
|
43
59
|
"node": "12.* || 14.* || >= 16"
|
|
@@ -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,6 +4,7 @@ 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 {
|
|
@@ -20,7 +21,7 @@ function appReexports(opts) {
|
|
|
20
21
|
this.emitFile({
|
|
21
22
|
type: 'asset',
|
|
22
23
|
fileName: `_app_/${appFilename}`,
|
|
23
|
-
source: `export { default } from "${pkg.name}/${addonFilename}";\n`,
|
|
24
|
+
source: `export { default } from "${pkg.name}/${addonFilename.slice(0, -(0, path_1.extname)(addonFilename).length)}";\n`,
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
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,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,I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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
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const pluginutils_1 = require("@rollup/pluginutils");
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
|
-
const
|
|
8
|
+
const core_1 = require("@embroider/core");
|
|
9
9
|
const assert_never_1 = __importDefault(require("assert-never"));
|
|
10
10
|
const path_1 = require("path");
|
|
11
11
|
function rollupHbsPlugin() {
|
|
@@ -30,8 +30,9 @@ function rollupHbsPlugin() {
|
|
|
30
30
|
}
|
|
31
31
|
switch (meta.type) {
|
|
32
32
|
case 'template':
|
|
33
|
+
this.addWatchFile(meta.originalId);
|
|
33
34
|
let input = (0, fs_1.readFileSync)(meta.originalId, 'utf8');
|
|
34
|
-
let code = (0,
|
|
35
|
+
let code = (0, core_1.hbsToJS)(input);
|
|
35
36
|
return {
|
|
36
37
|
code,
|
|
37
38
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup-hbs-plugin.js","sourceRoot":"","sources":["rollup-hbs-plugin.ts"],"names":[],"mappings":";;;;;AAAA,qDAAmD;AAOnD,2BAAkC;AAClC,
|
|
1
|
+
{"version":3,"file":"rollup-hbs-plugin.js","sourceRoot":"","sources":["rollup-hbs-plugin.ts"],"names":[],"mappings":";;;;;AAAA,qDAAmD;AAOnD,2BAAkC;AAClC,0CAA0C;AAC1C,gEAAuC;AACvC,+BAA0C;AAE1C,SAAwB,eAAe;IACrC,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,CAAC,UAAU,EAAE;gBACf,OAAO,0BAA0B,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;aACpE;iBAAM;gBACL,OAAO,eAAe,CAAC,UAAU,CAAC,CAAC;aACpC;QACH,CAAC;QAED,IAAI,CAAC,EAAU;YACb,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAC/B,IAAI,CAAC,IAAI,EAAE;gBACT,OAAO;aACR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,IAAI;QACd,GAAG,OAAO;KACX,CACF,CAAC;IACF,IAAI,CAAC,kBAAkB,EAAE;QACvB,OAAO,IAAI,CAAC;KACb;IACD,qEAAqE;IACrE,0DAA0D;IAC1D,OAAO;QACL,EAAE,EAAE,kBAAkB,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC;QAClD,IAAI,EAAE;YACJ,mBAAmB,EAAE;gBACnB,IAAI,EAAE,4BAA4B;aACnC;SACF;KACF,CAAC;AACJ,CAAC;AAED,MAAM,SAAS,GAAG,IAAA,0BAAY,EAAC,UAAU,CAAC,CAAC;AAE3C,SAAS,eAAe,CAAC,UAAsB;IAC7C,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE;QAC7B,OAAO,IAAI,CAAC;KACb;IAED,qEAAqE;IACrE,OAAO;QACL,GAAG,UAAU;QACb,EAAE,EAAE,UAAU,CAAC,EAAE,GAAG,KAAK;QACzB,IAAI,EAAE;YACJ,mBAAmB,EAAE;gBACnB,IAAI,EAAE,UAAU;gBAChB,UAAU,EAAE,UAAU,CAAC,EAAE;aAC1B;SACF;KACF,CAAC;AACJ,CAAC","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 this.addWatchFile(meta.originalId);\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"]}
|
|
@@ -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"]}
|