Skip to content

Commit

Permalink
Merge pull request #415 from ef4/entry-asset-url
Browse files Browse the repository at this point in the history
respect publicAssetURL for entry chunks
  • Loading branch information
ef4 committed Jun 24, 2021
2 parents 2bf7100 + dc8fed3 commit 56cdf5b
Show file tree
Hide file tree
Showing 5 changed files with 14,171 additions and 260 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Supported Options
- `alias`: _object_, Map from imported names to substitute names that will be imported instead. This is a prefix match by default. To opt out of prefix-matching and only match exactly, add a `$` suffix to the pattern.
- `exclude`: _list of strings, defaults to []_. Packages in this list will be ignored by ember-auto-import. Can be helpful if the package is already included another way (like a shim from some other Ember addon).
- `forbidEval`: _boolean_, defaults to false. We use `eval` in development by default (because that is the fastest way to provide sourcemaps). If you need to comply with a strict Content Security Policy (CSP), you can set `forbidEval: true`. You will still get sourcemaps, they will just use a slower implementation.
- `publicAssetURL`: where to load additional dynamic javascript files from. You usually don't need to set this -- the default works for most apps. However, if you're using `<script defer>` or another method of asynchronously loading your vendor.js script you will need to set this to the URL where your asset directory is served (typically `/assets`).
- `publicAssetURL`: the public URL to your `/assets` directory on the web. Many apps won't need to set this because we try to detect it automatically, but you will need to set this explicitly if you're deploying your assets to a different origin than your app (for example, on a CDN) or if you are using `<script defer>` (which causes scripts to be unable to guess what origin they loaded from).
- `skipBabel`: _list of objects, defaults to []_. The specified packages will be skipped from babel transpilation.
- `watchDependencies`: _list of strings or string arrays, defaults to []_. Tells ember-auto-import that you'd like to trigger a rebuild if one of these auto-imported dependencies changes. Pass a package name that refers to one of your own dependencies, or pass an array of package names to address a deeper dependency.
- `webpack`: _object_, An object that will get merged into the configuration we pass to webpack. This lets you work around quirks in underlying libraries and otherwise customize the way Webpack will assemble your dependencies.
Expand Down
28 changes: 28 additions & 0 deletions docs/upgrade-guide-2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- apps must add webpack to their own dependencies (`yarn add --dev webpack@5` or `npm install --save-dev webpack@5`)
- apps that were adding css handling (like `css-loader`, `style-loader`, and `MiniCSSExtraPlugin`) to the webpack config must remove those, because they're now included by default for compatibility with the embroider v2 package spec.
- apps should confirm that their deployment strategy includes all files produced under `dist` (not just the traditional expected ones like `dist/assets/your-app.js` and `dist/assets/vendor.js`)
- apps that use `fingerprint.preprend` to move their assets to a different origin will also need to set `autoImport.publicAssetURL`. See example below.
- addons that upgrade to ember-auto-import >= 2 will only work in apps that have ember-auto-import >= 2, so they should do their own semver major releases when they upgrade
- our `alias` option has changed slightly to align better with how it works in webpack
- we dropped support for node < 12 and ember-source < 3.4 and ember-cli < 3.4.
Expand Down Expand Up @@ -47,6 +48,33 @@ Today entry chunks are appended to vendor.js (and vendor.css if you manually add

2.0 inserts script (and link) tags directly into index.html instead. This is better for all the reasons above. The only potential downside is that the presence of these new files in dist may impact people with unnecessarily-specific deployment code that, instead of deploying `dist/*` like they should, deploys only `dist/assets/app.js`, `dist/assets/vendor.js`, etc, without noticing the new `dist/assets/chunk*.{js,css}` we emitted.

### publicAssetURL

If you use broccoli-asset-rev to move your assets:

```js
let app = new EmberApp(defaults, {
fingerprint: {
enabled: EmberApp.env() === 'production',
prepend: 'http://some-cdn/xyz',
},
});
```

You will also need to set ember-auto-import's `publicAssetURL`:

```js
let app = new EmberApp(defaults, {
fingerprint: {
enabled: EmberApp.env() === 'production',
prepend: 'http://some-cdn/xyz',
},
autoImport: {
pubicAssetURL: EmberApp.env() === 'production' ? 'https://some-cdn/xyz/assets' : undefined,
},
});
```

### Mandatory top-level auto-import

When used by an addon, ember-auto-import 2.0 will assert that the top-level app package has ember-auto-import >= 2.0. Therefore, addons that upgrade to ember-auto-import 2.0 should do their own semver major releases, and document that they now require ember-auto-import 2.0 in the app. This implies that semver major releases are needed recursively up the dependency chain if an addon is using an addon that upgrades to ember-auto-import 2.0.
Expand Down
Loading

0 comments on commit 56cdf5b

Please sign in to comment.