Skip to content

Commit

Permalink
Attempted updates
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Sep 18, 2024
1 parent 36a54b5 commit 7d77aeb
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 94 deletions.
4 changes: 4 additions & 0 deletions packages/repl-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
".": {
"types": "./src/index.d.ts",
"default": "./src/index.js"
},
"./compilers/ember/*": {
"default": "./src/compilers/ember/*.js"
}
},
"scripts": {
Expand Down Expand Up @@ -37,6 +40,7 @@
],
"license": "MIT",
"devDependencies": {
"@babel/plugin-proposal-decorators": "^7.23.9",
"@nullvoxpopuli/eslint-configs": "^4.0.0",
"@tsconfig/ember": "^3.0.7",
"eslint": "^8.55.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/repl-sdk/src/compilers/cdn.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const jsdelivr = {
async import(versions, importPath) {
let url = esmRun(versions, importPath);

return await import(/* vite-ignore */ url);
return await import(/* @vite-ignore */ url);
},
/**
* @param {Record<string, string>} versions
Expand All @@ -67,7 +67,7 @@ export const esmsh = {
async import(versions, importPath) {
let url = esmSh(versions, importPath);

return await import(/* vite-ignore */ url);
return await import(/* @vite-ignore */ url);
},
/**
* @param {Record<string, string>} versions
Expand Down
17 changes: 17 additions & 0 deletions packages/repl-sdk/src/compilers/ember/macros.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* This is a replacement module for `@embroider/macros` which is a babel plugin that was never meant to be ran in the browser.
*
* This provides runtime implementations of all the macros' behaviors.
*/

export function macroCondition(result) {
return result;
}

export function dependencySatisfies() {
return true;
}

export function isDevelopingApp() {
return true;
}
100 changes: 8 additions & 92 deletions packages/repl-sdk/src/compilers/glimmer-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ export async function compiler(config = {} /*, api */) {
templatePlugin,
{ default: templateCompiler },
{ Preprocessor },
{ default: MacrosPlugin },
,
{ buildPlugin: makeMacrosGlimmerPlugin },
{ default: AdjustImports },
{ default: DebugMacros },
] = await esmsh.importAll(versions, [
/**
Expand All @@ -39,15 +35,6 @@ export async function compiler(config = {} /*, api */) {
* Converts gjs/gts to standard js/ts
*/
'content-tag',
/**
* Build-time macros
* (partly because import.meta.env.DEV isn't standard
* partly because we needed more than what meta.env could offer)
*/
'@embroider/macros/src/babel/macros-babel-plugin.js',
'@embroider/macros/src/node.js',
'@embroider/macros/src/glimmer/ast-transform.js',
'@embroider/compat/src/babel-plugin-adjust-imports.js',
/**
* Older-style build macros
* (before import.meta.env was even a thing)
Expand All @@ -63,20 +50,14 @@ export async function compiler(config = {} /*, api */) {
]);

async function transform(text) {
// eslint-disable-next-line
console.log(templateCompiler, templatePlugin);

return babel.transform(text, {
filename: `dynamic-repl.js`,
plugins: [
[
templatePlugin,
{
compiler: templateCompiler,
transforms: [
makeMacrosGlimmerPlugin({ methodName: 'makeFirstTransform' }),
makeMacrosGlimmerPlugin({ methodName: 'makeSecondTransform' }),
],
transforms: [],
},
],
[
Expand Down Expand Up @@ -116,73 +97,6 @@ export async function compiler(config = {} /*, api */) {
},
'@ember/application/deprecations stripping',
],
/**
* TODO: I may need a safer browser-time implementation
* of @embroider/macros
*/
[
MacrosPlugin,
{
userConfigs: {},
globalConfig: {
'@embroider/macros': {
isTesting: false,
},
WarpDrive: {
debug: {
LOG_GRAPH: false,
LOG_IDENTIFIERS: false,
LOG_INSTANCE_CACHE: false,
LOG_MUTATIONS: false,
LOG_NOTIFICATIONS: false,
LOG_OPERATIONS: false,
LOG_PAYLOADS: false,
LOG_REQUESTS: false,
LOG_REQUEST_STATUS: false,
},
polyfillUUID: false,
includeDataAdapter: true,
compatWith: null,
deprecations: {
DEPRECATE_CATCH_ALL: true,
DEPRECATE_COMPUTED_CHAINS: true,
DEPRECATE_EMBER_INFLECTOR: true,
DEPRECATE_LEGACY_IMPORTS: true,
DEPRECATE_MANY_ARRAY_DUPLICATES: true,
DEPRECATE_NON_STRICT_ID: true,
DEPRECATE_NON_STRICT_TYPES: true,
DEPRECATE_NON_UNIQUE_PAYLOADS: true,
DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE: true,
DEPRECATE_STORE_EXTENDS_EMBER_OBJECT: true,
ENABLE_LEGACY_SCHEMA_SERVICE: true,
},
features: {
SAMPLE_FEATURE_FLAG: false,
},
env: {
TESTING: true,
PRODUCTION: false,
DEBUG: true,
},
},
'@embroider/core': {
active: true,
},
},
owningPackageRoot: null,
isDevelopingPackageRoots: ['/home/nvp/Development/tmp/my-fancy-app'],
appPackageRoot: '/home/nvp/Development/tmp/my-fancy-app',
embroiderMacrosConfigMarker: true,
mode: 'run-time',
hideRequires: true,
},
],
[
AdjustImports,
{
appRoot: '/home/nvp/Development/tmp/my-fancy-app',
},
],
// [babel.availablePlugins['proposal-decorators'], { legacy: true }],
// [babel.availablePlugins['proposal-class-properties']],
],
Expand Down Expand Up @@ -216,18 +130,20 @@ export async function compiler(config = {} /*, api */) {
return `https://esm.sh/*ember-source/dist/dependencies/${id}.js`;
}

// if (id.startsWith('@embroider/macros')) {
// return `https://esm.sh/*@embroider/macros/src/addon/runtime.js`;
// }
console.log({ id });

Check failure on line 133 in packages/repl-sdk/src/compilers/glimmer-js.js

View workflow job for this annotation

GitHub Actions / autofix

Unexpected console statement

Check failure on line 133 in packages/repl-sdk/src/compilers/glimmer-js.js

View workflow job for this annotation

GitHub Actions / Lints

Unexpected console statement

if (id.startsWith('@embroider/macros')) {
return `repl-sdk/compilers/ember/macros.js`;
}
},
compile: async (text) => {
let preprocessed = preprocessor.process(text, 'dynamic-repl.js');
let transformed = await transform({ babel, templatePlugin, templateCompiler }, preprocessed);
let transformed = await transform(preprocessed);

let code = transformed.code;

// eslint-disable-next-line
console.log(code);
console.log({ code });

return code;
},
Expand Down
1 change: 1 addition & 0 deletions packages/repl-sdk/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class Compiler {
mapOverrides: true, // default false
// Hook all module resolutions
resolve: (id) => {
console.debug('resolving', id);
if (id.startsWith('blob:')) return id;
if (id.startsWith('https://')) return id;
if (id.startsWith('.')) return id;
Expand Down
1 change: 1 addition & 0 deletions packages/repl-sdk/tests-self/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
},
"author": "NullvoxPopuli",
"devDependencies": {
"@babel/plugin-proposal-decorators": "^7.23.9",
"@babel/standalone": "^7.24.5",
"@nullvoxpopuli/eslint-configs": "^4.0.0",
"@testing-library/dom": "^10.3.2",
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7d77aeb

Please sign in to comment.