-
-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(internal): fix dendron-plugin-views
build
#3775
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
kevinslin
approved these changes
Nov 10, 2022
namjul
force-pushed
the
chore/fix-dendron-plugin-views-build
branch
from
November 11, 2022 09:24
b3f3892
to
6bdc46c
Compare
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)
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/).
namjul
force-pushed
the
chore/fix-dendron-plugin-views-build
branch
from
November 11, 2022 10:06
7400603
to
d4609a7
Compare
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.
Yes, I believe that should fail.
Found a version which works 5e406cc |
namjul
changed the title
chore: fix
chore(internal): fix Nov 11, 2022
dendron-plugin-views
builddendron-plugin-views
build
kevinslin
pushed a commit
that referenced
this pull request
Jun 11, 2023
* 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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This aim of this PR is to fix the build task within
dendron-plugin-views
package which currently results into the following error:The commit 419dec7 (PR: #3762) is responsible for this by adding a dependency
which conflicts with the webpack build in
dendron-plugin-views
. Thatdependency uses withing its cjs build files
@swc/helpers
whichconflicts with the import type from webpack.
@swc/helpers
provides amodule
entry https://github.com/swc-project/swc/blob/main/packages/swc-helpers/package.json#L6-L7 which has named reexports which gets flagged as an error.Update: Found a solution which works by pinning
zod-validation-error
to an other version: 5e406ccUpdate: I tried another solution to tell webpack to prefer main entry field instead of `module´. But since that would disable webpacks tree-shaking capabilities since this requries static module structure I reverted that change.
The solution is to use explicitly set
Rule.type
property which was introduced in webpack 4.0:In my understanding setting the value
javascript/auto
tells webpack that it allows formjs
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 torevert the change that introduced this issue.
Pull Request Checklist
If you are a community contributor, copy and paste the PR template from Dendron Community PR Checklist and add it to the body of the pull request.
If you are a team member, copy and paste the template from Dendron Extended PR Checklist.
To copy the template, click on the
Raw
button on the gist to copy the plaintext version of the template to this PR.