@embroider/core
Advanced tools
Comparing version 0.31.0 to 0.32.0
{ | ||
"name": "@embroider/core", | ||
"version": "0.31.0", | ||
"version": "0.32.0", | ||
"private": false, | ||
@@ -27,10 +27,13 @@ "description": "A build system for EmberJS applications.", | ||
"@babel/plugin-syntax-dynamic-import": "^7.8.3", | ||
"@babel/plugin-transform-runtime": "^7.12.1", | ||
"@babel/runtime": "^7.12.5", | ||
"@babel/traverse": "^7.12.1", | ||
"@babel/types": "^7.12.1", | ||
"@embroider/macros": "0.31.0", | ||
"@embroider/macros": "0.32.0", | ||
"assert-never": "^1.1.0", | ||
"babel-plugin-syntax-dynamic-import": "^6.18.0", | ||
"broccoli-persistent-filter": "^2.2.2", | ||
"broccoli-plugin": "^3.0.0", | ||
"broccoli-source": "^1.1.0", | ||
"broccoli-node-api": "^1.7.0", | ||
"broccoli-persistent-filter": "^3.1.2", | ||
"broccoli-plugin": "^4.0.1", | ||
"broccoli-source": "^3.0.0", | ||
"debug": "^3.1.0", | ||
@@ -57,3 +60,3 @@ "fast-sourcemap-concat": "^1.4.0", | ||
"@embroider/sample-transforms": "0.0.0", | ||
"@embroider/test-support": "0.31.0", | ||
"@embroider/test-support": "0.32.0", | ||
"@types/babel__core": "^7.1.10", | ||
@@ -60,0 +63,0 @@ "@types/debug": "^0.0.31", |
@@ -74,2 +74,3 @@ import { OutputPaths } from './wait-for-trees'; | ||
private templateCompiler; | ||
private get portableHints(); | ||
private addTemplateCompiler; | ||
@@ -76,0 +77,0 @@ private addBabelConfig; |
@@ -45,4 +45,4 @@ "use strict"; | ||
const macros_1 = require("@embroider/macros"); | ||
const portable_babel_config_1 = __importDefault(require("./portable-babel-config")); | ||
const template_compiler_1 = __importDefault(require("./template-compiler")); | ||
const portable_babel_config_1 = require("./portable-babel-config"); | ||
const template_compiler_1 = require("./template-compiler"); | ||
const paths_1 = require("./paths"); | ||
@@ -213,3 +213,3 @@ const engine_mangler_1 = require("./engine-mangler"); | ||
} | ||
babelConfig(templateCompiler, appFiles) { | ||
babelConfig(templateCompilerParams, appFiles) { | ||
let babel = this.adapter.babelConfig(); | ||
@@ -228,3 +228,3 @@ if (!babel.plugins) { | ||
{ | ||
templateCompiler, | ||
templateCompiler: templateCompilerParams, | ||
stage: 3, | ||
@@ -237,3 +237,8 @@ }, | ||
babel.plugins.push([require.resolve('./template-colocation-plugin')]); | ||
return new portable_babel_config_1.default(babel, { basedir: this.root }); | ||
// we can use globally shared babel runtime by default | ||
babel.plugins.push([ | ||
require.resolve('@babel/plugin-transform-runtime'), | ||
{ absoluteRuntime: __dirname, useESModules: true, regenerator: false }, | ||
]); | ||
return portable_babel_config_1.makePortable(babel, { basedir: this.root }, this.portableHints); | ||
} | ||
@@ -620,3 +625,3 @@ adjustImportsPlugin(engines) { | ||
let babelConfig = this.babelConfig(templateCompiler, appFiles); | ||
this.addTemplateCompiler(templateCompiler); | ||
let templateCompilerIsParallelSafe = this.addTemplateCompiler(templateCompiler); | ||
this.addBabelConfig(babelConfig); | ||
@@ -642,3 +647,3 @@ let assetPaths = assets.map(asset => asset.relativePath); | ||
filename: '_template_compiler_.js', | ||
isParallelSafe: templateCompiler.isParallelSafe, | ||
isParallelSafe: templateCompilerIsParallelSafe, | ||
}, | ||
@@ -678,3 +683,3 @@ babel: { | ||
} | ||
return new template_compiler_1.default({ | ||
return { | ||
plugins, | ||
@@ -684,12 +689,27 @@ compilerPath: resolve_1.default.sync(this.adapter.templateCompilerPath(), { basedir: this.root }), | ||
EmberENV: config, | ||
}; | ||
} | ||
get portableHints() { | ||
return this.options.pluginHints.map(hint => { | ||
let cursor = path_1.join(this.app.root, 'package.json'); | ||
for (let i = 0; i < hint.resolve.length; i++) { | ||
let target = hint.resolve[i]; | ||
if (i < hint.resolve.length - 1) { | ||
target = path_1.join(target, 'package.json'); | ||
} | ||
cursor = resolve_1.default.sync(target, { basedir: path_1.dirname(cursor) }); | ||
} | ||
return { requireFile: cursor, useMethod: hint.useMethod }; | ||
}); | ||
} | ||
addTemplateCompiler(templateCompiler) { | ||
fs_extra_1.writeFileSync(path_1.join(this.root, '_template_compiler_.js'), templateCompiler.serialize(), 'utf8'); | ||
addTemplateCompiler(params) { | ||
let mod = template_compiler_1.templateCompilerModule(params, this.portableHints); | ||
fs_extra_1.writeFileSync(path_1.join(this.root, '_template_compiler_.js'), mod.src, 'utf8'); | ||
return mod.isParallelSafe; | ||
} | ||
addBabelConfig(babelConfig) { | ||
if (!babelConfig.isParallelSafe) { | ||
addBabelConfig(pconfig) { | ||
if (!pconfig.isParallelSafe) { | ||
messages_1.warn('Your build is slower because some babel plugins are non-serializable'); | ||
} | ||
fs_extra_1.writeFileSync(path_1.join(this.root, '_babel_config_.js'), babelConfig.serialize(), 'utf8'); | ||
fs_extra_1.writeFileSync(path_1.join(this.root, '_babel_config_.js'), `module.exports = ${JSON.stringify(pconfig.config, null, 2)}`, 'utf8'); | ||
fs_extra_1.writeFileSync(path_1.join(this.root, '_babel_filter_.js'), babelFilterTemplate({ skipBabel: this.options.skipBabel }), 'utf8'); | ||
@@ -953,2 +973,5 @@ } | ||
typescript_memoize_1.Memoize() | ||
], AppBuilder.prototype, "portableHints", null); | ||
__decorate([ | ||
typescript_memoize_1.Memoize() | ||
], AppBuilder.prototype, "modulePrefix", null); | ||
@@ -955,0 +978,0 @@ exports.AppBuilder = AppBuilder; |
@@ -0,1 +1,18 @@ | ||
import { TemplateCompiler, TemplateCompilerParams } from './template-compiler'; | ||
import { ResolvedDep } from './resolver'; | ||
interface State { | ||
opts: { | ||
templateCompiler: TemplateCompilerParams; | ||
stage: 1 | 3; | ||
}; | ||
file: { | ||
code: string; | ||
opts: { | ||
filename: string; | ||
}; | ||
}; | ||
dependencies: Map<string, ResolvedDep>; | ||
templateCompiler: TemplateCompiler | undefined; | ||
} | ||
export declare type Params = State['opts']; | ||
declare function inlineHBSTransform(): unknown; | ||
@@ -2,0 +19,0 @@ declare namespace inlineHBSTransform { |
@@ -126,3 +126,3 @@ "use strict"; | ||
if (!state.templateCompiler) { | ||
state.templateCompiler = template_compiler_1.rehydrate(state.opts.templateCompiler); | ||
state.templateCompiler = new template_compiler_1.TemplateCompiler(state.opts.templateCompiler); | ||
} | ||
@@ -129,0 +129,0 @@ return state.templateCompiler; |
import { OutputPaths } from './wait-for-trees'; | ||
import PackageCache from './package-cache'; | ||
import Stage from './stage'; | ||
import { Tree } from 'broccoli-plugin'; | ||
import { Node } from 'broccoli-node-api'; | ||
export default class BuildStage<NamedTrees> implements Stage { | ||
@@ -14,3 +14,3 @@ private prevStage; | ||
constructor(prevStage: Stage, inTrees: NamedTrees, annotation: string, instantiate: (root: string, appSrcDir: string, packageCache: PackageCache) => Promise<BuilderInstance<NamedTrees>>); | ||
get tree(): Tree; | ||
get tree(): Node; | ||
get inputPath(): string; | ||
@@ -17,0 +17,0 @@ ready(): Promise<{ |
@@ -6,3 +6,3 @@ export { Packager, PackagerInstance, Variant, applyVariantToBabelConfig, applyVariantToTemplateCompiler, } from './packager'; | ||
export { default as Stage } from './stage'; | ||
export { default as TemplateCompiler, Plugins as TemplateCompilerPlugins } from './template-compiler'; | ||
export { TemplateCompiler, Plugins as TemplateCompilerPlugins, TemplateCompilerParams, templateCompilerModule, } from './template-compiler'; | ||
export { Asset, EmberAsset, ImplicitAssetPaths } from './asset'; | ||
@@ -9,0 +9,0 @@ export { default as Options, optionsWithDefaults } from './options'; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.mangledEngineRoot = exports.babelFilter = exports.extensionsPattern = exports.explicitRelative = exports.throwOnWarnings = exports.expectWarning = exports.debug = exports.warn = exports.unsupported = exports.todo = exports.AppBuilder = exports.jsHandlebarsCompile = exports.getOrCreate = exports.BuildStage = exports.WaitForTrees = exports.packageName = exports.PackageCache = exports.toBroccoliPlugin = exports.optionsWithDefaults = exports.TemplateCompiler = exports.Package = exports.applyVariantToTemplateCompiler = exports.applyVariantToBabelConfig = void 0; | ||
exports.mangledEngineRoot = exports.babelFilter = exports.extensionsPattern = exports.explicitRelative = exports.throwOnWarnings = exports.expectWarning = exports.debug = exports.warn = exports.unsupported = exports.todo = exports.AppBuilder = exports.jsHandlebarsCompile = exports.getOrCreate = exports.BuildStage = exports.WaitForTrees = exports.packageName = exports.PackageCache = exports.toBroccoliPlugin = exports.optionsWithDefaults = exports.templateCompilerModule = exports.TemplateCompiler = exports.Package = exports.applyVariantToTemplateCompiler = exports.applyVariantToBabelConfig = void 0; | ||
var packager_1 = require("./packager"); | ||
@@ -14,3 +14,4 @@ Object.defineProperty(exports, "applyVariantToBabelConfig", { enumerable: true, get: function () { return packager_1.applyVariantToBabelConfig; } }); | ||
var template_compiler_1 = require("./template-compiler"); | ||
Object.defineProperty(exports, "TemplateCompiler", { enumerable: true, get: function () { return __importDefault(template_compiler_1).default; } }); | ||
Object.defineProperty(exports, "TemplateCompiler", { enumerable: true, get: function () { return template_compiler_1.TemplateCompiler; } }); | ||
Object.defineProperty(exports, "templateCompilerModule", { enumerable: true, get: function () { return template_compiler_1.templateCompilerModule; } }); | ||
var options_1 = require("./options"); | ||
@@ -17,0 +18,0 @@ Object.defineProperty(exports, "optionsWithDefaults", { enumerable: true, get: function () { return options_1.optionsWithDefaults; } }); |
@@ -9,3 +9,7 @@ export default interface Options { | ||
}[]; | ||
pluginHints?: { | ||
resolve: string[]; | ||
useMethod?: string; | ||
}[]; | ||
} | ||
export declare function optionsWithDefaults(options?: Options): Required<Options>; |
@@ -13,2 +13,3 @@ "use strict"; | ||
skipBabel: [], | ||
pluginHints: [], | ||
}; | ||
@@ -15,0 +16,0 @@ if (options) { |
@@ -8,3 +8,3 @@ import Package from './package'; | ||
protected resolutionCache: Map<Package, Map<string, Package | null>>; | ||
protected basedir(pkg: Package): string; | ||
basedir(pkg: Package): string; | ||
get(packageRoot: string): Package; | ||
@@ -11,0 +11,0 @@ ownerOfFile(filename: string): Package | undefined; |
@@ -132,3 +132,3 @@ "use strict"; | ||
try { | ||
pkg = this.packageCache.get(path_1.join(this.root, path)); | ||
pkg = this.packageCache.get(path_1.join(this.packageCache.basedir(this), path)); | ||
} | ||
@@ -146,3 +146,3 @@ catch (err) { | ||
} | ||
let mainPath = path_1.join(this.root, path, main); | ||
let mainPath = path_1.join(this.packageCache.basedir(this), path, main); | ||
if (!fs_extra_1.existsSync(mainPath)) { | ||
@@ -149,0 +149,0 @@ // package has no valid main |
@@ -1,3 +0,3 @@ | ||
import { PortablePluginConfig } from './portable-plugin-config'; | ||
import { TransformOptions } from '@babel/core'; | ||
import { PortableHint } from './portable'; | ||
export declare type ResolveOptions = { | ||
@@ -8,8 +8,5 @@ basedir: string; | ||
}; | ||
export default class PortableBabelConfig extends PortablePluginConfig { | ||
private resolve; | ||
private basedir; | ||
constructor(config: TransformOptions, resolveOptions: ResolveOptions); | ||
protected makePortable(value: any, accessPath?: string[]): any; | ||
private resolveBabelPlugin; | ||
} | ||
export declare function makePortable(config: TransformOptions, resolveOptions: ResolveOptions, hints: PortableHint[]): { | ||
config: TransformOptions; | ||
isParallelSafe: boolean; | ||
}; |
@@ -6,7 +6,13 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const portable_plugin_config_1 = require("./portable-plugin-config"); | ||
exports.makePortable = void 0; | ||
const path_1 = require("path"); | ||
const resolve_1 = __importDefault(require("resolve")); | ||
class PortableBabelConfig extends portable_plugin_config_1.PortablePluginConfig { | ||
constructor(config, resolveOptions) { | ||
super(config); | ||
const portable_1 = require("./portable"); | ||
function makePortable(config, resolveOptions, hints) { | ||
return new PortableBabelConfig(resolveOptions, hints).convert(config); | ||
} | ||
exports.makePortable = makePortable; | ||
class PortableBabelConfig { | ||
constructor(resolveOptions, hints) { | ||
this.hints = hints; | ||
if ('resolve' in resolveOptions) { | ||
@@ -20,19 +26,63 @@ this.resolve = resolveOptions.resolve; | ||
} | ||
makePortable(value, accessPath = []) { | ||
if (accessPath.length === 2 && (accessPath[0] === 'plugins' || accessPath[0] === 'presets')) { | ||
if (typeof value === 'string') { | ||
return this.resolveBabelPlugin(value); | ||
} | ||
if (Array.isArray(value) && typeof value[0] === 'string') { | ||
let result = [this.resolveBabelPlugin(value[0])]; | ||
if (value.length > 1) { | ||
result.push(this.makePortable(value[1], accessPath.concat('1'))); | ||
convert(config) { | ||
let portable = new portable_1.Portable({ | ||
hints: this.hints, | ||
dehydrate: (value, accessPath) => { | ||
// this custom dehydrate hook handles babel plugins & presets. If we're | ||
// not looking at plugins or presets, continue with stock Portable | ||
// behavior | ||
if (accessPath.length !== 2 || (accessPath[0] !== 'plugins' && accessPath[0] !== 'presets')) { | ||
return undefined; | ||
} | ||
if (value.length > 2) { | ||
result.push(value[2]); | ||
// standardize to always handle an array | ||
if (!Array.isArray(value)) { | ||
value = [value]; | ||
} | ||
return result; | ||
} | ||
let [plugin, argument, asName] = value; | ||
// string plugins need to get resolved correctly into absolute paths, | ||
// so they will really be portable | ||
if (typeof plugin === 'string') { | ||
plugin = this.resolveBabelPlugin(plugin); | ||
} | ||
// next we deal with serializability. Our Portable system already | ||
// understands the protocol used by ember-cli-babel to identify plugin | ||
// classes and get back to their serializable forms, so this will | ||
// handle that case. | ||
let dehydrated = portable.dehydrate([plugin, argument, asName], accessPath.concat('_internal')); | ||
if (dehydrated.needsHydrate) { | ||
// we can eliminate the need for rehydration by going through our own | ||
// portable babel launcher | ||
return { | ||
value: [ | ||
path_1.join(__dirname, 'portable-babel-launcher.js'), | ||
{ module: dehydrated.value[0], arg: dehydrated.value[1], hints: this.hints }, | ||
dehydrated.value[2] || `portable-babel-launcher-${accessPath[1]}`, | ||
], | ||
needsHydrate: false, | ||
isParallelSafe: dehydrated.isParallelSafe, | ||
}; | ||
} | ||
else { | ||
// trim back down our array, because trailing undefined will get | ||
// converted into null via json.stringify, and babel will complain | ||
// about that. | ||
while (dehydrated.value[dehydrated.value.length - 1] == null) { | ||
dehydrated.value.pop(); | ||
} | ||
if (dehydrated.value.length === 1) { | ||
dehydrated.value = dehydrated.value[0]; | ||
} | ||
return { | ||
value: dehydrated.value, | ||
needsHydrate: dehydrated.needsHydrate, | ||
isParallelSafe: dehydrated.isParallelSafe, | ||
}; | ||
} | ||
}, | ||
}); | ||
let result = portable.dehydrate(config); | ||
if (result.needsHydrate) { | ||
throw new Error(`bug: portable babel configs aren't supposed to need hydration`); | ||
} | ||
return super.makePortable(value, accessPath); | ||
return { config: result.value, isParallelSafe: result.isParallelSafe }; | ||
} | ||
@@ -85,3 +135,2 @@ // babel lets you use relative paths, absolute paths, package names, and | ||
} | ||
exports.default = PortableBabelConfig; | ||
//# sourceMappingURL=portable-babel-config.js.map |
@@ -1,2 +0,2 @@ | ||
import TemplateCompiler from './template-compiler'; | ||
import { TemplateCompiler } from './template-compiler'; | ||
export interface ResolvedDep { | ||
@@ -10,3 +10,4 @@ runtimeName: string; | ||
dependenciesOf(moduleName: string): ResolvedDep[]; | ||
absPathToRuntimeName(absPath: string): string | undefined; | ||
absPathToRuntimePath(absPath: string): string; | ||
absPathToRuntimeName(absPath: string): string; | ||
} |
@@ -1,5 +0,5 @@ | ||
import { Tree } from 'broccoli-plugin'; | ||
import { Node } from 'broccoli-node-api'; | ||
import PackageCache from './package-cache'; | ||
export default interface Stage { | ||
readonly tree: Tree; | ||
readonly tree: Node; | ||
readonly inputPath: string; | ||
@@ -6,0 +6,0 @@ ready(): Promise<{ |
import { Resolver, ResolvedDep } from './resolver'; | ||
import { Tree } from 'broccoli-plugin'; | ||
import { Node } from 'broccoli-node-api'; | ||
import { PluginItem } from '@babel/core'; | ||
import { PortableHint } from './portable'; | ||
export interface Plugins { | ||
@@ -10,3 +11,7 @@ ast?: unknown[]; | ||
} | ||
interface SetupCompilerParams { | ||
export declare function templateCompilerModule(params: TemplateCompilerParams, hints: PortableHint[]): { | ||
src: string; | ||
isParallelSafe: boolean; | ||
}; | ||
export interface TemplateCompilerParams { | ||
compilerPath: string; | ||
@@ -17,17 +22,5 @@ resolver?: Resolver; | ||
} | ||
export declare function rehydrate(state: unknown): TemplateCompiler; | ||
export default class TemplateCompiler { | ||
private portableParams; | ||
private params; | ||
isParallelSafe: boolean; | ||
constructor(params: SetupCompilerParams); | ||
private get portableConfig(); | ||
get _parallelBabel(): { | ||
requireFile: string; | ||
buildUsing: string; | ||
params: { | ||
portableParams: object; | ||
}; | ||
} | undefined; | ||
serialize(): string; | ||
export declare class TemplateCompiler { | ||
params: TemplateCompilerParams; | ||
constructor(params: TemplateCompilerParams); | ||
private get syntax(); | ||
@@ -44,3 +37,3 @@ get cacheKey(): string; | ||
parse(moduleName: string, contents: string): AST; | ||
applyTransformsToTree(tree: Tree): Tree; | ||
applyTransformsToTree(tree: Node): Node; | ||
inlineTransformsBabelPlugin(): PluginItem; | ||
@@ -47,0 +40,0 @@ baseDir(): string; |
@@ -12,5 +12,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.rehydrate = void 0; | ||
exports.TemplateCompiler = exports.templateCompilerModule = void 0; | ||
const strip_bom_1 = __importDefault(require("strip-bom")); | ||
const portable_plugin_config_1 = require("./portable-plugin-config"); | ||
const fs_1 = require("fs"); | ||
@@ -20,3 +19,2 @@ const broccoli_persistent_filter_1 = __importDefault(require("broccoli-persistent-filter")); | ||
const crypto_1 = require("crypto"); | ||
const js_handlebars_1 = require("./js-handlebars"); | ||
const path_1 = require("path"); | ||
@@ -26,2 +24,3 @@ const typescript_memoize_1 = require("typescript-memoize"); | ||
const patch_template_compiler_1 = require("./patch-template-compiler"); | ||
const portable_1 = require("./portable"); | ||
const CACHE = new Map(); | ||
@@ -81,79 +80,23 @@ // Today the template compiler seems to not expose a public way to to source 2 source compilation of templates. | ||
} | ||
function rehydrate(state) { | ||
if (state instanceof TemplateCompiler && state.params) { | ||
return state; | ||
} | ||
if (state.portableParams) { | ||
return new TemplateCompiler(PortableTemplateCompilerConfig.load(state.portableParams)); | ||
} | ||
throw new Error(`unable to rehydrate TemplateCompiler ${state}`); | ||
function templateCompilerModule(params, hints) { | ||
let p = new portable_1.Portable({ hints }); | ||
let result = p.dehydrate(params); | ||
return { | ||
src: [ | ||
`const { TemplateCompiler } = require("${__filename}");`, | ||
`const { Portable } = require("${path_1.resolve(__dirname, './portable.js')}");`, | ||
`let p = new Portable({ hints: ${JSON.stringify(hints, null, 2)} });`, | ||
`module.exports = new TemplateCompiler(p.hydrate(${JSON.stringify(result.value, null, 2)}))`, | ||
].join('\n'), | ||
isParallelSafe: result.isParallelSafe, | ||
}; | ||
} | ||
exports.rehydrate = rehydrate; | ||
class PortableTemplateCompilerConfig extends portable_plugin_config_1.PortablePluginConfig { | ||
constructor(config) { | ||
super(config); | ||
this.here = __filename; | ||
} | ||
serialize() { | ||
return PortableTemplateCompilerConfig.template({ | ||
here: this.here, | ||
params: { portableParams: this.portable }, | ||
}); | ||
} | ||
} | ||
PortableTemplateCompilerConfig.template = js_handlebars_1.compile(` | ||
"use strict"; | ||
const { rehydrate } = require('{{{js-string-escape here}}}'); | ||
module.exports = rehydrate({{{json-stringify params 2 }}}); | ||
`); | ||
exports.templateCompilerModule = templateCompilerModule; | ||
class TemplateCompiler { | ||
constructor(params) { | ||
this.params = params; | ||
// stage3 packagers don't need to know about our instance, they can just | ||
// grab the compile function and use it. | ||
this.compile = this.compile.bind(this); | ||
// as a side effect of binding `this`, this.compile became enumerable. this | ||
// puts it back to non-enumerable, because it doesn't participate in | ||
// cloning, assigning, etc. | ||
Object.defineProperty(this, 'compile', { | ||
enumerable: false, | ||
}); | ||
Object.defineProperty(this, 'portableParams', { | ||
enumerable: true, | ||
get() { | ||
return this.portableConfig.portable; | ||
}, | ||
}); | ||
this.params = params; | ||
Object.defineProperty(this, 'params', { | ||
enumerable: false, | ||
}); | ||
Object.defineProperty(this, 'isParallelSafe', { | ||
enumerable: true, | ||
get() { | ||
return this.portableConfig.isParallelSafe; | ||
}, | ||
}); | ||
} | ||
get portableConfig() { | ||
return new PortableTemplateCompilerConfig(this.params); | ||
} | ||
// this supports the case where we are included as part of a larger config | ||
// that's getting serialized. Specifically, we are passed as an argument into | ||
// babel-plugin-inline-hbs, so when the whole babel config is being serialized | ||
// this gets detected by PortablePluginConfig so we can represent ourself. | ||
get _parallelBabel() { | ||
if (this.isParallelSafe) { | ||
return { | ||
requireFile: __filename, | ||
buildUsing: 'rehydrate', | ||
params: { portableParams: this.portableParams }, | ||
}; | ||
} | ||
} | ||
// this supports the case where we want to create a standalone executable | ||
// Javascript file that will re-create an equivalent TemplateCompiler | ||
// instance. | ||
serialize() { | ||
return this.portableConfig.serialize(); | ||
} | ||
get syntax() { | ||
@@ -163,11 +106,2 @@ return this.setup().syntax; | ||
get cacheKey() { | ||
// when we are inside a babel config, this can get called when we are in a | ||
// partially serialized state due to somebody cloning us, etc. | ||
// | ||
// The rest of our methods don't get called until after passing us through | ||
// `rehydrate`, but ember-cli-babel may call this directly and doesn't know | ||
// how to rehydrate us. | ||
if (!this.params) { | ||
this.params = PortableTemplateCompilerConfig.load(this.portableParams); | ||
} | ||
return this.setup().cacheKey; | ||
@@ -194,3 +128,3 @@ } | ||
if (this.params.resolver) { | ||
runtimeName = `${this.params.resolver.absPathToRuntimeName(moduleName)}${path_1.extname(moduleName)}` || moduleName; | ||
runtimeName = this.params.resolver.absPathToRuntimePath(moduleName); | ||
} | ||
@@ -253,3 +187,3 @@ else { | ||
opts.moduleName = this.params.resolver | ||
? this.params.resolver.absPathToRuntimeName(moduleName) || moduleName | ||
? this.params.resolver.absPathToRuntimePath(moduleName) || moduleName | ||
: moduleName; | ||
@@ -271,3 +205,9 @@ let ast = this.syntax.preprocess(contents, opts); | ||
inlineTransformsBabelPlugin() { | ||
return [path_1.join(__dirname, 'babel-plugin-inline-hbs.js'), { templateCompiler: this, stage: 1 }]; | ||
return [ | ||
path_1.join(__dirname, 'babel-plugin-inline-hbs.js'), | ||
{ | ||
templateCompiler: Object.assign({ cacheKey: this.cacheKey, baseDir: this.baseDir }, this.params), | ||
stage: 1, | ||
}, | ||
]; | ||
} | ||
@@ -298,5 +238,2 @@ baseDir() { | ||
typescript_memoize_1.Memoize() | ||
], TemplateCompiler.prototype, "portableConfig", null); | ||
__decorate([ | ||
typescript_memoize_1.Memoize() | ||
], TemplateCompiler.prototype, "setup", null); | ||
@@ -306,3 +243,3 @@ __decorate([ | ||
], TemplateCompiler.prototype, "getReversedASTPlugins", null); | ||
exports.default = TemplateCompiler; | ||
exports.TemplateCompiler = TemplateCompiler; | ||
class TemplateCompileTree extends broccoli_persistent_filter_1.default { | ||
@@ -309,0 +246,0 @@ constructor(inputTree, templateCompiler, stage) { |
@@ -1,2 +0,3 @@ | ||
import BroccoliPlugin, { Tree } from 'broccoli-plugin'; | ||
import BroccoliPlugin from 'broccoli-plugin'; | ||
import { Node } from 'broccoli-node-api'; | ||
export default class WaitForTrees<NamedTrees> extends BroccoliPlugin { | ||
@@ -6,8 +7,8 @@ private trees; | ||
constructor(trees: NamedTrees, annotation: string, buildHook: (trees: OutputPaths<NamedTrees>, changed: Map<string, boolean>) => Promise<void>); | ||
build(detail: { | ||
build(detail?: { | ||
changedNodes: boolean[]; | ||
} | undefined): Promise<void>; | ||
}): Promise<void>; | ||
} | ||
export declare type OutputPaths<NamedTrees> = { | ||
[P in keyof NamedTrees]: NamedTrees[P] extends Tree ? string : NamedTrees[P] extends Tree[] ? string[] : never; | ||
[P in keyof NamedTrees]: NamedTrees[P] extends Node ? string : NamedTrees[P] extends Node[] ? string[] : never; | ||
}; |
@@ -11,3 +11,3 @@ "use strict"; | ||
import { Tree } from 'broccoli-plugin'; | ||
import { Node } from 'broccoli-node-api';; | ||
@@ -19,3 +19,3 @@ interface MyInputs<T> { | ||
function(trees: MyInputs<Tree>): Tree { | ||
function(trees: MyInputs<Node>): Node { | ||
return WaitForTrees(trees, build); | ||
@@ -22,0 +22,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
312866
103
4597
32
20
+ Added@babel/runtime@^7.12.5
+ Addedbroccoli-node-api@^1.7.0
+ Added@babel/runtime@7.26.0(transitive)
+ Added@embroider/macros@0.32.0(transitive)
+ Addedasync-disk-cache@2.1.0(transitive)
+ Addedbroccoli-output-wrapper@3.2.5(transitive)
+ Addedbroccoli-persistent-filter@3.1.3(transitive)
+ Addedbroccoli-plugin@4.0.7(transitive)
+ Addedbroccoli-source@3.0.1(transitive)
+ Addededitions@2.3.1(transitive)
+ Addederrlop@2.2.0(transitive)
+ Addedistextorbinary@2.6.0(transitive)
+ Addedpromise-map-series@0.3.0(transitive)
+ Addedregenerator-runtime@0.14.1(transitive)
+ Addedsync-disk-cache@2.1.0(transitive)
- Removed@embroider/macros@0.31.0(transitive)
- Removedbroccoli-output-wrapper@2.0.0(transitive)
- Removedbroccoli-plugin@3.1.0(transitive)
- Removedbroccoli-source@1.1.0(transitive)
Updated@embroider/macros@0.32.0
Updatedbroccoli-plugin@^4.0.1
Updatedbroccoli-source@^3.0.0