From 93dfd4f471dc11c40f21f6fbdb71e10c667a3ab2 Mon Sep 17 00:00:00 2001 From: Barak Date: Wed, 1 Nov 2023 12:30:35 +0200 Subject: [PATCH] fix: all test reviewed and adjusted --- packages/cli/src/build.ts | 6 +++--- packages/cli/test/build.spec.ts | 6 +++--- packages/webpack-plugin/test/e2e/dynamic-bug.spec.ts | 4 ++-- .../test/e2e/dynamic-chunk-3rd-party-split-project.spec.ts | 2 +- .../test/e2e/projects/dynamic-bug/webpack.config.js | 2 +- .../dynamic-chunk-3rd-party-split-project/src/index.js | 3 +++ 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/cli/src/build.ts b/packages/cli/src/build.ts index a67f28b29..05abc8790 100644 --- a/packages/cli/src/build.ts +++ b/packages/cli/src/build.ts @@ -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, @@ -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')); } } diff --git a/packages/cli/test/build.spec.ts b/packages/cli/test/build.spec.ts index be92fd6be..ff2c0e398 100644 --- a/packages/cli/test/build.spec.ts +++ b/packages/cli/test/build.spec.ts @@ -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({ @@ -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"` ); }); diff --git a/packages/webpack-plugin/test/e2e/dynamic-bug.spec.ts b/packages/webpack-plugin/test/e2e/dynamic-bug.spec.ts index 0746a513d..627ace445 100644 --- a/packages/webpack-plugin/test/e2e/dynamic-bug.spec.ts +++ b/packages/webpack-plugin/test/e2e/dynamic-bug.spec.ts @@ -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( diff --git a/packages/webpack-plugin/test/e2e/dynamic-chunk-3rd-party-split-project.spec.ts b/packages/webpack-plugin/test/e2e/dynamic-chunk-3rd-party-split-project.spec.ts index cf9cfef46..6b2a20fda 100644 --- a/packages/webpack-plugin/test/e2e/dynamic-chunk-3rd-party-split-project.spec.ts +++ b/packages/webpack-plugin/test/e2e/dynamic-chunk-3rd-party-split-project.spec.ts @@ -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'); }); }); diff --git a/packages/webpack-plugin/test/e2e/projects/dynamic-bug/webpack.config.js b/packages/webpack-plugin/test/e2e/projects/dynamic-bug/webpack.config.js index 93910846e..21b90d973 100644 --- a/packages/webpack-plugin/test/e2e/projects/dynamic-bug/webpack.config.js +++ b/packages/webpack-plugin/test/e2e/projects/dynamic-bug/webpack.config.js @@ -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', diff --git a/packages/webpack-plugin/test/e2e/projects/dynamic-chunk-3rd-party-split-project/src/index.js b/packages/webpack-plugin/test/e2e/projects/dynamic-chunk-3rd-party-split-project/src/index.js index 8fab16a6d..cd1e28353 100644 --- a/packages/webpack-plugin/test/e2e/projects/dynamic-chunk-3rd-party-split-project/src/index.js +++ b/packages/webpack-plugin/test/e2e/projects/dynamic-chunk-3rd-party-split-project/src/index.js @@ -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');