Skip to content

Commit 8488c96

Browse files
authored
chore: fix dendron-plugin-views build (#3775)
* chore: fix `dendron-plugin-views` build This aim of this commit is to fix the build task within `dendron-plugin-views` package which currently results into the following error: ``` /home/nam/code/dendronhq/dendron/node_modules/zod-validation-error/node_modules/@swc/helpers/src/index.mjs Can't reexport the named export '__decorate' from non EcmaScript module (only default export is available) ``` The commit 419dec7 (PR: #3762) is responsible for this by adding a dependency which conflicts with the webpack build in `dendron-plugin-views`. That dependency uses withing its cjs build files `@swc/helpers` which conflicts with the import type from webpack. The solution is to use explicitly set [`Rule.type`](https://webpack.js.org/configuration/module/#ruletype) property which was introduced in [webpack 4.0](https://github.com/webpack/webpack/releases/tag/v4.0.0): > javascript/auto: (The default one in webpack 3) Javascript module with all module systems enabled: CommonJS, AMD, ESM > javascript/esm handles ESM more strictly compared to javascript/auto: > Imported names need to exist on imported module > Dynamic modules (non-esm, i. e. CommonJs) can only imported via default import, everything else (including namespace import) emit errors > In .mjs modules are javascript/esm by default In my understanding setting the value `javascript/auto` tells webpack that it allows for `mjs` files to be not ESM strict. This is a kind of hack and curcumvents the issue. In a proper setup `mjs` should only be handled as esm modules and nothing else. So instead of changing how webpack sees `mjs` file we might want to revert the change that introduced this issue. References - webpack/webpack#16213 (comment) * chore(internal): setup `dendron-plugin-views` build to prefer `main` entry field References - webpack/webpack#6459 (comment) - graphql/graphql-js#1272 (comment) - apollographql/apollo-link-state#302 (comment) * chore(internal): reverting to prevent increased bundle size Webpacks's treeshaking is negatively impacted by telling it to prefer `main` field instead of `module`. `module` point to esm modules which are what webpack needs to do its [treeshaking](https://webpack.js.org/guides/tree-shaking/). * chore(internal): pin version of `zod-validation-error` Intead of changing ``dendron-plugin-views` webpack build config this commits pins `zod-validation-error` to an older version within its dependency to `@swc/helpers` does not conflict with webpack rules.
1 parent 3553670 commit 8488c96

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

packages/common-all/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
"title": "^3.4.4",
5454
"vscode-uri": "^3.0.3",
5555
"zod": "3.19.1",
56-
"zod-validation-error": "^0.2.1"
56+
"zod-validation-error": "^0.1.1",
57+
"@swc/helpers": "^0.3.2"
5758
},
5859
"devDependencies": {
5960
"@types/fast-levenshtein": "^0.0.2",

yarn.lock

+8-10
Original file line numberDiff line numberDiff line change
@@ -3823,10 +3823,10 @@
38233823
dependencies:
38243824
tslib "^2.4.0"
38253825

3826-
"@swc/helpers@^0.4.11":
3827-
version "0.4.12"
3828-
resolved "https://registry.npmjs.org/@swc/helpers/-/helpers-0.4.12.tgz#203243e78cff3c87c081c97ae548ab33e2503573"
3829-
integrity sha512-R6RmwS9Dld5lNvwKlPn62+piU+WDG1sMfsnfJioXCciyko/gZ0DQ4Mqglhq1iGU1nQ/RcGkAwfMH+elMSkJH3Q==
3826+
"@swc/helpers@^0.3.2":
3827+
version "0.3.17"
3828+
resolved "https://registry.npmjs.org/@swc/helpers/-/helpers-0.3.17.tgz#7c1b91f43c77e2bba99492162a498d465ef253d5"
3829+
integrity sha512-tb7Iu+oZ+zWJZ3HJqwx8oNwSDIU440hmVMDPhpACWQWnrZHK99Bxs70gT1L2dnr5Hg50ZRWEFkQCAnOVVV0z1Q==
38303830
dependencies:
38313831
tslib "^2.4.0"
38323832

@@ -27254,12 +27254,10 @@ zen-observable@^0.8.0:
2725427254
resolved "https://registry.npmjs.org/zen-observable/-/zen-observable-0.8.15.tgz#96415c512d8e3ffd920afd3889604e30b9eaac15"
2725527255
integrity sha512-PQ2PC7R9rslx84ndNBZB/Dkv8V8fZEpk83RLgXtYd0fwUgEjseMn1Dgajh2x6S8QbZAFa9p2qVCEuYZNgve0dQ==
2725627256

27257-
zod-validation-error@^0.2.1:
27258-
version "0.2.1"
27259-
resolved "https://registry.npmjs.org/zod-validation-error/-/zod-validation-error-0.2.1.tgz#d855c8bba835f43692756670d407453424a7ba5b"
27260-
integrity sha512-zGg6P5EHi5V0dvyEeC8HBZd2pzp7QDKTngkSWgWunljrY+0SHkHyjI519D+u8/37BHkGHAFseWgnZ2Uq8LNFKg==
27261-
dependencies:
27262-
"@swc/helpers" "^0.4.11"
27257+
zod-validation-error@^0.1.1:
27258+
version "0.1.1"
27259+
resolved "https://registry.npmjs.org/zod-validation-error/-/zod-validation-error-0.1.1.tgz#9d231d934c3c23f2fa66c067edcb520ab78decfc"
27260+
integrity sha512-uRXWNeI6XyZtO2pr6D/gk+ths0WCrV+OImIk1YikwwztOQvO5jbFzbnY642iRmLSCFaOIsFF4u7YQIub7CFh2Q==
2726327261

2726427262
2726527263
version "3.19.1"

0 commit comments

Comments
 (0)