Skip to content
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: use parcel for packaging ReSpec #1493

Closed
wants to merge 6 commits into from

Conversation

nileshgulia1
Copy link

@nileshgulia1 nileshgulia1 commented Feb 9, 2018

Closes #1129

@saschanaz @marcoscaceres .I have closed old PR for some rebasing and conflicting issues.This patch bundles required js files which are dependencies in basic.html including w3c common.js to builds directory.

@saschanaz
Copy link
Collaborator

(The result should be respec-w3c-common.js rather than basic.js)

package.json Outdated
@@ -71,7 +71,7 @@
"test:karma": "npm run karma",
"prepare": "npm run snyk-protect",
"prepublish": "npm run snyk-protect",
"parcel": "parcel ./examples/basic.html -d ./builds"
"parcel": "parcel ./builds/respec-w3c-common.js -d ./builds/output"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@saschanaz Done!

@nileshgulia1
Copy link
Author

@marcoscaceres Can we have it merged now?

@marcoscaceres
Copy link
Contributor

I’m still unsure what this does? I’m sure it does something useful, but can you help me understand what advantages it brings to the project.

@nileshgulia1
Copy link
Author

@marcoscaceres Parcel bundles w3.respec.common.js and its linked dependencies to build folder. I thought that parcel-bundler is very good ,but it doesn't support multiple entry points which is needed here, I have used it because of its easy setup, no config file etc. It also enables uglify.js within itself to minify the code so we can refrain from using some packages here.

@marcoscaceres
Copy link
Contributor

@saschanaz, what’s your opinion? Worth using?

@@ -77,16 +76,6 @@ See original source for licenses: https://github.com/w3c/respec */
window.respecVersion = "${version}";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm run parcel currently skips adding boilerplate, we should add it.

Copy link
Collaborator

@saschanaz saschanaz Feb 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Note that this is also broken in master. (Comments disappear!))

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm run parcel currently skips adding boilerplate, we should add it.

Which boilerplate?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@saschanaz
Copy link
Collaborator

saschanaz commented Feb 12, 2018

I haven't really tried this PR yet, but I'm not sure why the test failures we've seen on #1489 do not occur here (as parcel also uses uglify-es).

@saschanaz
Copy link
Collaborator

And can you push your package-lock.json changes, as it helps seeing dependency changes + boosts installation speed?

@marcoscaceres
Copy link
Contributor

@nileshgulia1, you probably want to give this a rebase before adding your package-lock.

@marcoscaceres marcoscaceres changed the title Bundled some files chore: use parcel for packaging ReSpec Feb 12, 2018
@saschanaz
Copy link
Collaborator

yarn is good, but I'm not sure we should maintain both lock files...

@@ -6,7 +6,6 @@ node_js:
install:
- npm install
- npm run build
- npm run build:respec-w3c-common
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add npm run parcel here, but npm run parcel never ends on my local environment. Not sure what's happening.

@@ -71,7 +70,8 @@
"test:headless": "node ./tests/headless.js",
"test:karma": "npm run karma",
"prepare": "npm run snyk-protect",
"prepublish": "npm run snyk-protect"
"prepublish": "npm run snyk-protect",
"parcel": "parcel ./builds/respec-w3c-common.js -d ./builds/output"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build is omitted: "parcel build ./builds/respec-w3c-common.js -d ./builds/output"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I Have tried adding build before but is repeatedly throws this error:

parcel build ./builds/respec-w3c-common.js -d ./builds/output

🚨  /home/nilesh/respec/builds/respec-w3c-common.js: sym.definition is not a function
    at may_modify (eval at <anonymous> (/home/nilesh/respec/node_modules/uglify-es/tools/node.js:21:1), <anonymous>:8931:31)
    at TreeTransformer.abort [as before] (eval at <anonymous> (/home/nilesh/respec/node_modules/uglify-es/tools/node.js:21:1), <anonymous>:8541:74)
    at AST_VarDef.eval [as transform] (eval at <anonymous> (/home/nilesh/respec/node_modules/uglify-es/tools/node.js:21:1), <anonymous>:4570:35)
    at eval (eval at <anonymous> (/home/nilesh/respec/node_modules/uglify-es/tools/node.js:21:1), <anonymous>:4586:25)
    at doit (eval at <anonymous> (/home/nilesh/respec/node_modules/uglify-es/tools/node.js:21:1), <anonymous>:130:23)
    at MAP (eval at <anonymous> (/home/nilesh/respec/node_modules/uglify-es/tools/node.js:21:1), <anonymous>:156:52)
    at do_list (eval at <anonymous> (/home/nilesh/respec/node_modules/uglify-es/tools/node.js:21:1), <anonymous>:4585:16)
    at eval (eval at <anonymous> (/home/nilesh/respec/node_modules/uglify-es/tools/node.js:21:1), <anonymous>:4664:28)
    at AST_Const.eval [as transform] (eval at <anonymous> (/home/nilesh/respec/node_modules/uglify-es/tools/node.js:21:1), <anonymous>:4573:17)
    at collapse (eval at <anonymous> (/home/nilesh/respec/node_modules/uglify-es/tools/node.js:21:1), <anonymous>:8617:39)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, this is the uglify-es problem we met in #1489 that will be fixed in its next release. See mishoo/UglifyJS#2896

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do not use it until new release ,Using --no-minify removes this error for me. parcel-bundler/parcel#8. What do you think @saschanaz @marcoscaceres ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We ultimately want to minify this, otherwise the bundle size will be huge... so we are kinda stuck until the next Uglify release.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--no-minify may still be good for debugging purpose, where source mapping is frequently not perfect.

