ember-repl 5.0.0 → 5.0.1
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 preprocess(input, name) {
|
|
|
78
78
|
async function transform(intermediate, name) {
|
|
79
79
|
const [
|
|
80
80
|
// _parser, _traverse, _generator,
|
|
81
|
-
_decoratorTransforms,
|
|
81
|
+
_decoratorTransforms, _emberTemplateCompilation] = await Promise.all([
|
|
82
82
|
// @babel/* doesn't have the greatest ESM compat yet
|
|
83
83
|
// https://github.com/babel/babel/issues/14314#issuecomment-1054505190
|
|
84
84
|
//
|
|
@@ -87,7 +87,10 @@ async function transform(intermediate, name) {
|
|
|
87
87
|
// import('@babel/traverse'),
|
|
88
88
|
// import('@babel/generator'),
|
|
89
89
|
import('decorator-transforms'), import('babel-plugin-ember-template-compilation')]);
|
|
90
|
+
|
|
91
|
+
// These libraries are compiled incorrectly for cjs<->ESM compat
|
|
90
92
|
const decoratorTransforms = 'default' in _decoratorTransforms ? _decoratorTransforms.default : _decoratorTransforms;
|
|
93
|
+
const emberTemplateCompilation = 'default' in _emberTemplateCompilation ? _emberTemplateCompilation.default : _emberTemplateCompilation;
|
|
91
94
|
|
|
92
95
|
// so we have to use the default export (which is all the exports)
|
|
93
96
|
let maybeBabel = await import('@babel/standalone');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/compile/formats/gjs/index.ts"],"sourcesContent":["import * 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 let { code /* map */ } = processor.process(input, {\n filename: `${name}.js`,\n inline_source_map: true,\n });\n\n return code;\n}\n\nasync function transform(\n intermediate: string,\n name: string\n): Promise<ReturnType<Babel['transform']>> {\n const [\n // _parser, _traverse, _generator,\n _decoratorTransforms,\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/compile/formats/gjs/index.ts"],"sourcesContent":["import * 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 let { code /* map */ } = processor.process(input, {\n filename: `${name}.js`,\n inline_source_map: true,\n });\n\n return code;\n}\n\nasync function transform(\n intermediate: string,\n name: string\n): Promise<ReturnType<Babel['transform']>> {\n const [\n // _parser, _traverse, _generator,\n _decoratorTransforms,\n _emberTemplateCompilation,\n ] = await Promise.all([\n // @babel/* doesn't have the greatest ESM compat yet\n // https://github.com/babel/babel/issues/14314#issuecomment-1054505190\n //\n // babel-standalone is so easy...\n // import('@babel/parser'),\n // import('@babel/traverse'),\n // import('@babel/generator'),\n import('decorator-transforms'),\n import('babel-plugin-ember-template-compilation'),\n ]);\n\n // These libraries are compiled incorrectly for cjs<->ESM compat\n const decoratorTransforms =\n 'default' in _decoratorTransforms ? _decoratorTransforms.default : _decoratorTransforms;\n\n const emberTemplateCompilation =\n 'default' in _emberTemplateCompilation\n ? _emberTemplateCompilation.default\n : _emberTemplateCompilation;\n\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 [\n emberTemplateCompilation,\n {\n compiler,\n },\n ],\n [\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - we don't care about types here..\n decoratorTransforms,\n {\n runtime: {\n import: 'decorator-transforms/runtime',\n },\n },\n ],\n // Womp.\n // See this exploration into true ESM:\n // https://github.com/NullVoxPopuli/limber/pull/1805\n [babel.availablePlugins['transform-modules-commonjs']],\n ],\n presets: [],\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","_decoratorTransforms","_emberTemplateCompilation","Promise","all","decoratorTransforms","emberTemplateCompilation","maybeBabel","babel","plugins","compiler","runtime","import","availablePlugins","presets"],"mappings":";;;;AAaA;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;AACxB,EAAA,IAAII,SAAoC;AACxC,EAAA,IAAIC,KAAwB;EAE5B,IAAI;AACF,IAAA,IAAIC,QAAQ,GAAG,MAAMC,SAAS,CAAC;AAAEP,MAAAA,IAAI,EAAEA,IAAI;AAAE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I;AACb;AAEA,eAAegB,SAASA,CACtBO,YAAoB,EACpBrB,IAAY,EAC6B;EACzC,MAAM;AACJ;EACAsB,oBAAoB,EACpBC,yBAAyB,CAC1B,GAAG,MAAMC,OAAO,CAACC,GAAG,CAAC;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;EACA,OAAO,sBAAsB,CAAC,EAC9B,OAAO,yCAAyC,CAAC,CAClD,CAAC;;AAEF;EACA,MAAMC,mBAAmB,GACvB,SAAS,IAAIJ,oBAAoB,GAAGA,oBAAoB,CAACd,OAAO,GAAGc,oBAAoB;EAEzF,MAAMK,wBAAwB,GAC5B,SAAS,IAAIJ,yBAAyB,GAClCA,yBAAyB,CAACf,OAAO,GACjCe,yBAAyB;;AAE/B;AACA,EAAA,IAAIK,UAAU,GAAI,MAAM,OAAO,mBAAmB,CAAS;AAC3D;EACA,IAAIC,KAAY,GAAG,kBAAkB,IAAID,UAAU,GAAGA,UAAU,GAAGA,UAAU,CAACpB,OAAO;AAErF,EAAA,OAAOqB,KAAK,CAACf,SAAS,CAACO,YAAY,EAAE;IACnCF,QAAQ,EAAE,CAAGnB,EAAAA,IAAI,CAAK,GAAA,CAAA;AACtB8B,IAAAA,OAAO,EAAE,CACP,CACEH,wBAAwB,EACxB;AACEI,MAAAA;AACF,KAAC,CACF,EACD;AACE;AACA;AACAL,IAAAA,mBAAmB,EACnB;AACEM,MAAAA,OAAO,EAAE;AACPC,QAAAA,MAAM,EAAE;AACV;AACF,KAAC,CACF;AACD;AACA;AACA;AACA,IAAA,CAACJ,KAAK,CAACK,gBAAgB,CAAC,4BAA4B,CAAC,CAAC,CACvD;AACDC,IAAAA,OAAO,EAAE;AACX,GAAC,CAAC;AACJ;;;;"}
|
package/package.json
CHANGED
|
@@ -95,7 +95,7 @@ async function transform(
|
|
|
95
95
|
const [
|
|
96
96
|
// _parser, _traverse, _generator,
|
|
97
97
|
_decoratorTransforms,
|
|
98
|
-
|
|
98
|
+
_emberTemplateCompilation,
|
|
99
99
|
] = await Promise.all([
|
|
100
100
|
// @babel/* doesn't have the greatest ESM compat yet
|
|
101
101
|
// https://github.com/babel/babel/issues/14314#issuecomment-1054505190
|
|
@@ -108,9 +108,15 @@ async function transform(
|
|
|
108
108
|
import('babel-plugin-ember-template-compilation'),
|
|
109
109
|
]);
|
|
110
110
|
|
|
111
|
+
// These libraries are compiled incorrectly for cjs<->ESM compat
|
|
111
112
|
const decoratorTransforms =
|
|
112
113
|
'default' in _decoratorTransforms ? _decoratorTransforms.default : _decoratorTransforms;
|
|
113
114
|
|
|
115
|
+
const emberTemplateCompilation =
|
|
116
|
+
'default' in _emberTemplateCompilation
|
|
117
|
+
? _emberTemplateCompilation.default
|
|
118
|
+
: _emberTemplateCompilation;
|
|
119
|
+
|
|
114
120
|
// so we have to use the default export (which is all the exports)
|
|
115
121
|
let maybeBabel = (await import('@babel/standalone')) as any;
|
|
116
122
|
// Handle difference between vite and webpack in consuming projects...
|