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

ember build modifies node_modules by populating esm cache #7379

Closed
chancancode opened this issue Nov 9, 2020 · 6 comments · Fixed by #8042
Closed

ember build modifies node_modules by populating esm cache #7379

chancancode opened this issue Nov 9, 2020 · 6 comments · Fixed by #8042

Comments

@chancancode
Copy link
Member

Reproduction

/tmp ❯❯❯ ember new --yarn zomg
installing app
Ember CLI v3.22.0

✨  Creating a new Ember app in /private/tmp/zomg:
  create .editorconfig
  create .ember-cli
  create .eslintignore
  create .eslintrc.js
  create .template-lintrc.js
  create .travis.yml
  create .watchmanconfig
  create README.md
  create app/app.js
  create app/components/.gitkeep
  create app/controllers/.gitkeep
  create app/helpers/.gitkeep
  create app/index.html
  create app/models/.gitkeep
  create app/router.js
  create app/routes/.gitkeep
  create app/styles/app.css
  create app/templates/application.hbs
  create config/ember-cli-update.json
  create config/environment.js
  create config/optional-features.json
  create config/targets.js
  create ember-cli-build.js
  create .gitignore
  create package.json
  create public/robots.txt
  create testem.js
  create tests/helpers/.gitkeep
  create tests/index.html
  create tests/integration/.gitkeep
  create tests/test-helper.js
  create tests/unit/.gitkeep
  create vendor/.gitkeep

🚧  Installing packages... This might take a couple of minutes.
Yarn: Installed dependencies

🎥  Initializing git repository.
Git: successfully initialized.

🎉  Successfully created project zomg.
👉   Get started by typing:

  $ cd zomg
  $ yarn start

Happy coding!
/tmp ❯❯❯ cd zomg
/t/zomg ❯❯❯ sed -i '' '/node_modules/d' .gitignore
/t/zomg ❯❯❯ git diff
diff --git a/.gitignore b/.gitignore
index c40a1b2..bb2b3da 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,7 +6,6 @@

 # dependencies
 /bower_components/
-/node_modules/

 # misc
 /.env*
@@ -20,6 +19,5 @@
 /yarn-error.log

 # ember-try
-/.node_modules.ember-try/
 /bower.json.ember-try
 /package.json.ember-try
/t/zomg ❯❯❯ git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   .gitignore

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	node_modules/

no changes added to commit (use "git add" and/or "git commit -a")
/t/zomg ❯❯❯ git add .
/t/zomg ❯❯❯ git commit -m "snapshot node_modules"
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
[master 13798b2] snapshot node_modules
 34523 files changed, 3573631 insertions(+), 2 deletions(-)
/t/zomg ❯❯❯ ember build
Environment: development
cleaning up...
Built project successfully. Stored in "dist/".
/t/zomg ❯❯❯ git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

	node_modules/@ember-data/private-build-infra/node_modules/.cache/
	node_modules/esm/node_modules/

nothing added to commit but untracked files present (use "git add" to track)
/t/zomg ❯❯❯ tree node_modules/@ember-data/private-build-infra/node_modules/.cache/
node_modules/@ember-data/private-build-infra/node_modules/.cache/
└── esm
    ├── addd920c128a19ba.js
    └── d0446dc2128a19ba.js

1 directory, 2 files

Description

After a ember build, ember data adds extra files to the node_modules directory.

Versions

I think this has been an issue for the last few versions at least, but this was tested using 3.22

@snewcomer
Copy link
Contributor

ref #7322

@chancancode
Copy link
Member Author

Hmm it seems like that PR should have been included in 3.22 right?

@snewcomer
Copy link
Contributor

In my testing, this cache was always created (just tested on 3.18). { cache: false } was meant to avoid using that cache at run time. I have not yet seen a way to avoid creating the cache and am not sure if this is a bug or the feature.

https://github.com/standard-things/esm#devopts

As a side note, I noticed some potential bugs with esm.

Current
Screen Shot 2020-11-09 at 9 53 42 PM

With
process.env.ESM_DISABLE_CACHE = true as well as { cache: false }.
Screen Shot 2020-11-09 at 9 59 19 PM

So we are still creating something.

I think there is still some investigation here.

@rwjblue
Copy link
Member

rwjblue commented Nov 18, 2020

Since Node 12 and higher support modules natively, maybe we should look into use the native support when we can (and fallback to esm).

@runspired runspired changed the title ember build modifies node_modules ember build modifies node_modules by populating esm cache Apr 13, 2021
@runspired
Copy link
Contributor

I recently did some work requiring interop of native modules with cjs modules for node-12. Said interop requires using the experimental modules support flag when running the script and importing via await import() to get it working. I don't think we can do this considering this script runs for end users until node > 12 since we can't ask them to always run things with the flag.

@NullVoxPopuli
Copy link
Contributor

the existence of esm prevents ember-data from being used on stackblitz (See #8021 (and related issues))

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 a pull request may close this issue.

5 participants