-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add transpiled ES Module build with microbundle #9
Conversation
- Add module entrypoint (index.js) - Use whitelist of files (/src, /dist/sources.*) instead of .npmignore - Add build target using microbundle and rename existing example builds See geoblocks/base#4
@@ -1,4 +1,5 @@ | |||
/node_modules/ | |||
/package-lock.json | |||
/dist/api | |||
/dist/main.js | |||
/dist/main.* | |||
/dist/sources.* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just /dist/
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because dist/index.html
is (and was already before) part of the git source, it's the example entry point, so it should not be ignored. Ideally it should not be in dist IMHO, I can change that in a follow-up PR if you agree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 :-)
"doc": "typedoc --out dist/api --theme minimal --readme none --hideGenerator --listInvalidSymbolLinks --toc none" | ||
}, | ||
"files": [ | ||
"/src", | ||
"/dist/sources.*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just /dist
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, /dist/index.html
and /dist/main.js[.map]
are example / example build files that don't need to be included in the npm package.
package.json
Outdated
"start": "webpack-dev-server --mode development --content-base dist/ --watch", | ||
"typecheck": "tsc --pretty", | ||
"lint": "npm run eslint && npm run typecheck", | ||
"test": "npm run lint && npm run build && npm run build-debug", | ||
"test": "npm run lint && npm run build-example && npm run build-example-debug", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order for the microbundle build to be tested by travis, you should also add it here, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good point, I added it.
@romanzoller, I pushed a commit to make "npm link" work. |
@romanzoller, the code is still importing proj directly from the src files. You need to change that tp benefit from your changes in @geoblocks/proj. So I did: diff --git a/src/Swisstopo.js b/src/Swisstopo.js
index 9240e56..f9f8a37 100644
--- a/src/Swisstopo.js
+++ b/src/Swisstopo.js
@@ -1,7 +1,7 @@
import olSourceWMTS from 'ol/source/WMTS.js';
import olTilegridWMTS from 'ol/tilegrid/WMTS.js';
-import EPSG_2056 from '@geoblocks/proj/src/EPSG_2056.js';
-import EPSG_21781 from '@geoblocks/proj/src/EPSG_21781.js';
+import {EPSG_2056} from '@geoblocks/proj';
+import {EPSG_21781} from '@geoblocks/proj';
/** Then ran I think the reason is that:
If I build the proj project I guess it will succeed but then updating a proj file will not live reload the code anymore. Do you see a solution that keeps npm link working? |
This should not be required, I was trying to make only minimal changes in order to get things merged asap. The changes in @geoblocks/proj are only relevant for using proj somewhere else, we should be able to keep importing source files here. See also https://github.com/camptocamp/ti-oerebviewer/pull/67/commits/f48961ac480a766272d4ae0164c37119a983e2d0 about npm link, I think the easiest way to get around the npm link mess would be to publish new versions of geoblocks/proj and geoblocks/sources. |
@romanzoller, you are using the source here: https://github.com/camptocamp/ti-oerebviewer/pull/67/files#diff-ef47f283833c2e4c42778c3038ed1278L6. Since it depends on the non-transpiled ES6 sources from proj it will not fix your IE11 issue, right? |
@romanzoller, I think having paths pointing to
|
@romanzoller, @sbrunner, @fredj, would you be interested in a small (?) meeting this afternoon to:
|
You are technically right, but I was lucky, because in geoblocks/sources, only 2 strings are imported from geoblocks/proj, so there is nothing that breaks IE11. I guess I should change it anyway.
Pointing to Unfortunately the meaning of
Sure! |
@romanzoller, you need to release a geoblocks/proj package on npm and test it here.
Please also add the "geoblocks_src: src/index.js" entry in |
I think it was even more luck as the registration of the projection is done as a side effect of the import. |
done 👍
@gberaudo I don't really understand this part... Would you then remove the "source" entry? Is it causing any problems? And what is the purpose of adding "geoblocks_src"? |
|
Well, it's not standard, but it's used by microbundle, parcel, and maybe others, and might be standard in the future, whereas "geoblocks_src" is used by nobody and will for sure never be a standard, and (AFAIK) is also not necessary if you want to include sources in another project, you could already do that before without any "source" or "geoblocks_src" field and you can still do it now that "source" is there. |
@romanzoller, I checked parcel and found it has 3 ways of using the That is why I ask we use a custom entry for the geoblocks project that no one else will use inadvertently, and which semantics we can define clearly: geoblocks_src points to a single file entry point of standard Ecmascript (no esnext, no proposal, only the rock solid standard). Regarding your second point:
In an application |
Do you mean something like this? (tested and works in an empty temp folder, no "geoblocks_src" in the latest @geoblocks/proj)
|
No, I am saying: A
My understanding is that in this snippet the
The only way to avoid this is to have weback use entries like `geoblocks_src'. |
No need to change anything with microbundle, it turns out that it already looks for ./src/index.js or ./index.js (in that order) by default.
Ok, thank you for the explanations @gberaudo, I added a commit => good to merge? |
index.js
)/src
,/dist/sources.*
) instead of.npmignore
See geoblocks/base#4