Skip to content

Commit

Permalink
refactor: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
barak007 committed Nov 1, 2023
1 parent 93dfd4f commit 6f25ae0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
8 changes: 1 addition & 7 deletions packages/core/src/stylable-js-module-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,7 @@ function runtimeImport(
injectOptions: InjectCSSOptions | undefined
) {
const importInjectCSS = injectOptions?.css ? `, injectCSS` : '';
const request = JSON.stringify(
runtimeRequest ??
// TODO: we use direct requests here since we don't know how this will be resolved
(moduleType === 'esm'
? '@stylable/runtime/dist/index.mjs'
: '@stylable/runtime/dist/index.js')
);
const request = JSON.stringify(runtimeRequest ?? '@stylable/runtime');
return moduleType === 'esm'
? `import { classesRuntime, statesRuntime${importInjectCSS} } from ${request};`
: `const { classesRuntime, statesRuntime${importInjectCSS} } = require(${request});`;
Expand Down
6 changes: 5 additions & 1 deletion packages/module-utils/test/test-kit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ function evalModule(id: string, source: string, requireModule: (s: string) => an
*/
export function evalStylableModule<T = unknown>(source: string, fullPath: string): T {
return evalModule(fullPath, source, (id) => {
if (id === '@stylable/runtime' || id === '@stylable/runtime/dist/index.js' || id === '@stylable/runtime/dist/index.mjs') {
if (
id === '@stylable/runtime' ||
id === '@stylable/runtime/dist/index.js' ||
id === '@stylable/runtime/dist/index.mjs'
) {
return runtime;
}
throw new Error(`Could not find module: ${id}`);
Expand Down
4 changes: 0 additions & 4 deletions packages/node/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ async function initiateModuleFactory() {
},
{
moduleType: 'esm',
// point to cjs - the esm runtime isn't published with mjs
// and causes issues. currently it's problematic for direct esm
// usage and only works for bundlers.
runtimePath: '@stylable/runtime',
}
);
}
Expand Down

0 comments on commit 6f25ae0

Please sign in to comment.