@embroider/vite 0.2.1-unstable.b33cb4c → 0.2.1-unstable.b4add32
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/index.mjs +0 -1
- package/package.json +4 -4
- package/src/hbs.js +2 -4
- package/src/hbs.js.map +1 -1
- package/src/template-tag.js +2 -3
- package/src/template-tag.js.map +1 -1
package/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embroider/vite",
|
|
3
|
-
"version": "0.2.1-unstable.
|
|
3
|
+
"version": "0.2.1-unstable.b4add32",
|
|
4
4
|
"main": "index.mjs",
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@embroider/core": "3.4.
|
|
6
|
+
"@embroider/core": "3.4.4-unstable.b4add32",
|
|
7
7
|
"vite": "^4.3.9"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@babel/core": "^7.22.9",
|
|
14
|
-
"@embroider/macros": "1.13.
|
|
14
|
+
"@embroider/macros": "1.13.5-unstable.b4add32",
|
|
15
15
|
"@rollup/pluginutils": "^4.1.1",
|
|
16
16
|
"assert-never": "^1.2.1",
|
|
17
17
|
"content-tag": "^1.1.2",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"terser": "^5.7.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@embroider/core": "3.4.
|
|
26
|
+
"@embroider/core": "3.4.4-unstable.b4add32",
|
|
27
27
|
"@types/babel__core": "^7.20.1",
|
|
28
28
|
"@types/debug": "^4.1.5",
|
|
29
29
|
"@types/jsdom": "^16.2.11",
|
package/src/hbs.js
CHANGED
|
@@ -7,7 +7,6 @@ exports.hbs = void 0;
|
|
|
7
7
|
// TODO: I copied this from @embroider/addon-dev, it needs to be its own package
|
|
8
8
|
// (or be in shared-internals or core)
|
|
9
9
|
const pluginutils_1 = require("@rollup/pluginutils");
|
|
10
|
-
const fs_1 = require("fs");
|
|
11
10
|
const core_1 = require("@embroider/core");
|
|
12
11
|
const assert_never_1 = __importDefault(require("assert-never"));
|
|
13
12
|
const path_1 = require("path");
|
|
@@ -28,15 +27,14 @@ function hbs() {
|
|
|
28
27
|
return maybeRewriteHBS(resolution);
|
|
29
28
|
}
|
|
30
29
|
},
|
|
31
|
-
|
|
30
|
+
transform(source, id) {
|
|
32
31
|
const meta = getMeta(this, id);
|
|
33
32
|
if (!meta) {
|
|
34
33
|
return;
|
|
35
34
|
}
|
|
36
35
|
switch (meta.type) {
|
|
37
36
|
case 'template':
|
|
38
|
-
let
|
|
39
|
-
let code = (0, core_1.hbsToJS)(input);
|
|
37
|
+
let code = (0, core_1.hbsToJS)(source);
|
|
40
38
|
return {
|
|
41
39
|
code,
|
|
42
40
|
};
|
package/src/hbs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hbs.js","sourceRoot":"","sources":["hbs.ts"],"names":[],"mappings":";;;;;;AAAA,gFAAgF;AAChF,sCAAsC;AACtC,qDAAmD;AAGnD,
|
|
1
|
+
{"version":3,"file":"hbs.js","sourceRoot":"","sources":["hbs.ts"],"names":[],"mappings":";;;;;;AAAA,gFAAgF;AAChF,sCAAsC;AACtC,qDAAmD;AAGnD,0CAA0C;AAC1C,gEAAuC;AACvC,+BAA0C;AAC1C,kDAA8B;AAE9B,MAAM,KAAK,GAAG,IAAA,eAAS,EAAC,sBAAsB,CAAC,CAAC;AAEhD,SAAgB,GAAG;IACjB,OAAO;QACL,IAAI,EAAE,mBAAmB;QACzB,OAAO,EAAE,KAAK;QACd,KAAK,CAAC,SAAS,CAAC,MAAc,EAAE,QAA4B;YAC1D,IAAI,UAAU,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE;gBACpD,QAAQ,EAAE,IAAI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,UAAU,0BAA0B,CAAC,OAAsB,EAAE,MAAc,EAAE,QAA4B;IAC5G,KAAK,CAAC,0CAA0C,EAAE,MAAM,CAAC,CAAC;IAC1D,IAAI,kBAAkB,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE;QACtF,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE;YACN,SAAS,EAAE;gBACT,iEAAiE;gBACjE,sEAAsE;gBACtE,qEAAqE;gBACrE,sEAAsE;gBACtE,WAAW;gBACX,EAAE;gBACF,oEAAoE;gBACpE,2DAA2D;gBAC3D,oBAAoB,EAAE,KAAK;aAC5B;SACF;KACF,CAAC,CAAC;IACH,IAAI,CAAC,kBAAkB,EAAE;QACvB,OAAO,IAAI,CAAC;KACb;IACD,KAAK,CAAC,sCAAsC,EAAE,kBAAkB,CAAC,EAAE,CAAC,CAAC;IAErE,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,iBAAiB,CAAC,CAAC;AAElD,SAAS,eAAe,CAAC,UAAsB;IAC7C,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE;QAC7B,OAAO,IAAI,CAAC;KACb;IACD,KAAK,CAAC,0BAA0B,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC;IACjD,OAAO;QACL,GAAG,UAAU;QACb,IAAI,EAAE;YACJ,mBAAmB,EAAE;gBACnB,IAAI,EAAE,UAAU;aACjB;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["// TODO: I copied this from @embroider/addon-dev, it needs to be its own package\n// (or be in shared-internals or core)\nimport { createFilter } from '@rollup/pluginutils';\nimport type { PluginContext, ResolvedId } from 'rollup';\nimport type { Plugin } from 'vite';\nimport { hbsToJS } from '@embroider/core';\nimport assertNever from 'assert-never';\nimport { parse as pathParse } from 'path';\nimport makeDebug from 'debug';\n\nconst debug = makeDebug('embroider:hbs-plugin');\n\nexport function hbs(): Plugin {\n return {\n name: 'rollup-hbs-plugin',\n enforce: 'pre',\n async resolveId(source: string, importer: string | undefined) {\n let resolution = await this.resolve(source, importer, {\n skipSelf: true,\n });\n\n if (!resolution) {\n return maybeSynthesizeComponentJS(this, source, importer);\n } else {\n return maybeRewriteHBS(resolution);\n }\n },\n\n transform(source: string, id: string) {\n const meta = getMeta(this, id);\n if (!meta) {\n return;\n }\n\n switch (meta.type) {\n case 'template':\n let code = hbsToJS(source);\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` + `export default templateOnly();\\n`;\n\ntype Meta =\n | {\n type: 'template';\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(context: PluginContext, source: string, importer: string | undefined) {\n debug(`checking for template-only component: %s`, source);\n let templateResolution = await context.resolve(correspondingTemplate(source), importer, {\n skipSelf: true,\n custom: {\n embroider: {\n // we don't want to recurse into the whole embroider compatbility\n // resolver here. It has presumably already steered our request to the\n // correct place. All we want to do is slightly modify the request we\n // were given (changing the extension) and check if that would resolve\n // instead.\n //\n // Currently this guard is only actually exercised in rollup, not in\n // vite, due to https://github.com/vitejs/vite/issues/13852\n enableCustomResolver: false,\n },\n },\n });\n if (!templateResolution) {\n return null;\n }\n debug(`emitting template only component: %s`, templateResolution.id);\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 debug('emitting hbs rewrite: %s', resolution.id);\n return {\n ...resolution,\n meta: {\n 'rollup-hbs-plugin': {\n type: 'template',\n },\n },\n };\n}\n"]}
|
package/src/template-tag.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.templateTag = void 0;
|
|
4
4
|
const pluginutils_1 = require("@rollup/pluginutils");
|
|
5
|
-
const fs_1 = require("fs");
|
|
6
5
|
const content_tag_1 = require("content-tag");
|
|
7
6
|
const gjsFilter = (0, pluginutils_1.createFilter)('**/*.gjs?(\\?)*');
|
|
8
7
|
function templateTag() {
|
|
@@ -36,11 +35,11 @@ function templateTag() {
|
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
},
|
|
39
|
-
|
|
38
|
+
transform(code, id) {
|
|
40
39
|
if (!gjsFilter(id)) {
|
|
41
40
|
return null;
|
|
42
41
|
}
|
|
43
|
-
return preprocessor.process(
|
|
42
|
+
return preprocessor.process(code, id);
|
|
44
43
|
},
|
|
45
44
|
};
|
|
46
45
|
}
|
package/src/template-tag.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-tag.js","sourceRoot":"","sources":["template-tag.ts"],"names":[],"mappings":";;;AAAA,qDAAmD;AAEnD,
|
|
1
|
+
{"version":3,"file":"template-tag.js","sourceRoot":"","sources":["template-tag.ts"],"names":[],"mappings":";;;AAAA,qDAAmD;AAEnD,6CAA2C;AAE3C,MAAM,SAAS,GAAG,IAAA,0BAAY,EAAC,iBAAiB,CAAC,CAAC;AAElD,SAAgB,WAAW;IACzB,IAAI,YAAY,GAAG,IAAI,0BAAY,EAAE,CAAC;IAEtC,SAAS,UAAU,CAAC,EAAU;QAC5B,OAAO,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC;IACvB,CAAC;IAED,OAAO;QACL,IAAI,EAAE,wBAAwB;QAC9B,OAAO,EAAE,KAAK;QAEd,KAAK,CAAC,SAAS,CAAC,EAAU,EAAE,QAA4B;YACtD,IAAI,UAAU,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,QAAQ,EAAE;gBAChD,QAAQ,EAAE,IAAI;aACf,CAAC,CAAC;YACH,IAAI,UAAU,EAAE;gBACd,OAAO,UAAU,CAAC;aACnB;YACD,KAAK,IAAI,SAAS,IAAI,UAAU,CAAC,EAAE,CAAC,EAAE;gBACpC,UAAU,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,QAAQ,EAAE;oBACnD,QAAQ,EAAE,IAAI;oBACd,MAAM,EAAE;wBACN,SAAS,EAAE;4BACT,oBAAoB,EAAE,KAAK;yBAC5B;qBACF;iBACF,CAAC,CAAC;gBACH,IAAI,UAAU,EAAE;oBACd,OAAO;wBACL,EAAE,EAAE,UAAU,CAAC,EAAE;qBAClB,CAAC;iBACH;aACF;QACH,CAAC;QAED,SAAS,CAAC,IAAY,EAAE,EAAU;YAChC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE;gBAClB,OAAO,IAAI,CAAC;aACb;YACD,OAAO,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACxC,CAAC;KACF,CAAC;AACJ,CAAC;AA1CD,kCA0CC","sourcesContent":["import { createFilter } from '@rollup/pluginutils';\nimport type { Plugin } from 'vite';\nimport { Preprocessor } from 'content-tag';\n\nconst gjsFilter = createFilter('**/*.gjs?(\\\\?)*');\n\nexport function templateTag(): Plugin {\n let preprocessor = new Preprocessor();\n\n function candidates(id: string) {\n return [id + '.gjs'];\n }\n\n return {\n name: 'embroider-template-tag',\n enforce: 'pre',\n\n async resolveId(id: string, importer: string | undefined) {\n let resolution = await this.resolve(id, importer, {\n skipSelf: true,\n });\n if (resolution) {\n return resolution;\n }\n for (let candidate of candidates(id)) {\n resolution = await this.resolve(candidate, importer, {\n skipSelf: true,\n custom: {\n embroider: {\n enableCustomResolver: false,\n },\n },\n });\n if (resolution) {\n return {\n id: resolution.id,\n };\n }\n }\n },\n\n transform(code: string, id: string) {\n if (!gjsFilter(id)) {\n return null;\n }\n return preprocessor.process(code, id);\n },\n };\n}\n"]}
|