@embroider/compat 2.1.0 → 2.1.1-unstable.21eae41
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 +5 -4
- package/src/addon-dependency-rules/ember-data.js +1 -0
- package/src/addon-dependency-rules/ember-data.js.map +1 -1
- package/src/audit/build.js +48 -46
- package/src/audit/build.js.map +1 -1
- package/src/audit/options.d.ts +3 -2
- package/src/audit/options.js.map +1 -1
- package/src/audit-cli.js +0 -0
- package/src/audit.d.ts +25 -1
- package/src/audit.js +51 -32
- package/src/audit.js.map +1 -1
- package/src/babel-plugin-adjust-imports.d.ts +16 -0
- package/src/babel-plugin-adjust-imports.js +131 -0
- package/src/babel-plugin-adjust-imports.js.map +1 -0
- package/src/compat-adapters/ember-data.d.ts +1 -0
- package/src/compat-adapters/ember-data.js +4 -0
- package/src/compat-adapters/ember-data.js.map +1 -1
- package/src/compat-app.js +47 -76
- package/src/compat-app.js.map +1 -1
- package/src/dependency-rules.d.ts +5 -7
- package/src/dependency-rules.js +8 -40
- package/src/dependency-rules.js.map +1 -1
- package/src/resolver-transform.d.ts +11 -4
- package/src/resolver-transform.js +707 -322
- package/src/resolver-transform.js.map +1 -1
- package/src/v1-app.js +18 -4
- package/src/v1-app.js.map +1 -1
- package/src/audit/capture.d.ts +0 -8
- package/src/audit/capture.js +0 -45
- package/src/audit/capture.js.map +0 -1
- package/src/resolver.d.ts +0 -128
- package/src/resolver.js +0 -677
- package/src/resolver.js.map +0 -1
- package/src/template-compiler-broccoli-plugin.d.ts +0 -10
- package/src/template-compiler-broccoli-plugin.js +0 -28
- package/src/template-compiler-broccoli-plugin.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependency-rules.js","sourceRoot":"","sources":["dependency-rules.ts"],"names":[],"mappings":";;;AAAA,0CAAyE;AACzE,mCAAmC;AAEnC,+BAA+B;AA8J/B,6EAA6E;AAC7E,kCAAkC;AAClC,SAAgB,uB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EAAE,CAAC,CAAC;aAC7G;YACD,MAAM,CAAC,IAAI,CAAC;gBACV,OAAO;gBACP,MAAM,EAAE,IAAA,uBAAgB,EAAC,IAAA,cAAO,EAAC,OAAO,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC;gBACzD,WAAW,EAAE,KAAK,CAAC,WAAW;aAC/B,CAAC,CAAC;SACJ;KACF;IACD,IAAI,WAAW,CAAC,mBAAmB,EAAE;QACnC,KAAK,IAAI,OAAO,IAAI,WAAW,CAAC,mBAAmB,EAAE;YACnD,IAAI,KAAK,GAAG,QAAQ,CAAC,uBAAuB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YACnE,IAAI,KAAK,CAAC,QAAQ,EAAE;gBAClB,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC;gBACtD,MAAM,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAA,uBAAgB,EAAC,IAAA,cAAO,EAAC,OAAO,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;aAC3F;YACD,IAAI,KAAK,CAAC,SAAS,EAAE;gBACnB,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC;gBACvD,MAAM,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAA,uBAAgB,EAAC,IAAA,cAAO,EAAC,OAAO,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;aAC3F;SACF;KACF;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AA7BD,8CA6BC","sourcesContent":["import { Package, explicitRelative, getOrCreate } from '@embroider/core';\nimport { satisfies } from 'semver';\nimport CompatResolver from './resolver';\nimport { dirname } from 'path';\n\nexport interface PackageRules {\n // This whole set of rules will only apply when the given addon package\n // matching the given semver range is present and active.\n package: string;\n semverRange?: string;\n\n components?: {\n // I would prefer to write the key type here as `ComponentSnippet` to aid\n // documentation, but Typescript won't allow it. See ComponentSnippet below.\n [key: string]: ComponentRules;\n };\n\n addonModules?: {\n // `filename` is relative to your package root, and it assumes v2 package\n // format. Like \"templates/components/foo.hbs\".\n [filename: string]: ModuleRules;\n };\n\n appModules?: {\n // `filename` is relative to the app's root, and it assumes v2 package\n // format. Like \"templates/components/foo.hbs\".\n [filename: string]: ModuleRules;\n };\n\n addonTemplates?: {\n // `filename` is relative to your package root, and it assumes v2 package\n // format. Like \"templates/foo.hbs\".\n [filename: string]: TemplateRules;\n };\n\n appTemplates?: {\n // `filename` is relative to the app's root, and it assumes v2 package\n // format. Like \"templates/foo.hbs\".\n [filename: string]: TemplateRules;\n };\n}\n\nexport interface ActivePackageRules extends PackageRules {\n // the location(s) of active packages that match this rule.\n roots: string[];\n}\n\nexport interface TemplateRules {\n // Tells embroider which list of components may be needed for a given path.\n // For example, if your template says `{{component this.panel}}` and you know\n // that `this.panel` can be either \"light-panel\" or \"dark-panel\", you would\n // say: `invokes: { \"this.panel\": [\"<LightPanel/>\", \"<DarkPanel/>\"] }`\n invokes?: {\n [path: string]: ComponentSnippet[];\n };\n}\n\nexport interface ComponentRules extends TemplateRules {\n // This declares that our component yields other components that are safe to\n // invoke with the {{component}} helper.\n //\n // The array corresponds to your yielded positional arguments. Any value that\n // is true is considered a safe component. Any value can be a hash in which\n // individual keys that are true are considered safe components.\n //\n // Examples:\n //\n // If you do: {{yield (component \"x\") }}\n // Then say: yieldsSafeComponents: [true]\n //\n // If you do: {{yield (hash x=(component \"x\") y=(component \"y\")) }}\n // Then say: yieldsSafeComponents: [{x: true, y: true}]\n //\n yieldsSafeComponents?: (boolean | { [name: string]: boolean })[];\n\n // This declares that our component yields some of its arguments unchanged.\n //\n // The array corresponds to your yielded positional arguments. Each value can\n // be:\n // false, meaning this yielded value is not one of our arguments\n // a string, meaning this yielded value is our argument with that name\n // or a POJO, whose individual properties are string naming which arguments\n // from whence they came.\n //\n // Examples:\n //\n // If you do: {{yield @foo}}\n // Then say: yieldsArguments: ['foo']\n //\n // If you do: {{yield (hash x=@foo) }}\n // Then say: yieldsArguments: [{ x: 'foo' }]\n yieldsArguments?: (string | { [name: string]: string })[];\n\n // This declares that our component accepts arguments that will be invoked\n // with the {{component}} helper. This silences warnings in the places where\n // we consume them, while introducing warnings in the places where people are\n // passing them to us (if they are doing so in a way that is too dynamic to\n // analyze).\n //\n // If you use this, you may also need to set `layout`, see below.\n acceptsComponentArguments?: ArgumentMapping[];\n\n // If you want to use `acceptsComponentArguments` on a component that\n // customies its own `layout` (which is most addon-provided components), you\n // need to tell us here how to find its template by setting either `addonPath`\n // or `appPath`.\n layout?: {\n // This is a path relative to the addon root, assuming V2 format.\n addonPath?: string;\n // This is the path relative to the app root, assuming V2 format.\n appPath?: string;\n };\n\n // An unresolvable component is usually a build error (when your app has the\n // staticComponent Option enabled). But you can tell Embroider to ignore it by\n // setting this.\n safeToIgnore?: boolean;\n}\n\nexport interface ModuleRules {\n // We will resolve these components into the corresponding JS and HBS files\n // and generate imports such that this module depends on them.\n dependsOnComponents?: ComponentSnippet[];\n\n // This adds new imports to our module, as if they were really there. Helpful\n // for working around addons that depend on things but don't say so.\n dependsOnModules?: string[];\n}\n\n// The bare \"string\" short form implies that `becomes` is the same as `name`.\nexport type ArgumentMapping =\n | string\n | {\n // the name of the argument you accept\n name: string;\n // the name its consumed as in your template\n becomes: string;\n };\n\n// A component snippet is a string containing valid HBS that is a single\n// component invocation. We use it to refer to components in a way that doesn't\n// require any new syntax or rules, and that's necessarily supported by whatever\n// build-time template resolver is in use.\n//\n// Examples of valid ComponentSnippets:\n//\n// \"{{my-component}}\"\n// \"{{my-component/foo}}\"\n// \"<MyComponent />\"\n// \"{{component 'my-component'}}\"\n//\ntype ComponentSnippet = string;\n\nexport interface PreprocessedComponentRule {\n yieldsSafeComponents: Required<ComponentRules>['yieldsSafeComponents'];\n yieldsArguments: Required<ComponentRules>['yieldsArguments'];\n dependsOnComponents: ComponentSnippet[];\n argumentsAreComponents: string[];\n safeInteriorPaths: string[];\n}\n\n// take a component rule from the authoring format to a format more optimized\n// for consumption in the resolver\nexport function preprocessComponentRule(componentRules: ComponentRules): PreprocessedComponentRule {\n let argumentsAreComponents = [];\n let safeInteriorPaths = [];\n let dependsOnComponents = [];\n if (componentRules.acceptsComponentArguments) {\n for (let entry of componentRules.acceptsComponentArguments) {\n let name, interior;\n if (typeof entry === 'string') {\n name = interior = entry;\n } else {\n name = entry.name;\n interior = entry.becomes;\n }\n if (name.startsWith('@')) {\n name = name.slice(1);\n }\n argumentsAreComponents.push(name);\n safeInteriorPaths.push(interior);\n }\n }\n if (componentRules.invokes) {\n for (let [path, snippets] of Object.entries(componentRules.invokes)) {\n safeInteriorPaths.push(path);\n for (let snippet of snippets) {\n dependsOnComponents.push(snippet);\n }\n }\n }\n return {\n argumentsAreComponents,\n safeInteriorPaths,\n dependsOnComponents,\n yieldsSafeComponents: componentRules.yieldsSafeComponents || [],\n yieldsArguments: componentRules.yieldsArguments || [],\n };\n}\n\nexport function activePackageRules(packageRules: PackageRules[], activePackages: Package[]): ActivePackageRules[] {\n // rule order implies precedence. The first rule that matches a given package\n // applies to that package, and no other rule does.\n let rootsPerRule = new Map();\n for (let pkg of activePackages) {\n for (let rule of packageRules) {\n if (rule.package === pkg.name && (!rule.semverRange || satisfies(pkg.version, rule.semverRange))) {\n let roots = getOrCreate(rootsPerRule, rule, () => []);\n roots.push(pkg.root);\n break;\n }\n }\n }\n let output = [];\n for (let [rule, roots] of rootsPerRule) {\n output.push(Object.assign({ roots }, rule));\n }\n return output;\n}\n\nexport function expandModuleRules(absPath: string, moduleRules: ModuleRules, resolver: CompatResolver) {\n let output: { absPath: string; target: string; runtimeName: string }[] = [];\n if (moduleRules.dependsOnModules) {\n for (let path of moduleRules.dependsOnModules) {\n let found = resolver.resolveImport(path, absPath);\n if (!found) {\n throw new Error(`can't locate ${path} referred to in module rules:${JSON.stringify(moduleRules, null, 2)}`);\n }\n output.push({\n absPath,\n target: explicitRelative(dirname(absPath), found.absPath),\n runtimeName: found.runtimeName,\n });\n }\n }\n if (moduleRules.dependsOnComponents) {\n for (let snippet of moduleRules.dependsOnComponents) {\n let found = resolver.resolveComponentSnippet(snippet, moduleRules);\n if (found.jsModule) {\n let { absPath: target, runtimeName } = found.jsModule;\n output.push({ absPath, target: explicitRelative(dirname(absPath), target), runtimeName });\n }\n if (found.hbsModule) {\n let { absPath: target, runtimeName } = found.hbsModule;\n output.push({ absPath, target: explicitRelative(dirname(absPath), target), runtimeName });\n }\n }\n }\n return output;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dependency-rules.js","sourceRoot":"","sources":["dependency-rules.ts"],"names":[],"mappings":";;;AAAA,0CAAuD;AACvD,mCAAmC;AAwKnC,6EAA6E;AAC7E,kCAAkC;AAClC,SAAgB,uBAAuB,CAAC,cAA8B;;IACpE,IAAI,sBAAsB,GAAG,EAAE,CAAC;IAChC,IAAI,iBAAiB,GAAG,EAAE,CAAC;IAC3B,IAAI,cAAc,CAAC,yBAAyB,EAAE;QAC5C,KAAK,IAAI,KAAK,IAAI,cAAc,CAAC,yBAAyB,EAAE;YAC1D,IAAI,IAAI,EAAE,QAAQ,CAAC;YACnB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;gBAC7B,IAAI,GAAG,QAAQ,GAAG,KAAK,CAAC;aACzB;iBAAM;gBACL,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;gBAClB,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC;aAC1B;YACD,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;gBACxB,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;aACtB;YACD,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAClC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACjC,iBAAiB,CAAC,IAAI,CAAC,OAAO,GAAG,QA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AAI,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,YAAY,EAAE;QACtC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;KAC7C;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAlBD,gDAkBC","sourcesContent":["import { Package, getOrCreate } from '@embroider/core';\nimport { satisfies } from 'semver';\n\nexport interface PackageRules {\n // This whole set of rules will only apply when the given addon package\n // matching the given semver range is present and active.\n package: string;\n semverRange?: string;\n\n components?: {\n // I would prefer to write the key type here as `ComponentSnippet` to aid\n // documentation, but Typescript won't allow it. See ComponentSnippet below.\n [key: string]: ComponentRules;\n };\n\n addonModules?: {\n // `filename` is relative to your package root, and it assumes v2 package\n // format. Like \"templates/components/foo.hbs\".\n [filename: string]: ModuleRules;\n };\n\n appModules?: {\n // `filename` is relative to the app's root, and it assumes v2 package\n // format. Like \"templates/components/foo.hbs\".\n [filename: string]: ModuleRules;\n };\n\n addonTemplates?: {\n // `filename` is relative to your package root, and it assumes v2 package\n // format. Like \"templates/foo.hbs\".\n [filename: string]: TemplateRules;\n };\n\n appTemplates?: {\n // `filename` is relative to the app's root, and it assumes v2 package\n // format. Like \"templates/foo.hbs\".\n [filename: string]: TemplateRules;\n };\n}\n\nexport interface ActivePackageRules extends PackageRules {\n // the location(s) of active packages that match this rule.\n roots: string[];\n}\n\nexport interface TemplateRules {\n // Tells embroider which list of components may be needed for a given path.\n // For example, if your template says `{{component this.panel}}` and you know\n // that `this.panel` can be either \"light-panel\" or \"dark-panel\", you would\n // say: `invokes: { \"this.panel\": [\"<LightPanel/>\", \"<DarkPanel/>\"] }`\n invokes?: {\n [path: string]: ComponentSnippet[];\n };\n\n // Embroider will complain if you try to use staticHelper and/or\n // staticComponents and you have ambiguous forms that might be a component or\n // a helper or just some data that is being rendered. For example, if a\n // template says `{{something}}`, we can't tell if that is `<Something />` or\n // `{{ (something) }}` or `{{this.something}}`.\n disambiguate?: {\n [dasherizedName: string]: 'component' | 'helper' | 'data';\n };\n}\n\nexport interface ComponentRules extends TemplateRules {\n // This declares that our component yields other components that are safe to\n // invoke with the {{component}} helper.\n //\n // The array corresponds to your yielded positional arguments. Any value that\n // is true is considered a safe component. Any value can be a hash in which\n // individual keys that are true are considered safe components.\n //\n // Examples:\n //\n // If you do: {{yield (component \"x\") }}\n // Then say: yieldsSafeComponents: [true]\n //\n // If you do: {{yield (hash x=(component \"x\") y=(component \"y\")) }}\n // Then say: yieldsSafeComponents: [{x: true, y: true}]\n //\n yieldsSafeComponents?: (boolean | { [name: string]: boolean })[];\n\n // This declares that our component yields some of its arguments unchanged.\n //\n // The array corresponds to your yielded positional arguments. Each value can\n // be:\n // false, meaning this yielded value is not one of our arguments\n // a string, meaning this yielded value is our argument with that name\n // or a POJO, whose individual properties are string naming which arguments\n // from whence they came.\n //\n // Examples:\n //\n // If you do: {{yield @foo}}\n // Then say: yieldsArguments: ['foo']\n //\n // If you do: {{yield (hash x=@foo) }}\n // Then say: yieldsArguments: [{ x: 'foo' }]\n yieldsArguments?: (string | { [name: string]: string })[];\n\n // This declares that our component accepts arguments that will be invoked\n // with the {{component}} helper. This silences warnings in the places where\n // we consume them, while introducing warnings in the places where people are\n // passing them to us (if they are doing so in a way that is too dynamic to\n // analyze).\n //\n // If you use this, you may also need to set `layout`, see below.\n acceptsComponentArguments?: ArgumentMapping[];\n\n // If you want to use `acceptsComponentArguments` on a component that\n // customies its own `layout` (which is most addon-provided components), you\n // need to tell us here how to find its template by setting either `addonPath`\n // or `appPath`.\n layout?: {\n // This is a path relative to the addon root, assuming V2 format.\n addonPath?: string;\n // This is the path relative to the app root, assuming V2 format.\n appPath?: string;\n };\n\n // An unresolvable component is usually a build error (when your app has the\n // staticComponent Option enabled). But you can tell Embroider to ignore it by\n // setting this.\n safeToIgnore?: boolean;\n}\n\nexport interface ModuleRules {\n // We will resolve these components into the corresponding JS and HBS files\n // and generate imports such that this module depends on them.\n dependsOnComponents?: ComponentSnippet[];\n\n // This adds new imports to our module, as if they were really there. Helpful\n // for working around addons that depend on things but don't say so.\n dependsOnModules?: string[];\n}\n\n// The bare \"string\" short form implies that `becomes` is the same as `name`.\nexport type ArgumentMapping =\n | string\n | {\n // the name of the argument you accept\n name: string;\n // the name its consumed as in your template\n becomes: string;\n };\n\n// A component snippet is a string containing valid HBS that is a single\n// component invocation. We use it to refer to components in a way that doesn't\n// require any new syntax or rules, and that's necessarily supported by whatever\n// build-time template resolver is in use.\n//\n// Examples of valid ComponentSnippets:\n//\n// \"{{my-component}}\"\n// \"{{my-component/foo}}\"\n// \"<MyComponent />\"\n// \"{{component 'my-component'}}\"\n//\ntype ComponentSnippet = string;\n\nexport interface PreprocessedComponentRule {\n yieldsSafeComponents: Required<ComponentRules>['yieldsSafeComponents'];\n yieldsArguments: Required<ComponentRules>['yieldsArguments'];\n argumentsAreComponents: string[];\n safeToIgnore: boolean;\n safeInteriorPaths: string[];\n disambiguate: Record<string, 'component' | 'helper' | 'data'>;\n}\n\n// take a component rule from the authoring format to a format more optimized\n// for consumption in the resolver\nexport function preprocessComponentRule(componentRules: ComponentRules): PreprocessedComponentRule {\n let argumentsAreComponents = [];\n let safeInteriorPaths = [];\n if (componentRules.acceptsComponentArguments) {\n for (let entry of componentRules.acceptsComponentArguments) {\n let name, interior;\n if (typeof entry === 'string') {\n name = interior = entry;\n } else {\n name = entry.name;\n interior = entry.becomes;\n }\n if (name.startsWith('@')) {\n name = name.slice(1);\n }\n argumentsAreComponents.push(name);\n safeInteriorPaths.push(interior);\n safeInteriorPaths.push('this.' + interior);\n safeInteriorPaths.push('@' + name);\n }\n }\n if (componentRules.invokes) {\n for (let [path] of Object.entries(componentRules.invokes)) {\n safeInteriorPaths.push(path);\n }\n }\n return {\n safeInteriorPaths,\n safeToIgnore: Boolean(componentRules.safeToIgnore),\n argumentsAreComponents,\n yieldsSafeComponents: componentRules.yieldsSafeComponents || [],\n yieldsArguments: componentRules.yieldsArguments || [],\n disambiguate: componentRules?.disambiguate ?? {},\n };\n}\n\nexport function activePackageRules(packageRules: PackageRules[], activePackages: Package[]): ActivePackageRules[] {\n // rule order implies precedence. The first rule that matches a given package\n // applies to that package, and no other rule does.\n let rootsPerRule = new Map();\n for (let pkg of activePackages) {\n for (let rule of packageRules) {\n if (rule.package === pkg.name && (!rule.semverRange || satisfies(pkg.version, rule.semverRange))) {\n let roots = getOrCreate(rootsPerRule, rule, () => []);\n roots.push(pkg.root);\n break;\n }\n }\n }\n let output = [];\n for (let [rule, roots] of rootsPerRule) {\n output.push(Object.assign({ roots }, rule));\n }\n return output;\n}\n"]}
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
import { default as Resolver } from './resolver';
|
|
2
1
|
import type { ASTPluginBuilder, ASTPluginEnvironment } from '@glimmer/syntax';
|
|
2
|
+
import { ActivePackageRules } from './dependency-rules';
|
|
3
3
|
import type { WithJSUtils } from 'babel-plugin-ember-template-compilation';
|
|
4
|
+
import { ResolverOptions as CoreResolverOptions } from '@embroider/core';
|
|
5
|
+
import CompatOptions from './options';
|
|
4
6
|
declare type Env = WithJSUtils<ASTPluginEnvironment> & {
|
|
5
7
|
filename: string;
|
|
6
8
|
contents: string;
|
|
7
9
|
strict?: boolean;
|
|
8
10
|
locals?: string[];
|
|
9
11
|
};
|
|
12
|
+
declare type UserConfig = Pick<Required<CompatOptions>, 'staticHelpers' | 'staticModifiers' | 'staticComponents' | 'allowUnsafeDynamicComponents'>;
|
|
13
|
+
export interface CompatResolverOptions extends CoreResolverOptions {
|
|
14
|
+
activePackageRules: ActivePackageRules[];
|
|
15
|
+
options: UserConfig;
|
|
16
|
+
}
|
|
10
17
|
export interface Options {
|
|
11
|
-
|
|
12
|
-
patchHelpersBug: boolean;
|
|
18
|
+
appRoot: string;
|
|
13
19
|
}
|
|
14
|
-
export
|
|
20
|
+
export declare const builtInKeywords: string[];
|
|
21
|
+
export default function makeResolverTransform({ appRoot }: Options): ASTPluginBuilder<Env>;
|
|
15
22
|
export {};
|