@embroider/compat 4.0.4-unstable.ce3535d → 4.0.4
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.
|
@@ -118,7 +118,24 @@ class CompatAppBuilder {
|
|
|
118
118
|
}, { spaces: 2 });
|
|
119
119
|
}
|
|
120
120
|
addResolverConfig(config) {
|
|
121
|
-
|
|
121
|
+
var _a;
|
|
122
|
+
(0, fs_extra_1.outputJSONSync)((0, path_1.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'resolver.json'), {
|
|
123
|
+
...config,
|
|
124
|
+
splitAtRoutes: (_a = config.splitAtRoutes) === null || _a === void 0 ? void 0 : _a.map(s => {
|
|
125
|
+
if (typeof s === 'string') {
|
|
126
|
+
return {
|
|
127
|
+
type: 'string',
|
|
128
|
+
value: s,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
return {
|
|
133
|
+
type: 'regex',
|
|
134
|
+
value: s.toString(),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}),
|
|
138
|
+
}, { spaces: 2 });
|
|
122
139
|
}
|
|
123
140
|
addContentForConfig(contentForConfig) {
|
|
124
141
|
(0, fs_extra_1.outputJSONSync)((0, path_1.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'content-for.json'), contentForConfig, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compat-app-builder.js","sourceRoot":"","sources":["../../src/compat-app-builder.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,0CAA4D;AAG5D,yDAAwD;AACxD,uCAAsF;AAEtF,2DAAgF;AAChF,2DAA6C;AAC7C,+BAAqC;AACrC,sDAA8B;AAI9B,uCAAuC;AAIvC,qDAA0D;AAC1D,yFAAmF;AAGnF,8EAA8E;AAC9E,uDAAuD;AAEvD,MAAa,gBAAgB;IAC3B,YACU,cAAuB,EACvB,uBAAgC,EAChC,OAA0B,EAC1B,SA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AI,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;QAEpE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC;;;;;UAKZ,OAAO;;;;OAIV,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF;AAtMD,4CAsMC;AAjLC;IADC,IAAA,4BAAO,GAAE;sDAqBT;AAoBD;IADC,IAAA,4BAAO,GAAE;qDAkBT;AA0HH,SAAS,wBAAwB;IAC/B,OAAO,IAAA,sBAAW,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,wBAAwB,CAAC,CAAC;SAC1D,GAAG,CAAC,QAAQ,CAAC,EAAE;QACd,IAAI,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7B,iEAAiE;YACjE,OAAO,OAAO,CAAC,IAAA,WAAI,EAAC,SAAS,EAAE,wBAAwB,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC;QAC9E,CAAC;IACH,CAAC,CAAC;SACD,MAAM,CAAC,OAAO,CAAC;SACf,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import type { AddonPackage } from '@embroider/core';\nimport { locateEmbroiderWorkingDir } from '@embroider/core';\nimport type { CompatResolverOptions } from './resolver-transform';\nimport type { PackageRules } from './dependency-rules';\nimport { activePackageRules } from './dependency-rules';\nimport { outputJSONSync, readJSONSync, writeFileSync, writeJSONSync } from 'fs-extra';\nimport type { PortableHint } from '@embroider/core/src/portable';\nimport { maybeNodeModuleVersion, Portable } from '@embroider/core/src/portable';\nimport { Memoize } from 'typescript-memoize';\nimport { join, dirname } from 'path';\nimport resolve from 'resolve';\nimport type ContentForConfig from './content-for-config';\nimport type { V1Config } from './v1-config';\nimport type { Package } from '@embroider/core';\nimport { readdirSync } from 'fs-extra';\n\nimport type CompatApp from './compat-app';\nimport type { CompatBabelState } from './babel';\nimport { MacrosConfig } from '@embroider/macros/src/node';\nimport { buildResolverOptions } from '@embroider/core/src/module-resolver-options';\nimport type { CompatOptionsType } from './options';\n\n// This exists during the actual broccoli build step. As opposed to CompatApp,\n// which also exists during pipeline-construction time.\n\nexport class CompatAppBuilder {\n constructor(\n private origAppPackage: Package,\n private appPackageWithMovedDeps: Package,\n private options: CompatOptionsType,\n private compatApp: CompatApp,\n private configTree: V1Config,\n private contentForTree: ContentForConfig,\n private synthVendor: Package,\n private synthStyles: Package\n ) {}\n\n private modulePrefix(): string {\n return this.configTree.readConfig().modulePrefix;\n }\n\n private podModulePrefix(): string | undefined {\n return this.configTree.readConfig().podModulePrefix;\n }\n\n @Memoize()\n private get resolverConfig(): CompatResolverOptions {\n return buildResolverOptions({\n appPackage: this.appPackageWithMovedDeps,\n modulePrefix: this.modulePrefix(),\n podModulePrefix: this.podModulePrefix(),\n splitAtRoutes: this.options.splitAtRoutes,\n staticAppPaths: this.options.staticAppPaths,\n extraDeps: new Map([[this.appPackageWithMovedDeps.root, [this.synthVendor, this.synthStyles] as AddonPackage[]]]),\n extend: (options: CompatResolverOptions, allActiveAddons) => {\n options.activePackageRules = activePackageRules(this.options.packageRules.concat(defaultAddonPackageRules()), [\n { name: this.origAppPackage.name, version: this.origAppPackage.version, root: this.origAppPackage.root },\n ...allActiveAddons.filter(p => p.meta['auto-upgraded']),\n ]);\n options.options = {\n staticInvokables: this.options.staticInvokables,\n allowUnsafeDynamicComponents: this.options.allowUnsafeDynamicComponents,\n };\n return options;\n },\n });\n }\n\n async build() {\n // on the first build, we lock down the macros config. on subsequent builds,\n // this doesn't do anything anyway because it's idempotent.\n this.compatApp.macrosConfig.finalize();\n\n let resolverConfig = this.resolverConfig;\n let config = this.configTree.readConfig();\n let contentForConfig = this.contentForTree.readContents();\n\n this.addResolverConfig(resolverConfig);\n this.addContentForConfig(contentForConfig);\n this.addEmberEnvConfig(config.EmberENV);\n this.outputAppBootError(config.modulePrefix, config.APP, contentForConfig);\n this.addBabelCompat();\n this.addVersionMarker();\n }\n\n @Memoize()\n private get portableHints(): PortableHint[] {\n return this.options.pluginHints.map(hint => {\n let cursor = join(this.origAppPackage.root, 'package.json');\n for (let i = 0; i < hint.resolve.length; i++) {\n let target = hint.resolve[i];\n if (i < hint.resolve.length - 1) {\n target = join(target, 'package.json');\n }\n cursor = resolve.sync(target, { basedir: dirname(cursor) });\n }\n\n return {\n requireFile: cursor,\n useMethod: hint.useMethod,\n packageVersion: maybeNodeModuleVersion(cursor),\n };\n });\n }\n\n private addBabelCompat() {\n let plugins = this.compatApp.extraBabelPlugins();\n let templateTransforms = this.compatApp.htmlbarsPlugins;\n let babelMacros = this.compatApp.macrosConfig.babelPluginConfig();\n let { plugins: templateMacros, setConfig } = MacrosConfig.transforms();\n setConfig(this.compatApp.macrosConfig);\n\n let config: CompatBabelState = {\n plugins,\n templateTransforms,\n babelMacros,\n templateMacros: templateMacros as any,\n };\n\n let portableConfig = new Portable({ hints: this.portableHints }).dehydrate(config);\n if (!portableConfig.isParallelSafe) {\n throw new Error(`non-serializble babel plugins or AST transforms found in your app`);\n }\n\n writeFileSync(\n join(locateEmbroiderWorkingDir(this.compatApp.root), '_babel_compat_.js'),\n `\n const { Portable } = require('@embroider/core/src/portable');\n module.exports = new Portable().hydrate(${JSON.stringify(portableConfig.value, null, 2)});\n `,\n 'utf8'\n );\n }\n\n private addVersionMarker() {\n writeJSONSync(\n join(locateEmbroiderWorkingDir(this.compatApp.root), 'version.json'),\n {\n '@embroider/core': readJSONSync(require.resolve('@embroider/core/package.json')).version,\n },\n { spaces: 2 }\n );\n }\n\n private addResolverConfig(config: CompatResolverOptions) {\n outputJSONSync(join(locateEmbroiderWorkingDir(this.compatApp.root), 'resolver.json'), config, { spaces: 2 });\n }\n\n private addContentForConfig(contentForConfig: any) {\n outputJSONSync(join(locateEmbroiderWorkingDir(this.compatApp.root), 'content-for.json'), contentForConfig, {\n spaces: 2,\n });\n\n // In addition to outputting content-for.json, we also want to check if content-for 'config-module' has a custom content.\n // If so, it means some classic addons used to provide this custom content, which is no longer supported.\n // Developers can deactivate this check (and the subsequent warning) with useAddonConfigModule\n if (this.compatApp.options.useAddonConfigModule) {\n let modulePrefix = this.configTree.readConfig().modulePrefix;\n\n // This is the default script provided by https://github.com/ember-cli/ember-cli/blob/master/lib/utilities/ember-app-utils.js#L84\n // When storeConfigInMeta is true, this content is always present in the config-module key of content-for.json\n const defaultConfigModule =\n `var prefix = '${modulePrefix}';\\ntry {\\n var metaName = prefix + '/config/environment';\\n var rawConfig = document.querySelector('meta[name=\\\"' + metaName + '\\\"]').getAttribute('content');\\n var config = JSON.parse(decodeURIComponent(rawConfig));\\n\\n var exports = { 'default': config };\\n\\n Object.defineProperty(exports, '__esModule', { value: true });\\n\\n return exports;\\n}\\ncatch(err) {\\n throw new Error('Could not read config from meta tag with name \\\"' + metaName + '\\\".');\\n}\\n`.replace(\n /\\s/g,\n ''\n );\n\n const configModule = contentForConfig['/index.html']['config-module'];\n const diff = configModule.replace(/\\s/g, '').replace(defaultConfigModule, '');\n\n if (diff.length) {\n throw new Error(`\n Your app uses at least one classic addon that provides content-for 'config-module'. This is no longer supported.\n With Embroider, you have full control over the config module, so classic addons no longer need to modify it under the hood.\n The following code is included via content-for 'config-module':\n\n ${configModule}\n\n 1. If you want to keep the same behavior, add it to the app/environment.js.\n 2. Once app/environment.js has the content you need, remove the present error by setting \"useAddonConfigModule\" to false in the build options.\n `);\n }\n }\n }\n\n private addEmberEnvConfig(emberEnvConfig: any) {\n outputJSONSync(join(locateEmbroiderWorkingDir(this.compatApp.root), 'ember-env.json'), emberEnvConfig, {\n spaces: 2,\n });\n }\n\n // Classic addons providing custom content-for \"app-boot\" is no longer supported.\n // The purpose of this error message is to help developers to move the classic addons code.\n // Developers can deactivate it with useAddonAppBoot build option.\n private outputAppBootError(modulePrefix: string, appConfig: any, contentForConfig: any) {\n if (!this.compatApp.options.useAddonAppBoot) {\n return;\n }\n\n // This is the default script provided by\n // https://github.com/ember-cli/ember-cli/blob/master/lib/utilities/ember-app-utils.js#L103\n const defaultAppBoot = `\n if (!runningTests) {\n require(\"${modulePrefix}/app\")[\"default\"].create(${JSON.stringify(appConfig || {})});\n }\n `.replace(/\\s/g, '');\n\n const appBoot = contentForConfig['/index.html']['app-boot'];\n const diff = appBoot.replace(/\\s/g, '').replace(defaultAppBoot, '');\n\n if (diff.length) {\n throw new Error(`\n Your app uses at least one classic addon that provides content-for 'app-boot'. This is no longer supported.\n With Embroider, you have full control over the app-boot script, so classic addons no longer need to modify it under the hood.\n The following code is used for your app boot:\n\n ${appBoot}\n\n 1. If you want to keep the same behavior, copy and paste it to the app-boot script included in app/index.html.\n 2. Once app/index.html has the content you need, remove the present error by setting \"useAddonAppBoot\" to false in the build options.\n `);\n }\n }\n}\n\nfunction defaultAddonPackageRules(): PackageRules[] {\n return readdirSync(join(__dirname, 'addon-dependency-rules'))\n .map(filename => {\n if (filename.endsWith('.js')) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n return require(join(__dirname, 'addon-dependency-rules', filename)).default;\n }\n })\n .filter(Boolean)\n .reduce((a, b) => a.concat(b), []);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"compat-app-builder.js","sourceRoot":"","sources":["../../src/compat-app-builder.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,0CAA4D;AAG5D,yDAAwD;AACxD,uCAAsF;AAEtF,2DAAgF;AAChF,2DAA6C;AAC7C,+BAAqC;AACrC,sDAA8B;AAI9B,uCAAuC;AAIvC,qDAA0D;AAC1D,yFAAmF;AAGnF,8EAA8E;AAC9E,uDAAuD;AAEvD,MAAa,gBAAgB;IAC3B,YACU,cAAuB,EACvB,uBAAgC,EAChC,OAA0B,EAC1B,SAAoB,EACpB,UAAoB,EACpB,cAAgC,EAChC,WAAoB,EACpB,WAAoB;QAP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port type { CompatResolverOptions } from './resolver-transform';\nimport type { PackageRules } from './dependency-rules';\nimport { activePackageRules } from './dependency-rules';\nimport { outputJSONSync, readJSONSync, writeFileSync, writeJSONSync } from 'fs-extra';\nimport type { PortableHint } from '@embroider/core/src/portable';\nimport { maybeNodeModuleVersion, Portable } from '@embroider/core/src/portable';\nimport { Memoize } from 'typescript-memoize';\nimport { join, dirname } from 'path';\nimport resolve from 'resolve';\nimport type ContentForConfig from './content-for-config';\nimport type { V1Config } from './v1-config';\nimport type { Package } from '@embroider/core';\nimport { readdirSync } from 'fs-extra';\n\nimport type CompatApp from './compat-app';\nimport type { CompatBabelState } from './babel';\nimport { MacrosConfig } from '@embroider/macros/src/node';\nimport { buildResolverOptions } from '@embroider/core/src/module-resolver-options';\nimport type { CompatOptionsType } from './options';\n\n// This exists during the actual broccoli build step. As opposed to CompatApp,\n// which also exists during pipeline-construction time.\n\nexport class CompatAppBuilder {\n constructor(\n private origAppPackage: Package,\n private appPackageWithMovedDeps: Package,\n private options: CompatOptionsType,\n private compatApp: CompatApp,\n private configTree: V1Config,\n private contentForTree: ContentForConfig,\n private synthVendor: Package,\n private synthStyles: Package\n ) {}\n\n private modulePrefix(): string {\n return this.configTree.readConfig().modulePrefix;\n }\n\n private podModulePrefix(): string | undefined {\n return this.configTree.readConfig().podModulePrefix;\n }\n\n @Memoize()\n private get resolverConfig(): CompatResolverOptions {\n return buildResolverOptions({\n appPackage: this.appPackageWithMovedDeps,\n modulePrefix: this.modulePrefix(),\n podModulePrefix: this.podModulePrefix(),\n splitAtRoutes: this.options.splitAtRoutes,\n staticAppPaths: this.options.staticAppPaths,\n extraDeps: new Map([[this.appPackageWithMovedDeps.root, [this.synthVendor, this.synthStyles] as AddonPackage[]]]),\n extend: (options: CompatResolverOptions, allActiveAddons) => {\n options.activePackageRules = activePackageRules(this.options.packageRules.concat(defaultAddonPackageRules()), [\n { name: this.origAppPackage.name, version: this.origAppPackage.version, root: this.origAppPackage.root },\n ...allActiveAddons.filter(p => p.meta['auto-upgraded']),\n ]);\n options.options = {\n staticInvokables: this.options.staticInvokables,\n allowUnsafeDynamicComponents: this.options.allowUnsafeDynamicComponents,\n };\n return options;\n },\n });\n }\n\n async build() {\n // on the first build, we lock down the macros config. on subsequent builds,\n // this doesn't do anything anyway because it's idempotent.\n this.compatApp.macrosConfig.finalize();\n\n let resolverConfig = this.resolverConfig;\n let config = this.configTree.readConfig();\n let contentForConfig = this.contentForTree.readContents();\n\n this.addResolverConfig(resolverConfig);\n this.addContentForConfig(contentForConfig);\n this.addEmberEnvConfig(config.EmberENV);\n this.outputAppBootError(config.modulePrefix, config.APP, contentForConfig);\n this.addBabelCompat();\n this.addVersionMarker();\n }\n\n @Memoize()\n private get portableHints(): PortableHint[] {\n return this.options.pluginHints.map(hint => {\n let cursor = join(this.origAppPackage.root, 'package.json');\n for (let i = 0; i < hint.resolve.length; i++) {\n let target = hint.resolve[i];\n if (i < hint.resolve.length - 1) {\n target = join(target, 'package.json');\n }\n cursor = resolve.sync(target, { basedir: dirname(cursor) });\n }\n\n return {\n requireFile: cursor,\n useMethod: hint.useMethod,\n packageVersion: maybeNodeModuleVersion(cursor),\n };\n });\n }\n\n private addBabelCompat() {\n let plugins = this.compatApp.extraBabelPlugins();\n let templateTransforms = this.compatApp.htmlbarsPlugins;\n let babelMacros = this.compatApp.macrosConfig.babelPluginConfig();\n let { plugins: templateMacros, setConfig } = MacrosConfig.transforms();\n setConfig(this.compatApp.macrosConfig);\n\n let config: CompatBabelState = {\n plugins,\n templateTransforms,\n babelMacros,\n templateMacros: templateMacros as any,\n };\n\n let portableConfig = new Portable({ hints: this.portableHints }).dehydrate(config);\n if (!portableConfig.isParallelSafe) {\n throw new Error(`non-serializble babel plugins or AST transforms found in your app`);\n }\n\n writeFileSync(\n join(locateEmbroiderWorkingDir(this.compatApp.root), '_babel_compat_.js'),\n `\n const { Portable } = require('@embroider/core/src/portable');\n module.exports = new Portable().hydrate(${JSON.stringify(portableConfig.value, null, 2)});\n `,\n 'utf8'\n );\n }\n\n private addVersionMarker() {\n writeJSONSync(\n join(locateEmbroiderWorkingDir(this.compatApp.root), 'version.json'),\n {\n '@embroider/core': readJSONSync(require.resolve('@embroider/core/package.json')).version,\n },\n { spaces: 2 }\n );\n }\n\n private addResolverConfig(config: CompatResolverOptions) {\n outputJSONSync(\n join(locateEmbroiderWorkingDir(this.compatApp.root), 'resolver.json'),\n {\n ...config,\n splitAtRoutes: config.splitAtRoutes?.map(s => {\n if (typeof s === 'string') {\n return {\n type: 'string',\n value: s,\n };\n } else {\n return {\n type: 'regex',\n value: s.toString(),\n };\n }\n }),\n },\n { spaces: 2 }\n );\n }\n\n private addContentForConfig(contentForConfig: any) {\n outputJSONSync(join(locateEmbroiderWorkingDir(this.compatApp.root), 'content-for.json'), contentForConfig, {\n spaces: 2,\n });\n\n // In addition to outputting content-for.json, we also want to check if content-for 'config-module' has a custom content.\n // If so, it means some classic addons used to provide this custom content, which is no longer supported.\n // Developers can deactivate this check (and the subsequent warning) with useAddonConfigModule\n if (this.compatApp.options.useAddonConfigModule) {\n let modulePrefix = this.configTree.readConfig().modulePrefix;\n\n // This is the default script provided by https://github.com/ember-cli/ember-cli/blob/master/lib/utilities/ember-app-utils.js#L84\n // When storeConfigInMeta is true, this content is always present in the config-module key of content-for.json\n const defaultConfigModule =\n `var prefix = '${modulePrefix}';\\ntry {\\n var metaName = prefix + '/config/environment';\\n var rawConfig = document.querySelector('meta[name=\\\"' + metaName + '\\\"]').getAttribute('content');\\n var config = JSON.parse(decodeURIComponent(rawConfig));\\n\\n var exports = { 'default': config };\\n\\n Object.defineProperty(exports, '__esModule', { value: true });\\n\\n return exports;\\n}\\ncatch(err) {\\n throw new Error('Could not read config from meta tag with name \\\"' + metaName + '\\\".');\\n}\\n`.replace(\n /\\s/g,\n ''\n );\n\n const configModule = contentForConfig['/index.html']['config-module'];\n const diff = configModule.replace(/\\s/g, '').replace(defaultConfigModule, '');\n\n if (diff.length) {\n throw new Error(`\n Your app uses at least one classic addon that provides content-for 'config-module'. This is no longer supported.\n With Embroider, you have full control over the config module, so classic addons no longer need to modify it under the hood.\n The following code is included via content-for 'config-module':\n\n ${configModule}\n\n 1. If you want to keep the same behavior, add it to the app/environment.js.\n 2. Once app/environment.js has the content you need, remove the present error by setting \"useAddonConfigModule\" to false in the build options.\n `);\n }\n }\n }\n\n private addEmberEnvConfig(emberEnvConfig: any) {\n outputJSONSync(join(locateEmbroiderWorkingDir(this.compatApp.root), 'ember-env.json'), emberEnvConfig, {\n spaces: 2,\n });\n }\n\n // Classic addons providing custom content-for \"app-boot\" is no longer supported.\n // The purpose of this error message is to help developers to move the classic addons code.\n // Developers can deactivate it with useAddonAppBoot build option.\n private outputAppBootError(modulePrefix: string, appConfig: any, contentForConfig: any) {\n if (!this.compatApp.options.useAddonAppBoot) {\n return;\n }\n\n // This is the default script provided by\n // https://github.com/ember-cli/ember-cli/blob/master/lib/utilities/ember-app-utils.js#L103\n const defaultAppBoot = `\n if (!runningTests) {\n require(\"${modulePrefix}/app\")[\"default\"].create(${JSON.stringify(appConfig || {})});\n }\n `.replace(/\\s/g, '');\n\n const appBoot = contentForConfig['/index.html']['app-boot'];\n const diff = appBoot.replace(/\\s/g, '').replace(defaultAppBoot, '');\n\n if (diff.length) {\n throw new Error(`\n Your app uses at least one classic addon that provides content-for 'app-boot'. This is no longer supported.\n With Embroider, you have full control over the app-boot script, so classic addons no longer need to modify it under the hood.\n The following code is used for your app boot:\n\n ${appBoot}\n\n 1. If you want to keep the same behavior, copy and paste it to the app-boot script included in app/index.html.\n 2. Once app/index.html has the content you need, remove the present error by setting \"useAddonAppBoot\" to false in the build options.\n `);\n }\n }\n}\n\nfunction defaultAddonPackageRules(): PackageRules[] {\n return readdirSync(join(__dirname, 'addon-dependency-rules'))\n .map(filename => {\n if (filename.endsWith('.js')) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n return require(join(__dirname, 'addon-dependency-rules', filename)).default;\n }\n })\n .filter(Boolean)\n .reduce((a, b) => a.concat(b), []);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embroider/compat",
|
|
3
|
-
"version": "4.0.4
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Backward compatibility layer for the Embroider build system.",
|
|
6
6
|
"repository": {
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"tree-sync": "^2.1.0",
|
|
64
64
|
"typescript-memoize": "^1.0.1",
|
|
65
65
|
"walk-sync": "^3.0.0",
|
|
66
|
-
"@embroider/macros": "1.17.
|
|
66
|
+
"@embroider/macros": "1.17.3"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@glimmer/syntax": "^0.94.9",
|
|
@@ -86,12 +86,12 @@
|
|
|
86
86
|
"ember-engines": "^0.8.19",
|
|
87
87
|
"scenario-tester": "^4.0.0",
|
|
88
88
|
"typescript": "^5.4.5",
|
|
89
|
-
"@embroider/core": "^4.0.4
|
|
90
|
-
"@embroider/
|
|
91
|
-
"@embroider/
|
|
89
|
+
"@embroider/core": "^4.0.4",
|
|
90
|
+
"@embroider/sample-transforms": "0.0.0",
|
|
91
|
+
"@embroider/test-support": "0.36.0"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
|
-
"@embroider/core": "^4.0.4
|
|
94
|
+
"@embroider/core": "^4.0.4"
|
|
95
95
|
},
|
|
96
96
|
"engines": {
|
|
97
97
|
"node": "12.* || 14.* || >= 16"
|