Skip to content

Commit

Permalink
fix: all test reviewed and adjusted
Browse files Browse the repository at this point in the history
  • Loading branch information
barak007 committed Nov 1, 2023
1 parent f4d5eb6 commit 93dfd4f
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
6 changes: 3 additions & 3 deletions packages/cli/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export async function build(
diagnostics,
diagnosticsMode,
inlineRuntime,
runtimeCjsRequest = '@stylable/runtime/dist/index.js',
runtimeEsmRequest = '@stylable/runtime/dist/index.mjs',
runtimeCjsRequest = '@stylable/runtime',
runtimeEsmRequest = '@stylable/runtime',
}: BuildOptions,
{
projectRoot: _projectRoot,
Expand Down Expand Up @@ -456,7 +456,7 @@ function copyRuntime(
}
if (esm) {
fs.ensureDirectorySync(fullOutDir);
runtimeEsmOutPath = fs.join(fullOutDir, 'stylable-esm-runtime.js');
runtimeEsmOutPath = fs.join(fullOutDir, 'stylable-esm-runtime.mjs');
fs.writeFileSync(runtimeEsmOutPath, fs.readFileSync(runtimeEsmPath, 'utf8'));
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/test/build.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ describe('build stand alone', () => {
.root {}
`,
'/node_modules/@stylable/runtime/dist/index.js': `// runtime cjs`,
'/node_modules/@stylable/runtime/esm/index.js': `// runtime esm`,
'/node_modules/@stylable/runtime/dist/index.mjs': `// runtime esm`,
});

const stylable = new Stylable({
Expand Down Expand Up @@ -495,10 +495,10 @@ describe('build stand alone', () => {
const builtFileEsm = fs.readFileSync('/dist/comp.st.css.js', 'utf8');

expect(builtFileCjs, 'imports the cjs runtime with full extension').to.contain(
`"@stylable/runtime/dist/index.js"`
`"@stylable/runtime"`
);
expect(builtFileEsm, 'imports the esm runtime with full extension').to.contain(
`"@stylable/runtime/dist/index.mjs"`
`"@stylable/runtime"`
);
});

Expand Down
4 changes: 2 additions & 2 deletions packages/webpack-plugin/test/e2e/dynamic-bug.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ describe(`(${project})`, () => {
const chunkByName = projectRunner.getChunksModulesNames();

expect(chunkByName.entryA).to.eql(
['test-components/badge.st.css', 'test-components/badge.js', 'src/index-a.js'],
['test-components/badge.st.css', 'test-components/badge.js', 'src/index-a.js', 'dist/index.mjs'],
'entryA'
);
expect(chunkByName.entryB).to.eql(
['test-components/badge.st.css', 'test-components/badge.js', 'src/index-b.js'],
['test-components/badge.st.css', 'test-components/badge.js', 'src/index-b.js', 'dist/index.mjs'],
'entryB'
);
expect(chunkByName.dynamicSplit).to.eql(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ describe(`(${project})`, () => {
],
'Gallery'
);
expect(chunkByName.main).to.eql(['src/index.js'], 'main');
expect(chunkByName.main).to.eql(['src/index.js', 'dist/index.mjs'], 'main');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
// mode: 'production',
context: __dirname,
devtool: 'source-map',
plugins: [new StylableWebpackPlugin({ useWeakDeps: true }), new HtmlWebpackPlugin()],
plugins: [new StylableWebpackPlugin(), new HtmlWebpackPlugin()],
optimization: {
splitChunks: {
chunks: 'all',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// force runtime to be bundled in the main chunk
import "@stylable/runtime";

const Lib = {
async loadButton() {
return import(/* webpackChunkName: "Button" */ './button');
Expand Down

0 comments on commit 93dfd4f

Please sign in to comment.