@saschanaz
Copy link
Collaborator

I'm getting error logs when building:

> npm run parcel

> respec@19.2.0 parcel C:\Users\sasch\Documents\GitHub\respec
> parcel build ./builds/respec-w3c-common.js -d ./builds/output

∞  Building respec-w3c-common.js...
Condition always false [0:2608,20]
Condition left of && always false [0:2617,87]
Dropping unreachable code [0:2867,384]
Declarations in unreachable code! [0:2867,384]
Dropping unreachable code [0:3099,151]
Declarations in unreachable code! [0:3099,151]
Function.protoype.arguments not supported [0:4182,628]
Function.protoype.arguments not supported [0:4188,164]
Dropping duplicated definition of variable ADa [0:4435,14]
Function.protoype.arguments not supported [0:4616,49]
Function.protoype.arguments not supported [0:4616,67]
Function.protoype.arguments not supported [0:4630,120]
Function.protoype.arguments not supported [0:4707,361]
Function.protoype.arguments not supported [0:4798,41]
Function.protoype.arguments not supported [0:4798,73]
Function.protoype.arguments not supported [0:4830,24]
Dropping duplicated definition of variable dLa [0:4840,25]
Function.protoype.arguments not supported [0:4930,22]
Non-strict equality against boolean: == false [0:5302,6]
Non-strict equality against boolean: == false [0:5302,63]
Dropping unreachable code [0:5652,184]
√  Built in 16.58s.

Too hard to understand as it never says what file is in problem.

Also, we should be able to get a non-minified version of file:

Ok, but it would be a hard requirement that we can generate a concatenated, but not minified, version for development... otherwise, debugging is going to be extremely hard. Sourcemaps are very very broken across browsers, so definitely don't want to be reliant on them (been there, done that, never again 🤪).

.travis.yml Outdated
@@ -6,6 +6,7 @@ node_js:
install:
- npm install
- npm run build
- npm run parcel
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding npm run parcel is causing travis to fail.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@saschanaz Should I remove this ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is the required step. I think npm run build should be completely replaced by npm run parcel, as that's the whole purpose of using parcel.

@saschanaz
Copy link
Collaborator

saschanaz commented Feb 14, 2018

Currently we are generating transpiled non-concatenated files into js/ and examples/basic.html uses them. parcel removes the need of them, and then we probably should remove basic.html as we already have basic.built.html.

Additionally, we can remove direct babel dependency as all those things should be processed by parcel.

(BTW, I'm still worrying about recent uglify-es breakage though... Using parcel will lock the dependency, we cannot consider babel-minify then.)

@marcoscaceres
Copy link
Contributor

Currently we are generating transpiled non-concatenated files into js/ and examples/basic.html uses them. parcel removes the need of them, and then we probably should remove basic.html as we already have basic.built.html.

I'm still super concerned about trying to work with sourcemaps and a fully bundled app (debugging experience is still really terrible), so I'd prefer to keep basic.html... at least, till I'm confident that source mapping support is sane.

@marcoscaceres
Copy link
Contributor

(I'm willing to try tho - super interested to see what comes out of all this)

@saschanaz
Copy link
Collaborator

I'm still super concerned about trying to work with sourcemaps and a fully bundled app (debugging experience is still really terrible)

Deeply agreed, but that means we should't use parcel at all, we are just adding a new dependency then.

@marcoscaceres
Copy link
Contributor

Deeply agreed, but that means we should't use parcel at all, we are just adding a new dependency then.

Yeah, I'm kinda getting the same feeling - and can definitely live with the current setup. I guess eventually (in around 2 years) we will just be able to use ES Modules and native require() to import things we need. That seems fine to me.

@saschanaz
Copy link
Collaborator

saschanaz commented Feb 14, 2018

For a reference: this 2015 webpack issue webpack/webpack#1194 is still open 😞

@marcoscaceres
Copy link
Contributor

Lol, it was filed by an old friend on mine! Hi @Stuk!

@marcoscaceres
Copy link
Contributor

ok, I think we should close this.

@nileshgulia1, I want to say thanks for doing this investigation. This has been extremely helpful as it helped us understand the problem better. So, even though we aren't merging, we've learned a lot.

@Stuk
Copy link

Stuk commented Feb 15, 2018

Haha, hi @marcoscaceres 👋

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch to some other packaging system
4 participants