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

Generated npm_umd_bundle misses package scope in package_name #1095

Closed
ashi009 opened this issue Sep 5, 2019 · 4 comments
Closed

Generated npm_umd_bundle misses package scope in package_name #1095

ashi009 opened this issue Sep 5, 2019 · 4 comments
Labels
Milestone

Comments

@ashi009
Copy link
Contributor

ashi009 commented Sep 5, 2019

🐞 bug report

Affected Rule

npm_umd_bundle

https://github.com/gregmagolan/rules_nodejs/blob/27e2b68da628f5dd1c9f109f2cf605a30f4b7baa/internal/npm_install/generate_build_file.js#L533

Is this a regression?

No

Description

For scoped packages, the ts_devserver will require() the package using it's scoped package name (say, @scope/pkg). However, the generated umd file only uses the last segment of the name (pkg), which doesn't match the required name.

🔬 Minimal Reproduction

git clone https://github.com/ashi009/rules_nodejs_npm_umd_bundle.git
cd rules_nodejs_npm_umd_bundle
bazel run :devserver

🔥 Exception or Error


ts_scripts.js:1962 GET http://localhost:5432/@blueprintjs/core.js net::ERR_ABORTED 404 (Not Found)
req.load @ ts_scripts.js:1962
load @ ts_scripts.js:1686
load @ ts_scripts.js:835
fetch @ ts_scripts.js:825
check @ ts_scripts.js:857
enable @ ts_scripts.js:1177
enable @ ts_scripts.js:1558
(anonymous) @ ts_scripts.js:1162
(anonymous) @ ts_scripts.js:135
each @ ts_scripts.js:60
enable @ ts_scripts.js:1114
enable @ ts_scripts.js:1558
(anonymous) @ ts_scripts.js:1162
(anonymous) @ ts_scripts.js:135
each @ ts_scripts.js:60
enable @ ts_scripts.js:1114
init @ ts_scripts.js:789
(anonymous) @ ts_scripts.js:1461
setTimeout (async)
req.nextTick @ ts_scripts.js:1816
localRequire @ ts_scripts.js:1450
requirejs @ ts_scripts.js:1798
(anonymous) @ ts_scripts.js:43529
12:12:24.940 ts_scripts.js:169 Uncaught Error: Script error for "@blueprintjs/core", needed by: umd/index
http://requirejs.org/docs/errors.html#scripterror
    at makeError (ts_scripts.js:169)
    at HTMLScriptElement.onScriptError (ts_scripts.js:1739)
makeError @ ts_scripts.js:169
onScriptError @ ts_scripts.js:1739
error (async)
req.load @ ts_scripts.js:1944
load @ ts_scripts.js:1686
load @ ts_scripts.js:835
fetch @ ts_scripts.js:825
check @ ts_scripts.js:857
enable @ ts_scripts.js:1177
enable @ ts_scripts.js:1558
(anonymous) @ ts_scripts.js:1162
(anonymous) @ ts_scripts.js:135
each @ ts_scripts.js:60
enable @ ts_scripts.js:1114
enable @ ts_scripts.js:1558
(anonymous) @ ts_scripts.js:1162
(anonymous) @ ts_scripts.js:135
each @ ts_scripts.js:60
enable @ ts_scripts.js:1114
init @ ts_scripts.js:789
(anonymous) @ ts_scripts.js:1461
setTimeout (async)
req.nextTick @ ts_scripts.js:1816
localRequire @ ts_scripts.js:1450
requirejs @ ts_scripts.js:1798
(anonymous) @ ts_scripts.js:43529

🌍 Your Environment

Operating System:

  
macOS 10.14.6
  

Output of bazel version:

  
$ bazel version
Build label: 0.29.0
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed Aug 28 14:37:40 2019 (1567003060)
Build timestamp: 1567003060
Build timestamp as int: 1567003060
  

Rules version (SHA):

  
0.36.2
  

Anything else relevant?

@ghost
Copy link

ghost commented Sep 10, 2019

I am also having this issue with @material-ui/core. Did you find a workaround?

@ashi009
Copy link
Contributor Author

ashi009 commented Sep 11, 2019 via email

@ghost
Copy link

ghost commented Sep 11, 2019 via email

@gregmagolan gregmagolan added this to the 1.0 milestone Sep 19, 2019
@pyle
Copy link

pyle commented Oct 20, 2019

Also came across where import '@polymer/paper-progress'; would fail with the same error above.
Changing to import 'paper-progress' removes this error and the component/devserver loads the page.
Only problem is when changing to import 'paper-progress'; this then fails in module resolution for a rollup_bundle()

I've not found problems with packages that aren't namespaces like import {} 'lit-element';
Also not isolated to just @polymer/* packages, other webcomponents throw the same import error but load in rollup_bundle/web_package

afaik 0.38.3 should have the patch above unless im missing something.

Example build rule:

ts_library(
    name = "main",
    srcs = ["main.ts"],
    tsconfig = ":tsconfig.json",
    deps = [
        "//shared_app",
        "@npm//@webcomponents/webcomponentsjs",
        "@npm//lit-html",
    ],
)

ts_devserver(
    name = "devserver",
    additional_root_paths = [
        "npm/node_modules/core-js/client",
        "npm/node_modules/systemjs/dist",
    ],
    data = [
        "//assets",
        "@npm//:node_modules/core-js/client/core.min.js",
        "@npm//:node_modules/systemjs/dist/system.js",
    ],
    entry_module = "ui/main",
    index_html = "index.html",
    static_files = _ASSETS,
    deps = [
        ":main",
        "@npm//@polymer/paper-progress:paper-progress__umd",
        "@npm//lit-element:lit-element__umd",
    ],
)
http_archive(
    name = "build_bazel_rules_nodejs",
    sha256 = "ad4be2c6f40f5af70c7edf294955f9d9a0222c8e2756109731b25f79ea2ccea0",
    urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.38.3/rules_nodejs-0.38.3.tar.gz"],
)

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

No branches or pull requests

4 participants