Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Allow non-Webpack Workers Sites #1833

Merged
merged 3 commits into from
Apr 9, 2021
Merged

Allow non-Webpack Workers Sites #1833

merged 3 commits into from
Apr 9, 2021

Conversation

GregBrimble
Copy link
Member

Right now, custom build commands don't work with Workers SItes. This should enable them.

@GregBrimble GregBrimble requested a review from xortive April 2, 2021 20:06
@GregBrimble GregBrimble requested a review from a team as a code owner April 2, 2021 20:06
@@ -327,7 +321,7 @@ impl Manifest {
Not inherited: Must be defined for every environment individually.
*/
let mut target = Target {
target_type, // Top level
Copy link
Contributor

Choose a reason for hiding this comment

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

top level is correct -- we don't let you override target_type in environments

Copy link
Contributor

@xortive xortive left a comment

Choose a reason for hiding this comment

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

Could we:

  • forbid the rust type (it won't work)
  • for the javascript type fail if no [build], or a [build] section with no/empty command? Something like:
Workers Sites requires using a bundler, and your configuration indicates that you aren't using one. You can fix this by:
* setting your project type to "webpack" to use our automatically configured webpack bundler.
* setting your project type to "javascript", and configuring a build command in the `[build]` section if you wish to use your choice of bundler.

@@ -89,7 +97,7 @@ pub fn build(
log::info!("Plain JavaScript project detected. Publishing...");
let package_dir = target.package_dir()?;
let package = Package::new(&package_dir)?;
let script_path = package.main(&package_dir)?;
let script_path = package_dir.join(package.main(&package_dir)?);
Copy link
Contributor

Choose a reason for hiding this comment

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

why the change here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Without it, script_path is relative to the entrypoint. By joining package_dir with script_path, we get an absolute path, which is needed since wrangler actually executes in the project directory (parent).

So yes, it's needed, otherwise wrangler can't find that script to deploy.

TargetType::JavaScript => {
if let Some(build) = &self.build {
if build.command.is_none() {
failure::bail!(format!(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: would be nice if this message wasn't duplicated but I'm not too bothered by it if it's inconvenient to structure the code that way

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

Successfully merging this pull request may close these issues.

2 participants