ember-repl 4.3.3 → 4.3.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.
|
@@ -78,7 +78,7 @@ async function transform(intermediate, name, options = {}) {
|
|
|
78
78
|
// so we have to use the default export (which is all the exports)
|
|
79
79
|
let maybeBabel = await import('@babel/standalone');
|
|
80
80
|
// Handle difference between vite and webpack in consuming projects...
|
|
81
|
-
let babel = '
|
|
81
|
+
let babel = 'availablePlugins' in maybeBabel ? maybeBabel : maybeBabel.default;
|
|
82
82
|
return babel.transform(intermediate, {
|
|
83
83
|
filename: `${name}.js`,
|
|
84
84
|
plugins: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/compile/formats/gjs/index.ts"],"sourcesContent":["import babelPluginEmberTemplateCompilation from 'babel-plugin-ember-template-compilation';\nimport * as compiler from 'ember-template-compiler';\n\nimport { nameFor } from '../../utils.ts';\nimport { evalSnippet } from './eval.ts';\n\nimport type { CompileResult } from '../../types.ts';\nimport type { ComponentLike } from '@glint/template';\n\nexport interface Info {\n code: string;\n name: string;\n}\n\n/**\n * @public\n * Transpiles GlimmerJS (*.gjs) formatted text into and evaluates as a JS Module.\n * The returned component can be invoked explicitly in the consuming project.\n *\n * SEE: README for example usage\n *\n * @param {string} code: the code to be compiled\n * @param {Object} extraModules: map of import paths to modules. This isn't needed\n * for classic ember projects, but for strict static ember projects, extraModules\n * will need to be pasesd if compileJS is intended to be used in a styleguide or\n * if there are additional modules that could be imported in the passed `code`.\n *\n * Later on, imports that are not present by default (ember/glimmer) or that\n * are not provided by extraModules will be searched on npm to see if a package\n * needs to be downloaded before running the `code` / invoking the component\n */\nexport async function compileJS(\n code: string,\n extraModules?: Record<string, unknown>\n): Promise<CompileResult> {\n let name = nameFor(code);\n let component: undefined | ComponentLike;\n let error: undefined | Error;\n\n try {\n let compiled = await transpile({ code: code, name });\n\n if (!compiled) {\n throw new Error(`Compiled output is missing`);\n }\n\n component = evalSnippet(compiled, extraModules).default as unknown as ComponentLike;\n } catch (e) {\n error = e as Error | undefined;\n }\n\n return { name, component, error };\n}\n\nasync function transpile({ code: input, name }: Info) {\n let preprocessed = await preprocess(input, name);\n let result = await transform(preprocessed, name);\n\n if (!result) {\n return;\n }\n\n let { code } = result;\n\n return code;\n}\n\nimport type { Babel } from './babel.ts';\n\nlet processor: any;\nlet fetchingPromise: Promise<any>;\n\nasync function preprocess(input: string, name: string): Promise<string> {\n if (!fetchingPromise) {\n fetchingPromise = import('content-tag');\n }\n\n if (!processor) {\n let { Preprocessor } = await fetchingPromise;\n\n processor = new Preprocessor();\n }\n\n return processor.process(input, { filename: `${name}.js`, inline_source_map: true });\n}\n\nasync function transform(\n intermediate: string,\n name: string,\n options: any = {}\n): Promise<ReturnType<Babel['transform']>> {\n // @babel/standalone is a CJS module....\n // so we have to use the default export (which is all the exports)\n let maybeBabel = (await import('@babel/standalone')) as any;\n // Handle difference between vite and webpack in consuming projects...\n let babel: Babel = '
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/compile/formats/gjs/index.ts"],"sourcesContent":["import babelPluginEmberTemplateCompilation from 'babel-plugin-ember-template-compilation';\nimport * as compiler from 'ember-template-compiler';\n\nimport { nameFor } from '../../utils.ts';\nimport { evalSnippet } from './eval.ts';\n\nimport type { CompileResult } from '../../types.ts';\nimport type { ComponentLike } from '@glint/template';\n\nexport interface Info {\n code: string;\n name: string;\n}\n\n/**\n * @public\n * Transpiles GlimmerJS (*.gjs) formatted text into and evaluates as a JS Module.\n * The returned component can be invoked explicitly in the consuming project.\n *\n * SEE: README for example usage\n *\n * @param {string} code: the code to be compiled\n * @param {Object} extraModules: map of import paths to modules. This isn't needed\n * for classic ember projects, but for strict static ember projects, extraModules\n * will need to be pasesd if compileJS is intended to be used in a styleguide or\n * if there are additional modules that could be imported in the passed `code`.\n *\n * Later on, imports that are not present by default (ember/glimmer) or that\n * are not provided by extraModules will be searched on npm to see if a package\n * needs to be downloaded before running the `code` / invoking the component\n */\nexport async function compileJS(\n code: string,\n extraModules?: Record<string, unknown>\n): Promise<CompileResult> {\n let name = nameFor(code);\n let component: undefined | ComponentLike;\n let error: undefined | Error;\n\n try {\n let compiled = await transpile({ code: code, name });\n\n if (!compiled) {\n throw new Error(`Compiled output is missing`);\n }\n\n component = evalSnippet(compiled, extraModules).default as unknown as ComponentLike;\n } catch (e) {\n error = e as Error | undefined;\n }\n\n return { name, component, error };\n}\n\nasync function transpile({ code: input, name }: Info) {\n let preprocessed = await preprocess(input, name);\n let result = await transform(preprocessed, name);\n\n if (!result) {\n return;\n }\n\n let { code } = result;\n\n return code;\n}\n\nimport type { Babel } from './babel.ts';\n\nlet processor: any;\nlet fetchingPromise: Promise<any>;\n\nasync function preprocess(input: string, name: string): Promise<string> {\n if (!fetchingPromise) {\n fetchingPromise = import('content-tag');\n }\n\n if (!processor) {\n let { Preprocessor } = await fetchingPromise;\n\n processor = new Preprocessor();\n }\n\n return processor.process(input, { filename: `${name}.js`, inline_source_map: true });\n}\n\nasync function transform(\n intermediate: string,\n name: string,\n options: any = {}\n): Promise<ReturnType<Babel['transform']>> {\n // @babel/standalone is a CJS module....\n // so we have to use the default export (which is all the exports)\n let maybeBabel = (await import('@babel/standalone')) as any;\n // Handle difference between vite and webpack in consuming projects...\n let babel: Babel = 'availablePlugins' in maybeBabel ? maybeBabel : maybeBabel.default;\n\n return babel.transform(intermediate, {\n filename: `${name}.js`,\n plugins: [\n // [babelPluginIntermediateGJS],\n [\n babelPluginEmberTemplateCompilation,\n {\n compiler,\n },\n ],\n [babel.availablePlugins['proposal-decorators'], { legacy: true }],\n [babel.availablePlugins['proposal-class-properties']],\n ],\n presets: [\n [\n babel.availablePresets['env'],\n {\n // false -- keeps ES Modules\n modules: 'cjs',\n targets: { esmodules: true },\n forceAllTransforms: false,\n ...options,\n },\n ],\n ],\n });\n}\n"],"names":["compileJS","code","extraModules","name","nameFor","component","error","compiled","transpile","Error","evalSnippet","default","e","input","preprocessed","preprocess","result","transform","processor","fetchingPromise","Preprocessor","process","filename","inline_source_map","intermediate","options","maybeBabel","babel","plugins","babelPluginEmberTemplateCompilation","compiler","availablePlugins","legacy","presets","availablePresets","modules","targets","esmodules","forceAllTransforms"],"mappings":";;;;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeA,SAASA,CAC7BC,IAAY,EACZC,YAAsC,EACd;AACxB,EAAA,IAAIC,IAAI,GAAGC,OAAO,CAACH,IAAI,CAAC,CAAA;AACxB,EAAA,IAAII,SAAoC,CAAA;AACxC,EAAA,IAAIC,KAAwB,CAAA;EAE5B,IAAI;AACF,IAAA,IAAIC,QAAQ,GAAG,MAAMC,SAAS,CAAC;AAAEP,MAAAA,IAAI,EAAEA,IAAI;AAAEE,MAAAA,IAAAA;AAAK,KAAC,CAAC,CAAA;IAEpD,IAAI,CAACI,QAAQ,EAAE;AACb,MAAA,MAAM,IAAIE,KAAK,CAAC,CAAA,0BAAA,CAA4B,CAAC,CAAA;AAC/C,KAAA;IAEAJ,SAAS,GAAGK,WAAW,CAACH,QAAQ,EAAEL,YAAY,CAAC,CAACS,OAAmC,CAAA;GACpF,CAAC,OAAOC,CAAC,EAAE;AACVN,IAAAA,KAAK,GAAGM,CAAsB,CAAA;AAChC,GAAA;EAEA,OAAO;IAAET,IAAI;IAAEE,SAAS;AAAEC,IAAAA,KAAAA;GAAO,CAAA;AACnC,CAAA;AAEA,eAAeE,SAASA,CAAC;AAAEP,EAAAA,IAAI,EAAEY,KAAK;AAAEV,EAAAA,IAAAA;AAAW,CAAC,EAAE;EACpD,IAAIW,YAAY,GAAG,MAAMC,UAAU,CAACF,KAAK,EAAEV,IAAI,CAAC,CAAA;EAChD,IAAIa,MAAM,GAAG,MAAMC,SAAS,CAACH,YAAY,EAAEX,IAAI,CAAC,CAAA;EAEhD,IAAI,CAACa,MAAM,EAAE;AACX,IAAA,OAA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E,CAACL,KAAK,CAACI,gBAAgB,CAAC,2BAA2B,CAAC,CAAC,CACtD;IACDE,OAAO,EAAE,CACP,CACEN,KAAK,CAACO,gBAAgB,CAAC,KAAK,CAAC,EAC7B;AACE;AACAC,MAAAA,OAAO,EAAE,KAAK;AACdC,MAAAA,OAAO,EAAE;AAAEC,QAAAA,SAAS,EAAE,IAAA;OAAM;AAC5BC,MAAAA,kBAAkB,EAAE,KAAK;MACzB,GAAGb,OAAAA;AACL,KAAC,CACF,CAAA;AAEL,GAAC,CAAC,CAAA;AACJ;;;;"}
|
package/package.json
CHANGED
|
@@ -93,7 +93,7 @@ async function transform(
|
|
|
93
93
|
// so we have to use the default export (which is all the exports)
|
|
94
94
|
let maybeBabel = (await import('@babel/standalone')) as any;
|
|
95
95
|
// Handle difference between vite and webpack in consuming projects...
|
|
96
|
-
let babel: Babel = '
|
|
96
|
+
let babel: Babel = 'availablePlugins' in maybeBabel ? maybeBabel : maybeBabel.default;
|
|
97
97
|
|
|
98
98
|
return babel.transform(intermediate, {
|
|
99
99
|
filename: `${name}.js`,
|