@embroider/addon-dev 3.2.1-unstable.9048919 → 3.2.1-unstable.b6dee02
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/addon-dev",
|
|
3
|
-
"version": "3.2.1-unstable.
|
|
3
|
+
"version": "3.2.1-unstable.b6dee02",
|
|
4
4
|
"description": "Utilities for addon authors",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,9 +26,8 @@
|
|
|
26
26
|
"test": "jest"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@embroider/core": "3.2.1-unstable.
|
|
29
|
+
"@embroider/core": "3.2.1-unstable.b6dee02",
|
|
30
30
|
"@rollup/pluginutils": "^4.1.1",
|
|
31
|
-
"assert-never": "^1.2.1",
|
|
32
31
|
"content-tag": "^1.0.0",
|
|
33
32
|
"fs-extra": "^10.0.0",
|
|
34
33
|
"minimatch": "^3.0.4",
|
package/src/rollup-gjs-plugin.js
CHANGED
|
@@ -9,23 +9,12 @@ const processor = new content_tag_1.Preprocessor();
|
|
|
9
9
|
function rollupGjsPlugin() {
|
|
10
10
|
return {
|
|
11
11
|
name: PLUGIN_NAME,
|
|
12
|
-
async resolveId(source, importer, options) {
|
|
13
|
-
let resolution = await this.resolve(source, importer, {
|
|
14
|
-
skipSelf: true,
|
|
15
|
-
...options,
|
|
16
|
-
});
|
|
17
|
-
if (resolution) {
|
|
18
|
-
return maybeRewriteGJS(resolution);
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
12
|
load(id) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return;
|
|
13
|
+
if (!gjsFilter(id)) {
|
|
14
|
+
return null;
|
|
25
15
|
}
|
|
26
|
-
|
|
27
|
-
let
|
|
28
|
-
let code = processor.process(input);
|
|
16
|
+
let input = (0, fs_1.readFileSync)(id, 'utf8');
|
|
17
|
+
let code = processor.process(input, id);
|
|
29
18
|
return {
|
|
30
19
|
code,
|
|
31
20
|
};
|
|
@@ -33,40 +22,5 @@ function rollupGjsPlugin() {
|
|
|
33
22
|
};
|
|
34
23
|
}
|
|
35
24
|
exports.default = rollupGjsPlugin;
|
|
36
|
-
function getMeta(context, id) {
|
|
37
|
-
var _a, _b;
|
|
38
|
-
const meta = (_b = (_a = context.getModuleInfo(id)) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b[PLUGIN_NAME];
|
|
39
|
-
if (meta) {
|
|
40
|
-
return meta;
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
25
|
const gjsFilter = (0, pluginutils_1.createFilter)('**/*.g{j,t}s');
|
|
47
|
-
function maybeRewriteGJS(resolution) {
|
|
48
|
-
if (!gjsFilter(resolution.id)) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
let id;
|
|
52
|
-
if (resolution.id.endsWith('.gjs')) {
|
|
53
|
-
id = resolution.id.replace(/\.gjs$/, '.js');
|
|
54
|
-
}
|
|
55
|
-
else if (resolution.id.endsWith('.gts')) {
|
|
56
|
-
id = resolution.id.replace(/\.gts$/, '.ts');
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
throw new Error('Unexpected issues in the plugin-rollup-gjs - an unexpected file made its way throught the pluginUtils filter');
|
|
60
|
-
}
|
|
61
|
-
// This creates an `*.js` or `*.ts` that **replaces** the .gjs or .gts file that we will populate in `load()` hook.
|
|
62
|
-
return {
|
|
63
|
-
...resolution,
|
|
64
|
-
id,
|
|
65
|
-
meta: {
|
|
66
|
-
[PLUGIN_NAME]: {
|
|
67
|
-
originalId: resolution.id,
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
26
|
//# sourceMappingURL=rollup-gjs-plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup-gjs-plugin.js","sourceRoot":"","sources":["rollup-gjs-plugin.ts"],"names":[],"mappings":";;AAAA,qDAAmD;AAEnD,2BAAkC;AAClC,6CAA2C;AAE3C,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAExC,MAAM,SAAS,GAAG,IAAI,0BAAY,EAAE,CAAC;AACrC,6CAA6C;AAE7C,SAAwB,eAAe;IACrC,OAAO;QACL,IAAI,EAAE,WAAW;
|
|
1
|
+
{"version":3,"file":"rollup-gjs-plugin.js","sourceRoot":"","sources":["rollup-gjs-plugin.ts"],"names":[],"mappings":";;AAAA,qDAAmD;AAEnD,2BAAkC;AAClC,6CAA2C;AAE3C,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAExC,MAAM,SAAS,GAAG,IAAI,0BAAY,EAAE,CAAC;AACrC,6CAA6C;AAE7C,SAAwB,eAAe;IACrC,OAAO;QACL,IAAI,EAAE,WAAW;QAEjB,IAAI,CAAC,EAAU;YACb,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE;gBAClB,OAAO,IAAI,CAAC;aACb;YACD,IAAI,KAAK,GAAG,IAAA,iBAAY,EAAC,EAAE,EAAE,MAAM,CAAC,CAAC;YACrC,IAAI,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACxC,OAAO;gBACL,IAAI;aACL,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAfD,kCAeC;AAED,MAAM,SAAS,GAAG,IAAA,0BAAY,EAAC,cAAc,CAAC,CAAC","sourcesContent":["import { createFilter } from '@rollup/pluginutils';\nimport type { Plugin } from 'rollup';\nimport { readFileSync } from 'fs';\nimport { Preprocessor } from 'content-tag';\n\nconst PLUGIN_NAME = 'rollup-gjs-plugin';\n\nconst processor = new Preprocessor();\n// import { parse as pathParse } from 'path';\n\nexport default function rollupGjsPlugin(): Plugin {\n return {\n name: PLUGIN_NAME,\n\n load(id: string) {\n if (!gjsFilter(id)) {\n return null;\n }\n let input = readFileSync(id, 'utf8');\n let code = processor.process(input, id);\n return {\n code,\n };\n },\n };\n}\n\nconst gjsFilter = createFilter('**/*.g{j,t}s');\n"]}
|
package/src/rollup-hbs-plugin.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
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
3
|
const pluginutils_1 = require("@rollup/pluginutils");
|
|
7
4
|
const fs_1 = require("fs");
|
|
8
5
|
const core_1 = require("@embroider/core");
|
|
9
|
-
const assert_never_1 = __importDefault(require("assert-never"));
|
|
10
6
|
const path_1 = require("path");
|
|
11
7
|
function rollupHbsPlugin() {
|
|
12
8
|
return {
|
|
@@ -16,32 +12,25 @@ function rollupHbsPlugin() {
|
|
|
16
12
|
skipSelf: true,
|
|
17
13
|
...options,
|
|
18
14
|
});
|
|
19
|
-
if (
|
|
20
|
-
return
|
|
15
|
+
if (resolution) {
|
|
16
|
+
return resolution;
|
|
21
17
|
}
|
|
22
18
|
else {
|
|
23
|
-
return
|
|
19
|
+
return maybeSynthesizeComponentJS(this, source, importer, options);
|
|
24
20
|
}
|
|
25
21
|
},
|
|
26
22
|
load(id) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
if (hbsFilter(id)) {
|
|
24
|
+
let input = (0, fs_1.readFileSync)(id, 'utf8');
|
|
25
|
+
let code = (0, core_1.hbsToJS)(input);
|
|
26
|
+
return {
|
|
27
|
+
code,
|
|
28
|
+
};
|
|
30
29
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
let code = (0, core_1.hbsToJS)(input);
|
|
36
|
-
return {
|
|
37
|
-
code,
|
|
38
|
-
};
|
|
39
|
-
case 'template-only-component-js':
|
|
40
|
-
return {
|
|
41
|
-
code: templateOnlyComponent,
|
|
42
|
-
};
|
|
43
|
-
default:
|
|
44
|
-
(0, assert_never_1.default)(meta);
|
|
30
|
+
if (getMeta(this, id)) {
|
|
31
|
+
return {
|
|
32
|
+
code: templateOnlyComponent,
|
|
33
|
+
};
|
|
45
34
|
}
|
|
46
35
|
},
|
|
47
36
|
};
|
|
@@ -83,20 +72,4 @@ async function maybeSynthesizeComponentJS(context, source, importer, options) {
|
|
|
83
72
|
};
|
|
84
73
|
}
|
|
85
74
|
const hbsFilter = (0, pluginutils_1.createFilter)('**/*.hbs');
|
|
86
|
-
function maybeRewriteHBS(resolution) {
|
|
87
|
-
if (!hbsFilter(resolution.id)) {
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
// This creates an `*.hbs.js` that we will populate in `load()` hook.
|
|
91
|
-
return {
|
|
92
|
-
...resolution,
|
|
93
|
-
id: resolution.id + '.js',
|
|
94
|
-
meta: {
|
|
95
|
-
'rollup-hbs-plugin': {
|
|
96
|
-
type: 'template',
|
|
97
|
-
originalId: resolution.id,
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
75
|
//# 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":";;AAAA,qDAAmD;AAEnD,2BAAkC;AAClC,0CAA0C;AAC1C,+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,MA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B,EACtB,MAAc,EACd,QAA4B,EAC5B,OAA2D;IAE3D,IAAI,kBAAkB,GAAG,MAAM,OAAO,CAAC,OAAO,CAC5C,qBAAqB,CAAC,MAAM,CAAC,EAC7B,QAAQ,EACR;QACE,QAAQ,EAAE,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","sourcesContent":["import { createFilter } from '@rollup/pluginutils';\nimport type { Plugin, PluginContext, CustomPluginOptions } from 'rollup';\nimport { readFileSync } from 'fs';\nimport { hbsToJS } from '@embroider/core';\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 resolution;\n } else {\n return maybeSynthesizeComponentJS(this, source, importer, options);\n }\n },\n\n load(id: string) {\n if (hbsFilter(id)) {\n let input = readFileSync(id, 'utf8');\n let code = hbsToJS(input);\n return {\n code,\n };\n }\n if (getMeta(this, id)) {\n return {\n code: templateOnlyComponent,\n };\n }\n },\n };\n}\n\nconst templateOnlyComponent =\n `import templateOnly from '@ember/component/template-only';\\n` +\n `export default templateOnly();\\n`;\n\ntype Meta = {\n type: 'template-only-component-js';\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"]}
|