forked from emberjs/data
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: prebuilt v1 addons (emberjs#8353)
* feat: @ember-data/adapter as v2-lite addon * fix lint and docs src * remove unneded file * feat: @ember-data/serializer as v2-lite addon * fix docs src * feat: @ember-data/{model|record-data} as v2-lite addons
- Loading branch information
Showing
98 changed files
with
1,129 additions
and
355 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
const pkg = require('./package.json'); | ||
|
||
module.exports = { | ||
name: pkg.name, | ||
|
||
options: { | ||
'@embroider/macros': { | ||
setOwnConfig: {}, | ||
}, | ||
}, | ||
|
||
_emberDataConfig: null, | ||
configureEmberData() { | ||
if (this._emberDataConfig) { | ||
return this._emberDataConfig; | ||
} | ||
const app = this._findHost(); | ||
const isProd = /production/.test(process.env.EMBER_ENV); | ||
const hostOptions = app.options?.emberData || {}; | ||
const debugOptions = Object.assign( | ||
{ | ||
LOG_PAYLOADS: false, | ||
LOG_OPERATIONS: false, | ||
LOG_MUTATIONS: false, | ||
LOG_NOTIFICATIONS: false, | ||
LOG_REQUEST_STATUS: false, | ||
LOG_IDENTIFIERS: false, | ||
LOG_GRAPH: false, | ||
LOG_INSTANCE_CACHE: false, | ||
}, | ||
hostOptions.debug || {} | ||
); | ||
let HAS_DEBUG_PACKAGE, HAS_META_PACKAGE; | ||
|
||
try { | ||
// eslint-disable-next-line node/no-missing-require | ||
require.resolve('@ember-data/debug', { paths: [process.cwd(), __dirname] }); | ||
HAS_DEBUG_PACKAGE = true; | ||
} catch { | ||
HAS_DEBUG_PACKAGE = false; | ||
} | ||
try { | ||
// eslint-disable-next-line node/no-missing-require | ||
require.resolve('ember-data', { paths: [process.cwd(), __dirname] }); | ||
HAS_META_PACKAGE = true; | ||
} catch { | ||
HAS_META_PACKAGE = false; | ||
} | ||
const includeDataAdapterInProduction = | ||
typeof hostOptions.includeDataAdapterInProduction === 'boolean' | ||
? hostOptions.includeDataAdapterInProduction | ||
: HAS_META_PACKAGE; | ||
|
||
const includeDataAdapter = HAS_DEBUG_PACKAGE ? (isProd ? includeDataAdapterInProduction : true) : false; | ||
const DEPRECATIONS = require('@ember-data/private-build-infra/src/deprecations')(hostOptions.compatWith || null); | ||
const FEATURES = require('@ember-data/private-build-infra/src/features')(isProd); | ||
|
||
// copy configs forward | ||
const ownConfig = this.options['@embroider/macros'].setOwnConfig; | ||
ownConfig.compatWith = hostOptions.compatWith || null; | ||
ownConfig.debug = debugOptions; | ||
ownConfig.deprecations = Object.assign(DEPRECATIONS, ownConfig.deprecations || {}); | ||
ownConfig.features = Object.assign({}, FEATURES); | ||
ownConfig.includeDataAdapter = includeDataAdapter; | ||
|
||
this._emberDataConfig = ownConfig; | ||
return ownConfig; | ||
}, | ||
|
||
included() { | ||
this.configureEmberData(); | ||
return this._super.included.call(this, ...arguments); | ||
}, | ||
|
||
treeForVendor() { | ||
return; | ||
}, | ||
treeForPublic() { | ||
return; | ||
}, | ||
treeForStyles() { | ||
return; | ||
}, | ||
treeForAddonStyles() { | ||
return; | ||
}, | ||
treeForApp() { | ||
return; | ||
}, | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const macros = require('@ember-data/private-build-infra/src/v2-babel-build-pack'); | ||
|
||
module.exports = { | ||
plugins: [ | ||
...macros, | ||
// '@embroider/macros/src/babel/macros-babel-plugin.js', | ||
['@babel/plugin-transform-runtime', { loose: true }], | ||
['@babel/plugin-transform-typescript', { allowDeclareFields: true }], | ||
['@babel/plugin-proposal-decorators', { legacy: true, loose: true }], | ||
['@babel/plugin-proposal-private-methods', { loose: true }], | ||
['@babel/plugin-proposal-class-properties', { loose: true }], | ||
], | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,34 +13,66 @@ | |
"license": "MIT", | ||
"author": "", | ||
"directories": {}, | ||
"scripts": {}, | ||
"scripts": { | ||
"build": "rollup --config && babel ./addon --out-dir addon --plugins=../private-build-infra/src/transforms/babel-plugin-transform-ext.js", | ||
"start": "rollup --config --watch", | ||
"prepack": "pnpm build", | ||
"prepare": "pnpm build" | ||
}, | ||
"ember-addon": { | ||
"main": "addon-main.js", | ||
"type": "addon", | ||
"version": 1 | ||
}, | ||
"files": [ | ||
"addon-main.js", | ||
"addon" | ||
], | ||
"peerDependencies": { | ||
"@ember-data/store": "workspace:4.10.0-alpha.4", | ||
"@ember/string": "^3.0.0", | ||
"ember-inflector": "^4.0.2" | ||
}, | ||
"dependenciesMeta": { | ||
"@ember-data/canary-features": { | ||
"injected": true | ||
}, | ||
"@ember-data/private-build-infra": { | ||
"injected": true | ||
} | ||
}, | ||
"dependencies": { | ||
"@ember-data/private-build-infra": "workspace:4.10.0-alpha.4", | ||
"@ember/edition-utils": "^1.2.0", | ||
"@embroider/macros": "^1.10.0", | ||
"ember-auto-import": "^2.5.0", | ||
"ember-cli-babel": "^7.26.11", | ||
"ember-cli-test-info": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"webpack": "^5.75.0" | ||
"@babel/core": "^7.20.2", | ||
"@babel/cli": "^7.19.3", | ||
"@glimmer/component": "^1.1.2", | ||
"ember-source": "~4.8.2", | ||
"@embroider/addon-dev": "^2.0.0", | ||
"rollup": "^3.2.3", | ||
"@babel/plugin-proposal-class-properties": "^7.18.6", | ||
"@babel/plugin-proposal-private-methods": "^7.18.6", | ||
"@babel/plugin-proposal-decorators": "^7.20.0", | ||
"@babel/plugin-transform-typescript": "^7.20.0", | ||
"@babel/plugin-transform-runtime": "^7.19.6", | ||
"@babel/preset-typescript": "^7.18.6", | ||
"@babel/preset-env": "^7.19.4", | ||
"@babel/runtime": "^7.20.0", | ||
"@rollup/plugin-babel":"^6.0.2", | ||
"@rollup/plugin-node-resolve": "^15.0.1", | ||
"tslib": "^2.4.0", | ||
"walk-sync": "^3.0.0", | ||
"typescript": "^4.8.4" | ||
}, | ||
"engines": { | ||
"node": "^14.8.0 || 16.* || >= 18.*" | ||
}, | ||
"ember-addon": {}, | ||
"volta": { | ||
"extends": "../../package.json" | ||
}, | ||
"packageManager": "[email protected]" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Addon } from '@embroider/addon-dev/rollup'; | ||
import babel from '@rollup/plugin-babel'; | ||
import { nodeResolve } from '@rollup/plugin-node-resolve'; | ||
|
||
const addon = new Addon({ | ||
srcDir: 'src', | ||
destDir: 'addon', | ||
}); | ||
|
||
export default { | ||
// This provides defaults that work well alongside `publicEntrypoints` below. | ||
// You can augment this if you need to. | ||
output: addon.output(), | ||
|
||
external: [ | ||
'@embroider/macros', | ||
'@ember/service', | ||
'require', | ||
'rsvp', | ||
'ember-inflector', | ||
'@ember/debug', | ||
'@ember/string', | ||
'@ember/object', | ||
'@ember/error', | ||
'@ember/object/mixin', | ||
'@ember/application', | ||
'@glimmer/env', | ||
'@ember/runloop', | ||
'@ember/polyfills', | ||
], | ||
|
||
plugins: [ | ||
// These are the modules that users should be able to import from your | ||
// addon. Anything not listed here may get optimized away. | ||
addon.publicEntrypoints(['index.js', 'error.js', 'json-api.js', 'rest.js', '-private.js']), | ||
|
||
nodeResolve({ extensions: ['.ts', '.js'] }), | ||
babel({ | ||
extensions: ['.ts', '.js'], | ||
babelHelpers: 'runtime', // we should consider "external", | ||
}), | ||
|
||
// Remove leftover build artifacts when starting a new build. | ||
addon.clean(), | ||
], | ||
}; |
Oops, something went wrong.