@embroider/compat 3.2.3 → 3.2.4-unstable.157dd62
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embroider/compat",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.4-unstable.157dd62",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Backward compatibility layer for the Embroider build system.",
|
|
6
6
|
"repository": {
|
|
@@ -19,6 +19,9 @@
|
|
|
19
19
|
"bin": {
|
|
20
20
|
"embroider-compat-audit": "./src/audit-cli.js"
|
|
21
21
|
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"test": "jest"
|
|
24
|
+
},
|
|
22
25
|
"dependencies": {
|
|
23
26
|
"@babel/code-frame": "^7.14.5",
|
|
24
27
|
"@babel/core": "^7.14.5",
|
|
@@ -27,6 +30,7 @@
|
|
|
27
30
|
"@babel/preset-env": "^7.14.5",
|
|
28
31
|
"@babel/runtime": "^7.18.6",
|
|
29
32
|
"@babel/traverse": "^7.14.5",
|
|
33
|
+
"@embroider/macros": "1.13.3-unstable.157dd62",
|
|
30
34
|
"@types/babel__code-frame": "^7.0.2",
|
|
31
35
|
"@types/yargs": "^17.0.3",
|
|
32
36
|
"assert-never": "^1.1.0",
|
|
@@ -59,10 +63,12 @@
|
|
|
59
63
|
"tree-sync": "^2.1.0",
|
|
60
64
|
"typescript-memoize": "^1.0.1",
|
|
61
65
|
"walk-sync": "^3.0.0",
|
|
62
|
-
"yargs": "^17.0.1"
|
|
63
|
-
"@embroider/macros": "1.13.2"
|
|
66
|
+
"yargs": "^17.0.1"
|
|
64
67
|
},
|
|
65
68
|
"devDependencies": {
|
|
69
|
+
"@embroider/core": "3.3.1-unstable.157dd62",
|
|
70
|
+
"@embroider/sample-transforms": "workspace:*",
|
|
71
|
+
"@embroider/test-support": "workspace:*",
|
|
66
72
|
"@glimmer/syntax": "^0.84.3",
|
|
67
73
|
"@glint/template": "^1.0.0",
|
|
68
74
|
"@types/babel__core": "^7.1.14",
|
|
@@ -82,21 +88,15 @@
|
|
|
82
88
|
"code-equality-assertions": "^0.9.0",
|
|
83
89
|
"ember-engines": "^0.8.19",
|
|
84
90
|
"scenario-tester": "^2.1.2",
|
|
85
|
-
"typescript": "^5.1.6"
|
|
86
|
-
"@embroider/core": "^3.3.0",
|
|
87
|
-
"@embroider/sample-transforms": "0.0.0",
|
|
88
|
-
"@embroider/test-support": "0.36.0"
|
|
91
|
+
"typescript": "^5.1.6"
|
|
89
92
|
},
|
|
90
93
|
"peerDependencies": {
|
|
91
|
-
"@embroider/core": "
|
|
94
|
+
"@embroider/core": "3.3.1-unstable.157dd62"
|
|
92
95
|
},
|
|
93
96
|
"engines": {
|
|
94
97
|
"node": "12.* || 14.* || >= 16"
|
|
95
98
|
},
|
|
96
99
|
"volta": {
|
|
97
100
|
"extends": "../../package.json"
|
|
98
|
-
},
|
|
99
|
-
"scripts": {
|
|
100
|
-
"test": "jest"
|
|
101
101
|
}
|
|
102
|
-
}
|
|
102
|
+
}
|
|
@@ -9,7 +9,8 @@ export default class SynthesizeTemplateOnlyComponents extends Plugin {
|
|
|
9
9
|
templateExtensions: string[];
|
|
10
10
|
});
|
|
11
11
|
build(): Promise<void>;
|
|
12
|
-
private
|
|
12
|
+
private addTemplateOnlyComponent;
|
|
13
|
+
private addTemplateImport;
|
|
13
14
|
private remove;
|
|
14
15
|
private crawl;
|
|
15
16
|
}
|
|
@@ -10,6 +10,9 @@ const fs_extra_1 = require("fs-extra");
|
|
|
10
10
|
const source = `import templateOnlyComponent from '@ember/component/template-only';
|
|
11
11
|
export default templateOnlyComponent();`;
|
|
12
12
|
const jsExtensions = ['.js', '.ts', '.mjs', '.mts'];
|
|
13
|
+
function importTemplate(files) {
|
|
14
|
+
return `/* import __COLOCATED_TEMPLATE__ from './${(0, path_1.basename)(files.template.relativePath)}'; */\n`;
|
|
15
|
+
}
|
|
13
16
|
class SynthesizeTemplateOnlyComponents extends broccoli_plugin_1.default {
|
|
14
17
|
constructor(tree, params) {
|
|
15
18
|
super([tree], {
|
|
@@ -17,60 +20,89 @@ class SynthesizeTemplateOnlyComponents extends broccoli_plugin_1.default {
|
|
|
17
20
|
persistentOutput: true,
|
|
18
21
|
needsCache: false,
|
|
19
22
|
});
|
|
20
|
-
this.emitted = new
|
|
23
|
+
this.emitted = new Map();
|
|
21
24
|
this.allowedPaths = params.allowedPaths;
|
|
22
25
|
this.templateExtensions = params.templateExtensions;
|
|
23
26
|
}
|
|
24
27
|
async build() {
|
|
28
|
+
let unneeded = new Set(this.emitted.keys());
|
|
25
29
|
for (let dir of this.allowedPaths) {
|
|
26
|
-
let
|
|
27
|
-
for (let
|
|
28
|
-
let fullName = (0, path_1.join)(this.outputPath, dir,
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
let entries = this.crawl((0, path_1.join)(this.inputPaths[0], dir));
|
|
31
|
+
for (let [name, files] of entries) {
|
|
32
|
+
let fullName = (0, path_1.join)(this.outputPath, dir, name);
|
|
33
|
+
unneeded.delete(fullName);
|
|
34
|
+
if (files.javascript && files.template) {
|
|
35
|
+
this.addTemplateImport(fullName, files);
|
|
36
|
+
}
|
|
37
|
+
else if (files.template) {
|
|
38
|
+
this.addTemplateOnlyComponent(fullName, files);
|
|
31
39
|
}
|
|
32
40
|
else {
|
|
33
|
-
this.
|
|
41
|
+
this.remove(fullName);
|
|
34
42
|
}
|
|
35
43
|
}
|
|
36
44
|
}
|
|
45
|
+
for (let fullName of unneeded) {
|
|
46
|
+
this.remove(fullName);
|
|
47
|
+
}
|
|
37
48
|
}
|
|
38
|
-
|
|
39
|
-
|
|
49
|
+
addTemplateOnlyComponent(filename, files) {
|
|
50
|
+
const emitted = this.emitted.get(filename);
|
|
51
|
+
if ((emitted === null || emitted === void 0 ? void 0 : emitted.type) !== 'template-only-component') {
|
|
40
52
|
// special case: ember-cli doesn't allow template-only components named
|
|
41
53
|
// "template.hbs" because there are too many people doing a "pods-like"
|
|
42
54
|
// layout that happens to match that pattern.🤮
|
|
43
55
|
if ((0, path_1.basename)(filename) !== 'template') {
|
|
44
|
-
|
|
56
|
+
const outputPath = filename + '.js';
|
|
57
|
+
(0, fs_extra_1.outputFileSync)(outputPath, importTemplate(files) + source, 'utf8');
|
|
58
|
+
this.emitted.set(filename, { type: 'template-only-component', outputPath });
|
|
59
|
+
if (emitted && emitted.outputPath !== outputPath) {
|
|
60
|
+
(0, fs_extra_1.removeSync)(emitted.outputPath);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
addTemplateImport(filename, files) {
|
|
66
|
+
const emitted = this.emitted.get(filename);
|
|
67
|
+
const mtime = files.javascript.mtime;
|
|
68
|
+
if (!((emitted === null || emitted === void 0 ? void 0 : emitted.type) === 'template-import' && emitted.mtime === mtime)) {
|
|
69
|
+
const inputSource = (0, fs_extra_1.readFileSync)(files.javascript.fullPath, { encoding: 'utf8' });
|
|
70
|
+
const outputPath = filename + (0, path_1.extname)(files.javascript.relativePath);
|
|
71
|
+
// If we are ok with appending instead, copy + append maybe more efficient?
|
|
72
|
+
(0, fs_extra_1.outputFileSync)(outputPath, importTemplate(files) + inputSource, 'utf8');
|
|
73
|
+
this.emitted.set(filename, { type: 'template-import', outputPath, mtime });
|
|
74
|
+
if (emitted && emitted.outputPath !== outputPath) {
|
|
75
|
+
(0, fs_extra_1.removeSync)(emitted.outputPath);
|
|
45
76
|
}
|
|
46
|
-
this.emitted.add(filename);
|
|
47
77
|
}
|
|
48
78
|
}
|
|
49
79
|
remove(filename) {
|
|
50
|
-
|
|
51
|
-
|
|
80
|
+
const emitted = this.emitted.get(filename);
|
|
81
|
+
if (emitted) {
|
|
82
|
+
(0, fs_extra_1.removeSync)(emitted.outputPath);
|
|
52
83
|
this.emitted.delete(filename);
|
|
53
84
|
}
|
|
54
85
|
}
|
|
55
86
|
crawl(dir) {
|
|
56
|
-
|
|
57
|
-
const
|
|
87
|
+
var _a, _b;
|
|
88
|
+
const entries = new Map();
|
|
58
89
|
if ((0, fs_extra_1.pathExistsSync)(dir)) {
|
|
59
|
-
for (let
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
90
|
+
for (let entry of walk_sync_1.default.entries(dir, { directories: false })) {
|
|
91
|
+
const templateExtension = this.templateExtensions.find(ext => entry.relativePath.endsWith(ext));
|
|
92
|
+
if (templateExtension) {
|
|
93
|
+
const key = entry.relativePath.slice(0, -1 * templateExtension.length);
|
|
94
|
+
entries.set(key, { template: entry, javascript: (_a = entries.get(key)) === null || _a === void 0 ? void 0 : _a.javascript });
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const jsExtension = jsExtensions.find(ext => entry.relativePath.endsWith(ext));
|
|
98
|
+
if (jsExtension) {
|
|
99
|
+
const key = entry.relativePath.slice(0, -1 * jsExtension.length);
|
|
100
|
+
entries.set(key, { template: (_b = entries.get(key)) === null || _b === void 0 ? void 0 : _b.template, javascript: entry });
|
|
101
|
+
continue;
|
|
70
102
|
}
|
|
71
103
|
}
|
|
72
104
|
}
|
|
73
|
-
return
|
|
105
|
+
return entries;
|
|
74
106
|
}
|
|
75
107
|
}
|
|
76
108
|
exports.default = SynthesizeTemplateOnlyComponents;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"synthesize-template-only-components.js","sourceRoot":"","sources":["synthesize-template-only-components.ts"],"names":[],"mappings":";;;;;AAAA,sEAAqC;AAErC,+
|
|
1
|
+
{"version":3,"file":"synthesize-template-only-components.js","sourceRoot":"","sources":["synthesize-template-only-components.ts"],"names":[],"mappings":";;;;;AAAA,sEAAqC;AAErC,+BAA+C;AAC/C,0DAAiD;AACjD,uCAAoF;AAEpF,MAAM,MAAM,GAAG;wCACyB,CAAC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,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE;gBAC/D,MAAM,iBAAiB,GAAG,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;gBAChG,IAAI,iBAAiB,EAAE;oBACrB,MAAM,GAAG,GAAG,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;oBACvE,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,MAAA,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,0CAAE,UAAU,EAAE,CAAC,CAAC;oBAChF,SAAS;iBACV;gBAED,MAAM,WAAW,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC/E,IAAI,WAAW,EAAE;oBACf,MAAM,GAAG,GAAG,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;oBACjE,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,MAAA,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,0CAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;oBAC9E,SAAS;iBACV;aACF;SACF;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAxGD,mDAwGC","sourcesContent":["import Plugin from 'broccoli-plugin';\nimport type { Node } from 'broccoli-node-api';\nimport { join, basename, extname } from 'path';\nimport walkSync, { type Entry } from 'walk-sync';\nimport { removeSync, outputFileSync, pathExistsSync, readFileSync } from 'fs-extra';\n\nconst source = `import templateOnlyComponent from '@ember/component/template-only';\nexport default templateOnlyComponent();`;\n\nconst jsExtensions = ['.js', '.ts', '.mjs', '.mts'];\n\ntype Emitted =\n | { type: 'template-only-component'; outputPath: string }\n | { type: 'template-import'; outputPath: string; mtime: number };\n\ntype TemplateOnly = { template: Entry; javascript: undefined };\ntype JavaScriptOnly = { template: undefined; javascript: Entry };\ntype Colocated = { template: Entry; javascript: Entry };\ntype ComponentFiles = TemplateOnly | JavaScriptOnly | Colocated;\n\nfunction importTemplate(files: { template: Entry }): string {\n return `/* import __COLOCATED_TEMPLATE__ from './${basename(files.template.relativePath)}'; */\\n`;\n}\n\nexport default class SynthesizeTemplateOnlyComponents extends Plugin {\n private emitted = new Map() as Map<string, Emitted>;\n private allowedPaths: string[];\n private templateExtensions: string[];\n\n constructor(tree: Node, params: { allowedPaths: string[]; templateExtensions: string[] }) {\n super([tree], {\n annotation: `synthesize-template-only-components:${params.allowedPaths.join(':')}`,\n persistentOutput: true,\n needsCache: false,\n });\n this.allowedPaths = params.allowedPaths;\n this.templateExtensions = params.templateExtensions;\n }\n\n async build() {\n let unneeded = new Set(this.emitted.keys());\n for (let dir of this.allowedPaths) {\n let entries = this.crawl(join(this.inputPaths[0], dir));\n for (let [name, files] of entries) {\n let fullName = join(this.outputPath, dir, name);\n unneeded.delete(fullName);\n if (files.javascript && files.template) {\n this.addTemplateImport(fullName, files);\n } else if (files.template) {\n this.addTemplateOnlyComponent(fullName, files);\n } else {\n this.remove(fullName);\n }\n }\n }\n for (let fullName of unneeded) {\n this.remove(fullName);\n }\n }\n\n private addTemplateOnlyComponent(filename: string, files: TemplateOnly) {\n const emitted = this.emitted.get(filename);\n\n if (emitted?.type !== 'template-only-component') {\n // special case: ember-cli doesn't allow template-only components named\n // \"template.hbs\" because there are too many people doing a \"pods-like\"\n // layout that happens to match that pattern.🤮\n if (basename(filename) !== 'template') {\n const outputPath = filename + '.js';\n outputFileSync(outputPath, importTemplate(files) + source, 'utf8');\n this.emitted.set(filename, { type: 'template-only-component', outputPath });\n\n if (emitted && emitted.outputPath !== outputPath) {\n removeSync(emitted.outputPath);\n }\n }\n }\n }\n\n private addTemplateImport(filename: string, files: Colocated) {\n const emitted = this.emitted.get(filename);\n const mtime = files.javascript.mtime;\n\n if (!(emitted?.type === 'template-import' && emitted.mtime === mtime)) {\n const inputSource = readFileSync(files.javascript.fullPath, { encoding: 'utf8' });\n const outputPath = filename + extname(files.javascript.relativePath);\n // If we are ok with appending instead, copy + append maybe more efficient?\n outputFileSync(outputPath, importTemplate(files) + inputSource, 'utf8');\n this.emitted.set(filename, { type: 'template-import', outputPath, mtime });\n\n if (emitted && emitted.outputPath !== outputPath) {\n removeSync(emitted.outputPath);\n }\n }\n }\n\n private remove(filename: string) {\n const emitted = this.emitted.get(filename);\n\n if (emitted) {\n removeSync(emitted.outputPath);\n this.emitted.delete(filename);\n }\n }\n\n private crawl(dir: string): Map<string, ComponentFiles> {\n const entries = new Map<string, ComponentFiles>();\n\n if (pathExistsSync(dir)) {\n for (let entry of walkSync.entries(dir, { directories: false })) {\n const templateExtension = this.templateExtensions.find(ext => entry.relativePath.endsWith(ext));\n if (templateExtension) {\n const key = entry.relativePath.slice(0, -1 * templateExtension.length);\n entries.set(key, { template: entry, javascript: entries.get(key)?.javascript });\n continue;\n }\n\n const jsExtension = jsExtensions.find(ext => entry.relativePath.endsWith(ext));\n if (jsExtension) {\n const key = entry.relativePath.slice(0, -1 * jsExtension.length);\n entries.set(key, { template: entries.get(key)?.template, javascript: entry });\n continue;\n }\n }\n }\n\n return entries;\n }\n}\n"]}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2018 Edward Faulkner
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|