@embroider/core 1.5.0 → 1.6.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.
@@ -1,14 +1,9 @@
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
  exports.NodeTemplateCompiler = void 0;
7
4
  const path_1 = require("path");
8
- const core_1 = require("@babel/core");
9
5
  const load_ember_template_compiler_1 = require("./load-ember-template-compiler");
10
6
  const template_compiler_common_1 = require("./template-compiler-common");
11
- const babel_plugin_adjust_imports_1 = __importDefault(require("./babel-plugin-adjust-imports"));
12
7
  class NodeTemplateCompiler extends template_compiler_common_1.TemplateCompiler {
13
8
  constructor(params) {
14
9
  super({
@@ -19,23 +14,6 @@ class NodeTemplateCompiler extends template_compiler_common_1.TemplateCompiler {
19
14
  });
20
15
  this.params = params;
21
16
  }
22
- compile(moduleName, contents) {
23
- let src = super.compile(moduleName, contents);
24
- let resolver = this.params.resolver;
25
- if (resolver) {
26
- let opts = resolver.adjustImportsOptions;
27
- return (0, core_1.transform)(src, {
28
- filename: moduleName,
29
- generatorOpts: {
30
- compact: false,
31
- },
32
- plugins: [[babel_plugin_adjust_imports_1.default, opts]],
33
- }).code;
34
- }
35
- else {
36
- return src;
37
- }
38
- }
39
17
  // Use applyTransforms on the contents of inline hbs template strings inside
40
18
  // Javascript.
41
19
  inlineTransformsBabelPlugin() {
@@ -49,27 +27,6 @@ class NodeTemplateCompiler extends template_compiler_common_1.TemplateCompiler {
49
27
  baseDir() {
50
28
  return (0, path_1.join)(__dirname, '..');
51
29
  }
52
- // tests for the classic ember-cli-htmlbars-inline-precompile babel plugin
53
- static isInlinePrecompilePlugin(item) {
54
- if (typeof item === 'string') {
55
- return (0, template_compiler_common_1.matchesSourceFile)(item);
56
- }
57
- if (hasProperties(item) && item._parallelBabel) {
58
- return (0, template_compiler_common_1.matchesSourceFile)(item._parallelBabel.requireFile);
59
- }
60
- if (Array.isArray(item) && item.length > 0) {
61
- if (typeof item[0] === 'string') {
62
- return (0, template_compiler_common_1.matchesSourceFile)(item[0]);
63
- }
64
- if (hasProperties(item[0]) && item[0]._parallelBabel) {
65
- return (0, template_compiler_common_1.matchesSourceFile)(item[0]._parallelBabel.requireFile);
66
- }
67
- }
68
- return false;
69
- }
70
30
  }
71
31
  exports.NodeTemplateCompiler = NodeTemplateCompiler;
72
- function hasProperties(item) {
73
- return item && (typeof item === 'object' || typeof item === 'function');
74
- }
75
32
  //# sourceMappingURL=template-compiler-node.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"template-compiler-node.js","sourceRoot":"","sources":["template-compiler-node.ts"],"names":[],"mappings":";;;;;;AACA,+BAA4B;AAC5B,sCAAoD;AAGpD,iFAAiE;AACjE,yEAAiF;AACjF,gGAAqG;AAUrG,MAAa,oBAAqB,SAAQ,2CAAgB;IACxD,YAAmB,MAAkC;QACnD,KAAK,CAAC;YACJ,yBAAyB,EAAE,GAAG,EAAE,CAAC,IAAA,8CAAe,EAAC,MAAM,CAAC,YAAY,CAAC;YACrE,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,CAAC,CAAC;QANc,WAAM,GAAN,MAAM,CAA4B;IAOrD,CAAC;IAED,OAAO,CAAC,UAAkB,EAAE,QAAgB;QAC1C,IAAI,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC9C,IAAI,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;QACpC,IAAI,QAAQ,EAAE;YACZ,IAAI,IAAI,GAAyB,QAAQ,CAAC,oBAAoB,CAAC;YAC/D,OAAO,IAAA,gBAAS,EAAC,GAAG,EAAE;gBACpB,QAAQ,EAAE,UAAU;gBACpB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DC;AAED,SAAS,aAAa,CAAC,IAAS;IAC9B,OAAO,IAAI,IAAI,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["import { Resolver } from './resolver';\nimport { join } from 'path';\nimport { PluginItem, transform } from '@babel/core';\nimport type { Params as InlineBabelParams } from './babel-plugin-stage1-inline-hbs-node';\nimport { Plugins } from './ember-template-compiler-types';\nimport { getEmberExports } from './load-ember-template-compiler';\nimport { TemplateCompiler, matchesSourceFile } from './template-compiler-common';\nimport adjustImportsPlugin, { Options as AdjustImportsOptions } from './babel-plugin-adjust-imports';\n\nexport interface NodeTemplateCompilerParams {\n compilerPath: string;\n compilerChecksum: string;\n resolver?: Resolver;\n EmberENV: unknown;\n plugins: Plugins;\n}\n\nexport class NodeTemplateCompiler extends TemplateCompiler {\n constructor(public params: NodeTemplateCompilerParams) {\n super({\n loadEmberTemplateCompiler: () => getEmberExports(params.compilerPath),\n resolver: params.resolver,\n EmberENV: params.EmberENV,\n plugins: params.plugins,\n });\n }\n\n compile(moduleName: string, contents: string) {\n let src = super.compile(moduleName, contents);\n let resolver = this.params.resolver;\n if (resolver) {\n let opts: AdjustImportsOptions = resolver.adjustImportsOptions;\n return transform(src, {\n filename: moduleName,\n generatorOpts: {\n compact: false,\n },\n plugins: [[adjustImportsPlugin, opts]],\n })!.code!;\n } else {\n return src;\n }\n }\n\n // Use applyTransforms on the contents of inline hbs template strings inside\n // Javascript.\n inlineTransformsBabelPlugin(): PluginItem {\n return [\n join(__dirname, 'babel-plugin-stage1-inline-hbs-node.js'),\n {\n templateCompiler: this.params,\n } as InlineBabelParams,\n ];\n }\n\n baseDir() {\n return join(__dirname, '..');\n }\n\n // tests for the classic ember-cli-htmlbars-inline-precompile babel plugin\n static isInlinePrecompilePlugin(item: PluginItem) {\n if (typeof item === 'string') {\n return matchesSourceFile(item);\n }\n if (hasProperties(item) && (item as any)._parallelBabel) {\n return matchesSourceFile((item as any)._parallelBabel.requireFile);\n }\n if (Array.isArray(item) && item.length > 0) {\n if (typeof item[0] === 'string') {\n return matchesSourceFile(item[0]);\n }\n if (hasProperties(item[0]) && (item[0] as any)._parallelBabel) {\n return matchesSourceFile((item[0] as any)._parallelBabel.requireFile);\n }\n }\n return false;\n }\n}\n\nfunction hasProperties(item: any) {\n return item && (typeof item === 'object' || typeof item === 'function');\n}\n"]}
1
+ {"version":3,"file":"template-compiler-node.js","sourceRoot":"","sources":["template-compiler-node.ts"],"names":[],"mappings":";;;AACA,+BAA4B;AAI5B,iFAAiE;AACjE,yEAA8D;AAU9D,MAAa,oBAAqB,SAAQ,2CAAgB;IACxD,YAAmB,MAAkC;QACnD,KAAK,CAAC;YACJ,yBAAyB,EAAE,GAAG,EAAE,CAAC,IAAA,8CAAe,EAAC,MAAM,CAAC,YAAY,CAAC;YACrE,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,CAAC,CAAC;QANc,WAAM,GAAN,MAAM,CAA4B;IAOrD,CAAC;IAED,4EAA4E;IAC5E,cAAc;IACd,2BAA2B;QACzB,OAAO;YACL,IAAA,WAAI,EAAC,SAAS,EAAE,wCAAwC,CAAC;YACzD;gBACE,gBAAgB,EAAE,IAAI,CAAC,MAAM;aACT;SACvB,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;CACF;AAxBD,oDAwBC","sourcesContent":["import { Resolver } from './resolver';\nimport { join } from 'path';\nimport { PluginItem } from '@babel/core';\nimport type { Params as InlineBabelParams } from './babel-plugin-stage1-inline-hbs-node';\nimport { Plugins } from './ember-template-compiler-types';\nimport { getEmberExports } from './load-ember-template-compiler';\nimport { TemplateCompiler } from './template-compiler-common';\n\nexport interface NodeTemplateCompilerParams {\n compilerPath: string;\n compilerChecksum: string;\n resolver?: Resolver;\n EmberENV: unknown;\n plugins: Plugins;\n}\n\nexport class NodeTemplateCompiler extends TemplateCompiler {\n constructor(public params: NodeTemplateCompilerParams) {\n super({\n loadEmberTemplateCompiler: () => getEmberExports(params.compilerPath),\n resolver: params.resolver,\n EmberENV: params.EmberENV,\n plugins: params.plugins,\n });\n }\n\n // Use applyTransforms on the contents of inline hbs template strings inside\n // Javascript.\n inlineTransformsBabelPlugin(): PluginItem {\n return [\n join(__dirname, 'babel-plugin-stage1-inline-hbs-node.js'),\n {\n templateCompiler: this.params,\n } as InlineBabelParams,\n ];\n }\n\n baseDir() {\n return join(__dirname, '..');\n }\n}\n"]}
@@ -1 +0,0 @@
1
- export declare function atomicWrite(path: string, content: string): void;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.atomicWrite = void 0;
4
- const crypto_1 = require("crypto");
5
- const fs_extra_1 = require("fs-extra");
6
- const fs_1 = require("fs");
7
- // if the path already exists, this will replace it atomically so that nobody
8
- // will ever read an inconsistent state.
9
- //
10
- // if it doesn't already exist, this will create any intervening directories and
11
- // then create the file.
12
- function atomicWrite(path, content) {
13
- let suffix = (0, crypto_1.randomBytes)(8).toString('hex');
14
- (0, fs_extra_1.outputFileSync)(path + suffix, content);
15
- (0, fs_1.renameSync)(path + suffix, path);
16
- }
17
- exports.atomicWrite = atomicWrite;
18
- //# sourceMappingURL=atomic-write.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"atomic-write.js","sourceRoot":"","sources":["atomic-write.ts"],"names":[],"mappings":";;;AAAA,mCAAqC;AACrC,uCAA0C;AAC1C,2BAAgC;AAEhC,6EAA6E;AAC7E,wCAAwC;AACxC,EAAE;AACF,gFAAgF;AAChF,wBAAwB;AACxB,SAAgB,WAAW,CAAC,IAAY,EAAE,OAAe;IACvD,IAAI,MAAM,GAAG,IAAA,oBAAW,EAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5C,IAAA,yBAAc,EAAC,IAAI,GAAG,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,IAAA,eAAU,EAAC,IAAI,GAAG,MAAM,EAAE,IAAI,CAAC,CAAC;AAClC,CAAC;AAJD,kCAIC","sourcesContent":["import { randomBytes } from 'crypto';\nimport { outputFileSync } from 'fs-extra';\nimport { renameSync } from 'fs';\n\n// if the path already exists, this will replace it atomically so that nobody\n// will ever read an inconsistent state.\n//\n// if it doesn't already exist, this will create any intervening directories and\n// then create the file.\nexport function atomicWrite(path: string, content: string) {\n let suffix = randomBytes(8).toString('hex');\n outputFileSync(path + suffix, content);\n renameSync(path + suffix, path);\n}\n"]}
@@ -1,6 +0,0 @@
1
- import { PortableHint } from './portable';
2
- import type { NodeTemplateCompilerParams } from './template-compiler-node';
3
- export declare function templateCompilerModule(params: NodeTemplateCompilerParams, hints: PortableHint[]): {
4
- src: string;
5
- isParallelSafe: boolean;
6
- };
@@ -1,24 +0,0 @@
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
- exports.templateCompilerModule = void 0;
7
- const path_1 = require("path");
8
- const portable_1 = require("./portable");
9
- const js_string_escape_1 = __importDefault(require("js-string-escape"));
10
- function templateCompilerModule(params, hints) {
11
- let p = new portable_1.Portable({ hints });
12
- let result = p.dehydrate(params);
13
- return {
14
- src: [
15
- `const { NodeTemplateCompiler } = require("${(0, js_string_escape_1.default)((0, path_1.resolve)(__dirname, './template-compiler-node.js'))}");`,
16
- `const { Portable } = require("${(0, js_string_escape_1.default)((0, path_1.resolve)(__dirname, './portable.js'))}");`,
17
- `let p = new Portable({ hints: ${JSON.stringify(hints, null, 2)} });`,
18
- `module.exports = new NodeTemplateCompiler(p.hydrate(${JSON.stringify(result.value, null, 2)}))`,
19
- ].join('\n'),
20
- isParallelSafe: result.isParallelSafe,
21
- };
22
- }
23
- exports.templateCompilerModule = templateCompilerModule;
24
- //# sourceMappingURL=write-template-compiler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"write-template-compiler.js","sourceRoot":"","sources":["write-template-compiler.ts"],"names":[],"mappings":";;;;;;AAAA,+BAA+B;AAC/B,yCAAoD;AAEpD,wEAA8C;AAE9C,SAAgB,sBAAsB,CAAC,MAAkC,EAAE,KAAqB;IAC9F,IAAI,CAAC,GAAG,IAAI,mBAAQ,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAChC,IAAI,MAAM,GAAG,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO;QACL,GAAG,EAAE;YACH,6CAA6C,IAAA,0BAAc,EACzD,IAAA,cAAO,EAAC,SAAS,EAAE,6BAA6B,CAAC,CAClD,KAAK;YACN,iCAAiC,IAAA,0BAAc,EAAC,IAAA,cAAO,EAAC,SAAS,EAAE,eAAe,CAAC,CAAC,KAAK;YACzF,iCAAiC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM;YACrE,uDAAuD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI;SACjG,CAAC,IAAI,CAAC,IAAI,CAAC;QACZ,cAAc,EAAE,MAAM,CAAC,cAAc;KACtC,CAAC;AACJ,CAAC;AAdD,wDAcC","sourcesContent":["import { resolve } from 'path';\nimport { Portable, PortableHint } from './portable';\nimport type { NodeTemplateCompilerParams } from './template-compiler-node';\nimport jsStringEscape from 'js-string-escape';\n\nexport function templateCompilerModule(params: NodeTemplateCompilerParams, hints: PortableHint[]) {\n let p = new Portable({ hints });\n let result = p.dehydrate(params);\n return {\n src: [\n `const { NodeTemplateCompiler } = require(\"${jsStringEscape(\n resolve(__dirname, './template-compiler-node.js')\n )}\");`,\n `const { Portable } = require(\"${jsStringEscape(resolve(__dirname, './portable.js'))}\");`,\n `let p = new Portable({ hints: ${JSON.stringify(hints, null, 2)} });`,\n `module.exports = new NodeTemplateCompiler(p.hydrate(${JSON.stringify(result.value, null, 2)}))`,\n ].join('\\n'),\n isParallelSafe: result.isParallelSafe,\n };\n}\n"]}