Parcel: 馃悰 Cannot assign to window object using `watch` or `build`

Created on 30 Jan 2018  路  2Comments  路  Source: parcel-bundler/parcel

When i work with parcel index.html the resulting files and served page can assign to window object.
However if I use watch or build window object doesn't have any of the assigned properties.

馃帥 Configuration (.babelrc, package.json, cli command)

{
"name": "cli",
"version": "1.0.0",
"license": "MIT",
"scripts": {
"dev-serve": "parcel src/index.html -d build --no-cache",
"watch": "parcel watch src/index.html -d build --no-cache",
"build": "parcel build src/index.html -d build --no-minify --no-cache",
"start": "yarn build"
},
"devDependencies": {
"parcel-bundler": "^1.5.1",
"typescript": "^2.6.2"
}
}

馃 Expected Behavior

watch and build should allow assigning to window object as `parcel index.html``

either with

  • "prestart": "yarn build",
  • "prestart": "yarn watch",
  1. yarn start
  2. in my browser console: foo should not be undefined
  3. in my browser console: help should not be undefined
  4. in my browser console: helpts should not be undefined

馃槸 Current Behavior

window object doesn't get any of the assigned props.

either with

  • "prestart": "yarn build",
  • "prestart": "yarn watch",
  1. yarn start
  2. in my browser console: foo is undefined
  3. in my browser console: help is undefined
  4. in my browser console: helpts is undefined

dev-serve behaves correctly

馃拋 Possible Solution

I don't know about the implementation, but I just recommend they all behave as the dev-serve. If unwanted then dev serve should behave like watch and build and at least we could provide a flag (although that would be a feature request instead)

馃寧 Environment

| Software | Version(s)
| Parcel | 1.5.1
| Node | 8.9.2
| Yarn | 1.2.1
| OS | Windows 10 Pro

Bug

Most helpful comment

This has nothing to do about window.
If you look t it, the js was not found.

Use this to generate files: parcel watch src/index.html -d build --public-url=./

All 2 comments

This has nothing to do about window.
If you look t it, the js was not found.

Use this to generate files: parcel watch src/index.html -d build --public-url=./

Thanks for letting me know what the issue was niicojs, however I am filing a new bug because I don't think this is desired. https://github.com/parcel-bundler/parcel/issues/714

Was this page helpful?
0 / 5 - 0 ratings

Related issues

oliger picture oliger  路  3Comments

davidnagli picture davidnagli  路  3Comments

466023746 picture 466023746  路  3Comments

termhn picture termhn  路  3Comments

algebraic-brain picture algebraic-brain  路  3Comments